diff --git a/synchole.sh b/synchole.sh index 0bf43e9..2ca7b12 100755 --- a/synchole.sh +++ b/synchole.sh @@ -25,13 +25,6 @@ DEPENDENCIES="wget" # **** functions **** -## check if script is run by cron -amicron() { - if [ -t 1 ]; then - return 1 - fi -} - ## check for elevated privileges amiroot() { if [ $(whoami) != "root" ]; then @@ -48,6 +41,13 @@ amipihole() { ## output handling log() { + + if [ -t 1 ]; then + CRON=0 + else + CRON=1 + fi + case $1 in "error") level="\033[31m✗\033[0m" @@ -162,11 +162,7 @@ log debug "Starting synchole" ## preflight checks log debug "Running preflight checks" -if amicron; then - CRON=1 -else - CRON=0 -fi + if ! amiroot; then log error "You must be root"