scripts/gitea/download_update_gitea.sh

74 lines
2.0 KiB
Bash
Raw Normal View History

2024-06-10 11:44:44 +02:00
#!/bin/sh
# Script Updating Gitea (c) Thomas Kuschel
# since 2024
2024-06-10 11:44:44 +02:00
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"
# 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