Files
HomeServerCTs/CT-Files/gitea/Scripts/Update-Gitea.sh
Bram Prieshof a647ab711b Fixed CT's NodeRed (Missing setting) and Gitea (Broken updater)
CT NodeRed: Fixed missing config file by adding 5sec wait time before ending pm2 on setup to generate it
CT Gitea: moved from `gitea-auto-update`  from to an basic sh script since it is broken on AlpineLinux
2025-01-10 19:30:45 +01:00

27 lines
958 B
Bash

#!/bin/ash
#Check if Gitea is running
case $(service gitea status) in
*started*);;
*)
echo "Gitea is not running, exiting"
exit ;;
esac
#Check internet connection
if ! ping -c 2 api.github.com &> /dev/null; then echo "No internet connection detected, exiting";exit ;fi
#Get latest vesion
NewGiteaVer=$(curl --retry 7 --retry-delay 5 -Ls https://api.github.com/repos/go-gitea/gitea/releases/latest |jq -r .tag_name)
CurGiteaVer=$(curl --retry 7 --retry-delay 5 -Ls http://localhost:3000/api/v1/version |jq -r .version)
#Compare versions to check for update
if [ "$NewGiteaVer" = "$CurGiteaVer" ] ; then
echo 'Gitea up-to-date'
exit
else
echo 'Updating Gitea'
service gitea stop
mv /usr/local/bin/gitea /usr/local/bin/gitea.old
curl --retry 7 --retry-delay 5 -L https://dl.gitea.io/gitea/"${NewGiteaVer//v}"/gitea-"${NewGiteaVer//v}"-linux-amd64 -o /usr/local/bin/gitea
chmod +x /usr/local/bin/gitea
service gitea start
fi