FIX with temp dir

This commit is contained in:
Thomas Kuschel 2024-07-24 01:44:45 +02:00
parent 8f9c0a3ed4
commit 9bf5b636b9

View File

@ -9,7 +9,9 @@ website_uri="https://dl.gitea.io/gitea"
file_prefix="gitea" file_prefix="gitea"
file_suffix="linux-amd64" file_suffix="linux-amd64"
install_dir="/usr/local/bin" install_dir="/usr/local/bin"
temp_file="gitea.temp08154711" file_gitea="gitea"
temp_folder="temp08154711"
temp_file=${temp_folder}/${file_gitea}
# get the latest version with the website_latest uri to github: # 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_raw=$( curl -Ls -I -o /dev/null -w %{url_effective} ${website_latest} )
@ -39,24 +41,27 @@ else
if [[ $REPLY =~ ^[YyJj]$ ]] if [[ $REPLY =~ ^[YyJj]$ ]]
then then
uri=${website_uri}/${version}/${file_prefix}-${version}-${file_suffix} uri=${website_uri}/${version}/${file_prefix}-${version}-${file_suffix}
wget -O ${temp_file} --show-progress ${uri} cd ${temp_folder}
wget -O gitea.sha256 ${uri}.sha256 wget -O ${file_gitea} --show-progress ${uri}
wget -O ${file_gitea}.sha256 ${uri}.sha256
# strip gitea # strip gitea
sha256check=$( echo "$(cat gitea.sha256 | awk '{ print $1 }') ${temp_file}" | sha256sum --check ) sha256check=$( echo "$(cat gitea.sha256 | awk '{ print $1 }') ${file_gitea}" | sha256sum --check )
echo ${sha256check} echo ${sha256check}
check=$( echo ${sha256check} | awk '{ print $2 }' ) check=$( echo ${sha256check} | awk '{ print $2 }' )
if [ "${check}" == "OK" ] if [ "${check}" == "OK" ]
then then
echo "SHA256 was checked and verified OK" echo "SHA256 was checked and verified OK"
sudo install --owner=git --group=git --mode=755 --strip ${temp_file} ${install_dir} sudo install --owner=git --group=git --mode=755 --strip ${file_gitea} ${install_dir}
else else
echo "There was a failure in the SHA256 file check." echo "There was a failure in the SHA256 file check."
fi fi
# remove local files: # remove local files:
rm ${temp_file} gitea.sha256 rm ${temp_file} gitea.sha256
cd ..
rmdir ${temp_folder}
fi fi
fi fi