Improve --redownload

Refactor junk code
This commit is contained in:
Jiří Štefka 2023-02-27 00:52:04 +01:00
parent 11eeafa289
commit f8dd301eeb

@ -236,11 +236,7 @@ function self_update {
# Download the latest version of the script # Download the latest version of the script
echo "Updating script..." echo "Updating script..."
# Download the file into msman_new.sh # Download the file into msman_new.sh
curl -sLJ -w '%{http_code}\n' "https://github.com/$REPO_OWNER/$REPO_NAME/releases/download/$LATEST_SCRIPT_VERSION/msman.sh" > msman_new.sh if [[ $(curl -sLJ -w '%{http_code}\n' "https://github.com/$REPO_OWNER/$REPO_NAME/releases/download/$LATEST_SCRIPT_VERSION/msman.sh" -o msman_new.sh) == 200 ]]; then
# Check if the download was successful by checking the last line of the file for 200
if [[ $(cat msman_new.sh | tail -n 1) == 200 ]]; then
# Remove the last line of the file
sed -i '$d' msman_new.sh
# Make the file executable # Make the file executable
chmod +x msman_new.sh chmod +x msman_new.sh
# Remove the old script # Remove the old script