Check if the system has systemd before trying to use it to stop/start services

This commit is contained in:
Eric Nemchik 2018-02-27 14:33:37 -06:00
commit f1428fba6c

View file

@ -102,6 +102,14 @@ unzip-strip() (
fi && rm -rf "$temp"/* "$temp"
)
IsSystemdSupported() {
if command -v systemctl > /dev/null && systemctl | grep -q '\-\.mount'; then
return 0
else
return 1
fi
}
# Import any custom config to override the defaults, if necessary
configfile="$(dirname $0)/update_ombi.conf"
if [ -e $configfile ]; then
@ -222,7 +230,8 @@ fi
.log 6 "File size validated...checking Ombi service status..."
declare -i running=0
if [ "`systemctl is-active $ombiservicename`" == "active" ]; then
if IsSystemdSupported; then
if [ "`systemctl is-active $ombiservicename`" == "active" ]; then
running=1
.log 6 "Ombi is active...attempting to stop..."
declare -i i=1
@ -252,8 +261,11 @@ if [ "`systemctl is-active $ombiservicename`" == "active" ]; then
exit 99
fi
done
else
else
.log 6 "Ombi is not active...installing update..."
fi
else
.log 4 "systemd not available..."
fi
unzip-strip $file $installdir