From 875030f5a4728730725ef535f571c15de32eeaf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Choch=C3=B3=C5=82?= Date: Mon, 5 Nov 2018 17:29:18 +0100 Subject: [PATCH] Futher install changes --- bmotd.sh | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bmotd.sh b/bmotd.sh index f34b939..3fbaa93 100755 --- a/bmotd.sh +++ b/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 ;;