mirror of
https://github.com/Unimatrix0/update_ombi.git
synced 2025-08-19 04:50:44 -07:00
Check if the system has systemd before trying to use it to stop/start services
This commit is contained in:
parent
2be16cb034
commit
f1428fba6c
1 changed files with 42 additions and 30 deletions
|
@ -102,6 +102,14 @@ unzip-strip() (
|
||||||
fi && rm -rf "$temp"/* "$temp"
|
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
|
# Import any custom config to override the defaults, if necessary
|
||||||
configfile="$(dirname $0)/update_ombi.conf"
|
configfile="$(dirname $0)/update_ombi.conf"
|
||||||
if [ -e $configfile ]; then
|
if [ -e $configfile ]; then
|
||||||
|
@ -222,38 +230,42 @@ fi
|
||||||
.log 6 "File size validated...checking Ombi service status..."
|
.log 6 "File size validated...checking Ombi service status..."
|
||||||
|
|
||||||
declare -i running=0
|
declare -i running=0
|
||||||
if [ "`systemctl is-active $ombiservicename`" == "active" ]; then
|
if IsSystemdSupported; then
|
||||||
running=1
|
if [ "`systemctl is-active $ombiservicename`" == "active" ]; then
|
||||||
.log 6 "Ombi is active...attempting to stop..."
|
running=1
|
||||||
declare -i i=1
|
.log 6 "Ombi is active...attempting to stop..."
|
||||||
declare -i j=5
|
declare -i i=1
|
||||||
while [ $i -le $j ]
|
declare -i j=5
|
||||||
do
|
while [ $i -le $j ]
|
||||||
if [ $scriptuser = "root" ]; then
|
do
|
||||||
systemctl stop $ombiservicename.service > /dev/null 2>&1
|
if [ $scriptuser = "root" ]; then
|
||||||
else
|
systemctl stop $ombiservicename.service > /dev/null 2>&1
|
||||||
sudo systemctl stop $ombiservicename.service > /dev/null 2>&1
|
|
||||||
fi
|
|
||||||
if [ $? -ne 0 ] || [ "`systemctl is-active $ombiservicename`" == "active" ] ; then
|
|
||||||
if [ $i -lt $j ]; then
|
|
||||||
.log 3 "Failed to stop Ombi...[attempt $i of $j]"
|
|
||||||
sleep 1
|
|
||||||
else
|
else
|
||||||
.log 2 "Failed to stop Ombi...[attempt $i of $j]...Bailing!"
|
sudo systemctl stop $ombiservicename.service > /dev/null 2>&1
|
||||||
exit 2
|
|
||||||
fi
|
fi
|
||||||
i+=1
|
if [ $? -ne 0 ] || [ "`systemctl is-active $ombiservicename`" == "active" ] ; then
|
||||||
continue
|
if [ $i -lt $j ]; then
|
||||||
elif [ "`systemctl is-active $ombiservicename`" == "inactive" ]; then
|
.log 3 "Failed to stop Ombi...[attempt $i of $j]"
|
||||||
.log 6 "Ombi stopped...installing update..."
|
sleep 1
|
||||||
break
|
else
|
||||||
else
|
.log 2 "Failed to stop Ombi...[attempt $i of $j]...Bailing!"
|
||||||
.log 1 "Unknown error...bailing!"
|
exit 2
|
||||||
exit 99
|
fi
|
||||||
fi
|
i+=1
|
||||||
done
|
continue
|
||||||
|
elif [ "`systemctl is-active $ombiservicename`" == "inactive" ]; then
|
||||||
|
.log 6 "Ombi stopped...installing update..."
|
||||||
|
break
|
||||||
|
else
|
||||||
|
.log 1 "Unknown error...bailing!"
|
||||||
|
exit 99
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
.log 6 "Ombi is not active...installing update..."
|
||||||
|
fi
|
||||||
else
|
else
|
||||||
.log 6 "Ombi is not active...installing update..."
|
.log 4 "systemd not available..."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unzip-strip $file $installdir
|
unzip-strip $file $installdir
|
||||||
|
@ -334,4 +346,4 @@ elif [ $seconds -eq 1 ]; then
|
||||||
fi
|
fi
|
||||||
durationmsg="Update complete...elapsed time $duration..."
|
durationmsg="Update complete...elapsed time $duration..."
|
||||||
durationmsg="${durationmsg// / }"
|
durationmsg="${durationmsg// / }"
|
||||||
.log 6 "$durationmsg"
|
.log 6 "$durationmsg"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue