template_setup/15-Tweaking_Systemd_Journalling.sh
2022-04-06 07:11:52 -04:00

38 lines
1005 B
Bash

#!/bin/bash
## Script Location
SCRIPTDIR=$(dirname $0)
source "$SCRIPTDIR/common/colors.sh"
source "$SCRIPTDIR/common/functions.sh"
printf "$COL_LIGHT_BLUE" "* Vaccuming Systemd Journal"
journalctl --vacuum-size=50M
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
systemd_journald_conf="/etc/systemd/journald.conf"
if (whiptail --title "Systemd Journalling limits" --yes-button "yes" --no-button "no" --yesno "Do You want to join a limit systemd journalling?" 10 80)
then
if [[ $(grep -L "Change Logging maximums" $systemd_journald_conf) ]]; then
printf "$COL_YELLOW" "** Limitting"
cat <<EOT >> $systemd_journald_conf
#Change Logging maximums
RuntimeMaxFileSize=50
RuntimeMaxFiles=100
EOT
else
printf "$COL_YELLOW" "** not limitting"
fi
fi
systemctl restart systemd-journald