#!/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