mirror of
https://github.com/Unimatrix0/update_ombi.git
synced 2025-07-06 13:01:55 -07:00
feat(updater): remove loop
This commit is contained in:
parent
9846ce0fec
commit
51a0510143
1 changed files with 212 additions and 219 deletions
|
@ -87,6 +87,7 @@ while [ $# -gt 0 ]; do
|
||||||
printf "* Error: Invalid argument. *\n"
|
printf "* Error: Invalid argument. *\n"
|
||||||
printf "****************************\n"
|
printf "****************************\n"
|
||||||
exit 1
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
@ -192,10 +193,6 @@ if [ "$archshort" = 'arm' ]; then
|
||||||
else
|
else
|
||||||
filename='linux-x64.tar.gz'
|
filename='linux-x64.tar.gz'
|
||||||
fi
|
fi
|
||||||
declare -i i=1
|
|
||||||
declare -i j=5
|
|
||||||
while [ $i -le $j ]
|
|
||||||
do
|
|
||||||
.log 6 "Checking for latest version"
|
.log 6 "Checking for latest version"
|
||||||
if [ -z "$baseurl" ]; then
|
if [ -z "$baseurl" ]; then
|
||||||
json=$(curl -sL http://$ip:$port/$baseurl/api/v1/Update)
|
json=$(curl -sL http://$ip:$port/$baseurl/api/v1/Update)
|
||||||
|
@ -238,7 +235,6 @@ do
|
||||||
# .log 1 "Invalid file size value...bailing!"
|
# .log 1 "Invalid file size value...bailing!"
|
||||||
# exit 99
|
# exit 99
|
||||||
#fi
|
#fi
|
||||||
done
|
|
||||||
tempdir=$(mktemp -d)
|
tempdir=$(mktemp -d)
|
||||||
file="$tempdir/ombi_$version.tar.gz"
|
file="$tempdir/ombi_$version.tar.gz"
|
||||||
wget --quiet --show-progress -O $file "https://github.com/Ombi-app/Ombi/releases/download/$latestversion/$filename"
|
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..."
|
.log 6 "Checking Ombi service status..."
|
||||||
|
|
||||||
declare -i running=0
|
declare -i running=0
|
||||||
if [ "`systemctl is-active $ombiservicename`" == "active" ]; then
|
if [ "$(systemctl is-active $ombiservicename)" == "active" ]; then
|
||||||
running=1
|
running=1
|
||||||
.log 6 "Ombi is active...attempting to stop..."
|
.log 6 "Ombi is active...attempting to stop..."
|
||||||
declare -i i=1
|
declare -i i=1
|
||||||
declare -i j=5
|
declare -i j=5
|
||||||
while [ $i -le $j ]
|
while [ $i -le $j ]; do
|
||||||
do
|
|
||||||
if [ $scriptuser = "root" ]; then
|
if [ $scriptuser = "root" ]; then
|
||||||
systemctl stop $ombiservicename.service >/dev/null 2>&1
|
systemctl stop $ombiservicename.service >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
sudo systemctl stop $ombiservicename.service >/dev/null 2>&1
|
sudo systemctl stop $ombiservicename.service >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
if [ $? -ne 0 ] || [ "`systemctl is-active $ombiservicename`" == "active" ] ; then
|
if [ $? -ne 0 ] || [ "$(systemctl is-active $ombiservicename)" == "active" ]; then
|
||||||
if [ $i -lt $j ]; then
|
if [ $i -lt $j ]; then
|
||||||
.log 3 "Failed to stop Ombi...[attempt $i of $j]"
|
.log 3 "Failed to stop Ombi...[attempt $i of $j]"
|
||||||
sleep 1
|
sleep 1
|
||||||
|
@ -272,7 +267,7 @@ if [ "`systemctl is-active $ombiservicename`" == "active" ]; then
|
||||||
fi
|
fi
|
||||||
i+=1
|
i+=1
|
||||||
continue
|
continue
|
||||||
elif [ "`systemctl is-active $ombiservicename`" == "inactive" ]; then
|
elif [ "$(systemctl is-active $ombiservicename)" == "inactive" ]; then
|
||||||
.log 6 "Ombi stopped...installing update..."
|
.log 6 "Ombi stopped...installing update..."
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
|
@ -296,14 +291,13 @@ if [ $running -eq 1 ]; then
|
||||||
.log 6 "Ownership set...starting Ombi..."
|
.log 6 "Ownership set...starting Ombi..."
|
||||||
declare -i i=1
|
declare -i i=1
|
||||||
declare -i j=5
|
declare -i j=5
|
||||||
while [ $i -le $j ]
|
while [ $i -le $j ]; do
|
||||||
do
|
|
||||||
if [ $scriptuser = "root" ]; then
|
if [ $scriptuser = "root" ]; then
|
||||||
systemctl start $ombiservicename.service >/dev/null 2>&1
|
systemctl start $ombiservicename.service >/dev/null 2>&1
|
||||||
else
|
else
|
||||||
sudo systemctl start $ombiservicename.service >/dev/null 2>&1
|
sudo systemctl start $ombiservicename.service >/dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
if [ $? -ne 0 ] || [ "`systemctl is-active $ombiservicename`" != "active" ] ; then
|
if [ $? -ne 0 ] || [ "$(systemctl is-active $ombiservicename)" != "active" ]; then
|
||||||
if [ $i -lt $j ]; then
|
if [ $i -lt $j ]; then
|
||||||
.log 3 "Failed to start Ombi...[attempt $i of $j]"
|
.log 3 "Failed to start Ombi...[attempt $i of $j]"
|
||||||
sleep 1
|
sleep 1
|
||||||
|
@ -313,12 +307,11 @@ if [ $running -eq 1 ]; then
|
||||||
fi
|
fi
|
||||||
i+=1
|
i+=1
|
||||||
continue
|
continue
|
||||||
elif [ "`systemctl is-active $ombiservicename`" == "active" ]; then
|
elif [ "$(systemctl is-active $ombiservicename)" == "active" ]; then
|
||||||
.log 6 "Ombi started...waiting for confirmation..."
|
.log 6 "Ombi started...waiting for confirmation..."
|
||||||
declare -i k=1
|
declare -i k=1
|
||||||
declare -i l=5
|
declare -i l=5
|
||||||
while [ $k -le $l ]
|
while [ $k -le $l ]; do
|
||||||
do
|
|
||||||
sleep 5
|
sleep 5
|
||||||
curl -sIL $ip:$port >/dev/null 2>&1
|
curl -sIL $ip:$port >/dev/null 2>&1
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue