FIX gitea update, problem when there is a directory named gitea exists.

This commit is contained in:
Thomas Kuschel 2024-07-24 01:21:59 +02:00
parent 88072138d4
commit 8f9c0a3ed4

View File

@ -9,6 +9,7 @@ website_uri="https://dl.gitea.io/gitea"
file_prefix="gitea"
file_suffix="linux-amd64"
install_dir="/usr/local/bin"
temp_file="gitea.temp08154711"
# 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} )
@ -31,31 +32,31 @@ if [ "${version}" == "${version_active}" ]
then
echo "Both version strings are the same."
else
echo "There are differnces between the two version strings."
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}
wget -O gitea --show-progress ${uri}
wget -O ${temp_file} --show-progress ${uri}
wget -O gitea.sha256 ${uri}.sha256
# strip gitea
sha256check=$( echo "$(cat gitea.sha256 | awk '{ print $1 }') gitea" | sha256sum --check )
sha256check=$( echo "$(cat gitea.sha256 | awk '{ print $1 }') ${temp_file}" | 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}
sudo install --owner=git --group=git --mode=755 --strip ${temp_file} ${install_dir}
else
echo "There was a failure in the SHA256 file check."
fi
# remove local files:
rm gitea gitea.sha256
rm ${temp_file} gitea.sha256
fi
fi