template_setup/050-Tweaking_Systemd_Journalling.sh
deathbybandaid f64e0cb9a0 test
2023-12-17 11:14:22 -05:00

48 lines
1.3 KiB
Bash

#!/bin/bash
## Script Location
SCRIPTDIR=$(dirname $0)
source "$SCRIPTDIR/common/colors.sh"
source "$SCRIPTDIR/common/functions.sh"
source "$SCRIPTDIR/common/load-defaults.sh"
do_limit_journal() {
systemd_journald_conf="/etc/systemd/journald.conf"
if [[ $(grep -L "Change Logging maximums" $systemd_journald_conf) ]]; then
printf "$COL_YELLOW" "** Applying Systemd Journal tweak"
cat <<EOT >> $systemd_journald_conf
#Change Logging maximums
RuntimeMaxFileSize=50
RuntimeMaxFiles=100
EOT
else
printf "$COL_YELLOW" "** Systemd Journal tweak already applied"
fi
}
printf "$COL_LIGHT_BLUE" "* Checking for Systemd Journal directory"
journal_directory="/var/log/journal"
if [ ! -d "$journal_directory" ]; then
printf "$COL_YELLOW" "** creating Systemd Journal installation directory"
mkdir $journal_directory
fi
if [ "$systemd_journaling_tweak" == "ask" ]; then
if (whiptail --title "Systemd Journalling limits" --yes-button "yes" --no-button "no" --yesno "Do You want to limit systemd journalling?" 10 80)
then
systemd_journaling_tweak=1
else
systemd_journaling_tweak=0
fi
fi
if [ "$systemd_journaling_tweak" == 1 ]; then
printf "$COL_YELLOW" "** Limitting"
do_limit_journal
systemctl restart systemd-journald
else
printf "$COL_YELLOW" "** not Applying Systemd Journal tweak"
fi