#!/bin/bash # Script Updating Gitea (c) Thomas Kuschel # since 2024 echo "Update the Gitea from the website and restart Gitea service" website_latest="https://github.com/go-gitea/gitea/releases/latest" website_uri="https://dl.gitea.io/gitea" file_prefix="gitea" file_suffix="linux-amd64" install_dir="/usr/local/bin" file_gitea="gitea" temp_folder="temp.gitea.08154711" # get the latest version with the website_latest uri to github: website_version_raw=$( curl -Ls -I -o /dev/null -w %{url_effective} ${website_latest} ) website_version=$( echo ${website_version_raw} | sed -E 's#(.*/v)([0-9\.]*)#\2#g' ) # echo ${website_version} # echo ${website_version_raw} if [ -n ${website_version} ] then version=${website_version} fi version_active_raw=$( gitea --version ) version_active=$( gitea --version | awk '{ print $3; exit }' ) echo "Website version: ${version}" echo " Active version: ${version_active}" if [ "${version}" == "${version_active}" ] then echo "Both version strings are the same." else echo "There are differences between the two version strings." echo "Start updating..." read -p "Are you sure? (y/N)" -n 1 -r echo # (optional) move to a new line if [[ $REPLY =~ ^[YyJj]$ ]] then uri=${website_uri}/${version}/${file_prefix}-${version}-${file_suffix} mkdir -p ${temp_folder} cd ${temp_folder} wget -O ${file_gitea} --show-progress ${uri} wget -O ${file_gitea}.sha256 ${uri}.sha256 # strip gitea sha256check=$( echo "$(cat ${file_gitea}.sha256 | awk '{ print $1 }') ${file_gitea}" | sha256sum --check ) echo ${sha256check} check=$( echo ${sha256check} | awk '{ print $2 }' ) if [ "${check}" == "OK" ] then echo "SHA256 was checked and verified OK" sudo install --owner=git --group=git --mode=755 --strip ${file_gitea} ${install_dir} else echo "There was a failure in the SHA256 file check." fi # remove local files: rm ${file_gitea} ${file_gitea}.sha256 cd .. rmdir ${temp_folder} fi fi #echo active gitea version: echo "Active gitea full version string:" gitea --version read -p "Restart the gitea service on the host? (y/N)" -n 1 -r echo # (optional) move to a new line if [[ $REPLY =~ ^[YyJj]$ ]] then sudo systemctl restart gitea.service echo "gitea.service restarted." fi