Futher install changes

master
Mateusz Chochół 7 years ago
parent 676d1aeca9
commit 875030f5a4
  1. 13
      bmotd.sh

@ -27,19 +27,22 @@ main () {
case "$1" in
enable)
echo -e "\nEnabling bmotd.sh"
# copy to INSTPATH
cp "$(readlink -f $0)" "$INSTPATH"
# check if crontab present
command -v crontab >/dev/null 2>&1 || ( echo "Error: couldn't find crontab. Exiting..."; exit 1)
# Check if motd writable
test -w $MOTD || ( echo "Unable to write $MOTD . To enable update permissions. Exiting..."; exit 1 )
# Check if script is already in crontab, if not add itself
CRON_ENTRY="* * * * * $(realpath "$0")"
CRON_ENTRY="* * * * * $INSTPATH"
crontab -l 2>/dev/null | grep -q "$CRON_ENTRY" || ( crontab -l 2>/dev/null; echo "$CRON_ENTRY" ) | crontab -
echo -e "Success! Check it yourself with crontab -l"
# Check if motd writable
test -w $MOTD || echo "Unable to write $MOTD . To enable update permissions."
echo "Exiting."
exit 0
;;

Loading…
Cancel
Save