#!/usr/bin/env bash
# Turns sys logs ON

#[ -t 1 ] &&
. colors



STARTCMNT="# LOGS OFF START"
ENDCMNT="# LOGS OFF END"

fstab=`cat /etc/fstab`


# Enable systemd-journald persistent files
if ! (cat /etc/systemd/journald.conf | grep -q '^Storage=persistent$'); then
	sed -E 's/^[#]?Storage=.*$/Storage=persistent/g' -i /etc/systemd/journald.conf
fi


echo "$fstab" | grep -q "$STARTCMNT"

[[ $? -ne 0 ]] &&
	echo "Logs already enabled" &&
	exit 0


echo "$fstab" | sed "/$STARTCMNT/,/$ENDCMNT/d" > /etc/fstab


echo -e "Disk logs are ${GREEN}enabled${NOCOLOR} now. History will stay after reboots.\n${YELLOW}Please reboot.${NOCOLOR}"