FIX gitea update, problem when there is a directory named gitea exists.
This commit is contained in:
		@@ -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
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user