fixed an issue with cron detection
This commit is contained in:
parent
00a7209d0f
commit
b6425cd6da
20
synchole.sh
20
synchole.sh
|
@ -25,13 +25,6 @@ DEPENDENCIES="wget"
|
||||||
|
|
||||||
# **** functions ****
|
# **** functions ****
|
||||||
|
|
||||||
## check if script is run by cron
|
|
||||||
amicron() {
|
|
||||||
if [ -t 1 ]; then
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
## check for elevated privileges
|
## check for elevated privileges
|
||||||
amiroot() {
|
amiroot() {
|
||||||
if [ $(whoami) != "root" ]; then
|
if [ $(whoami) != "root" ]; then
|
||||||
|
@ -48,6 +41,13 @@ amipihole() {
|
||||||
|
|
||||||
## output handling
|
## output handling
|
||||||
log() {
|
log() {
|
||||||
|
|
||||||
|
if [ -t 1 ]; then
|
||||||
|
CRON=0
|
||||||
|
else
|
||||||
|
CRON=1
|
||||||
|
fi
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
"error")
|
"error")
|
||||||
level="\033[31m✗\033[0m"
|
level="\033[31m✗\033[0m"
|
||||||
|
@ -162,11 +162,7 @@ log debug "Starting synchole"
|
||||||
|
|
||||||
## preflight checks
|
## preflight checks
|
||||||
log debug "Running preflight checks"
|
log debug "Running preflight checks"
|
||||||
if amicron; then
|
|
||||||
CRON=1
|
|
||||||
else
|
|
||||||
CRON=0
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! amiroot; then
|
if ! amiroot; then
|
||||||
log error "You must be root"
|
log error "You must be root"
|
||||||
|
|
Reference in New Issue