From b6425cd6da3f6c16268431d09dcf4d673e67de9b Mon Sep 17 00:00:00 2001 From: david Date: Sat, 9 Nov 2019 02:59:24 +0100 Subject: [PATCH] fixed an issue with cron detection --- synchole.sh | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) 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"