ADD download_update_gitea script for mycarbon

This commit is contained in:
Thomas Kuschel 2024-06-10 11:33:51 +02:00
commit 04a882f52f

View File

@ -0,0 +1,75 @@
echo "Update the Gitea from the website and restart Gitea Service"
# version=1.15.0
# if [ -n "$1" ]
# then
# version=$1
# fi
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"
# 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 Equal."
else
echo "Both Version Strings are not Equal."
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}
wget -O gitea --show-progress ${uri}
wget -O gitea.sha256 ${uri}.sha256
# strip gitea
sha256check=$( echo "$(cat gitea.sha256 | awk '{ print $1 }') 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 gitea ${install_dir}
else
echo "There was a failure in the SHA256 file check."
fi
# remove local files:
rm gitea gitea.sha256
fi
fi
#echo active gitea version:
echo "Print the 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 "Restarted gitea.service"
fi