feat(updater): remove loop

This commit is contained in:
agaucher 2021-04-13 13:19:35 +02:00
parent 9846ce0fec
commit 51a0510143

View file

@ -87,6 +87,7 @@ while [ $# -gt 0 ]; do
printf "* Error: Invalid argument. *\n"
printf "****************************\n"
exit 1
;;
esac
shift
done
@ -192,10 +193,6 @@ if [ "$archshort" = 'arm' ]; then
else
filename='linux-x64.tar.gz'
fi
declare -i i=1
declare -i j=5
while [ $i -le $j ]
do
.log 6 "Checking for latest version"
if [ -z "$baseurl" ]; then
json=$(curl -sL http://$ip:$port/$baseurl/api/v1/Update)
@ -238,7 +235,6 @@ do
# .log 1 "Invalid file size value...bailing!"
# exit 99
#fi
done
tempdir=$(mktemp -d)
file="$tempdir/ombi_$version.tar.gz"
wget --quiet --show-progress -O $file "https://github.com/Ombi-app/Ombi/releases/download/$latestversion/$filename"
@ -250,19 +246,18 @@ wget --quiet --show-progress -O $file "https://github.com/Ombi-app/Ombi/releases
.log 6 "Checking Ombi service status..."
declare -i running=0
if [ "`systemctl is-active $ombiservicename`" == "active" ]; then
if [ "$(systemctl is-active $ombiservicename)" == "active" ]; then
running=1
.log 6 "Ombi is active...attempting to stop..."
declare -i i=1
declare -i j=5
while [ $i -le $j ]
do
while [ $i -le $j ]; do
if [ $scriptuser = "root" ]; then
systemctl stop $ombiservicename.service >/dev/null 2>&1
else
sudo systemctl stop $ombiservicename.service >/dev/null 2>&1
fi
if [ $? -ne 0 ] || [ "`systemctl is-active $ombiservicename`" == "active" ] ; then
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
@ -272,7 +267,7 @@ if [ "`systemctl is-active $ombiservicename`" == "active" ]; then
fi
i+=1
continue
elif [ "`systemctl is-active $ombiservicename`" == "inactive" ]; then
elif [ "$(systemctl is-active $ombiservicename)" == "inactive" ]; then
.log 6 "Ombi stopped...installing update..."
break
else
@ -296,14 +291,13 @@ if [ $running -eq 1 ]; then
.log 6 "Ownership set...starting Ombi..."
declare -i i=1
declare -i j=5
while [ $i -le $j ]
do
while [ $i -le $j ]; do
if [ $scriptuser = "root" ]; then
systemctl start $ombiservicename.service >/dev/null 2>&1
else
sudo systemctl start $ombiservicename.service >/dev/null 2>&1
fi
if [ $? -ne 0 ] || [ "`systemctl is-active $ombiservicename`" != "active" ] ; then
if [ $? -ne 0 ] || [ "$(systemctl is-active $ombiservicename)" != "active" ]; then
if [ $i -lt $j ]; then
.log 3 "Failed to start Ombi...[attempt $i of $j]"
sleep 1
@ -313,12 +307,11 @@ if [ $running -eq 1 ]; then
fi
i+=1
continue
elif [ "`systemctl is-active $ombiservicename`" == "active" ]; then
elif [ "$(systemctl is-active $ombiservicename)" == "active" ]; then
.log 6 "Ombi started...waiting for confirmation..."
declare -i k=1
declare -i l=5
while [ $k -le $l ]
do
while [ $k -le $l ]; do
sleep 5
curl -sIL $ip:$port >/dev/null 2>&1
if [ $? -ne 0 ]; then