Browse Source

fix: only overwrite run.sh if successful response is received (#299)

pull/303/head
tangowithfoxtrot 1 year ago committed by GitHub
parent
commit
c3ddb7483d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 10
      bitwarden.sh

10
bitwarden.sh

@ -93,16 +93,20 @@ function downloadRunFile() { @@ -93,16 +93,20 @@ function downloadRunFile() {
then
mkdir $SCRIPTS_DIR
fi
run_file_status_code=$(curl -s -L -w "%{http_code}" -o $SCRIPTS_DIR/run.sh $RUN_SCRIPT_URL)
local tmp_script=$(mktemp)
run_file_status_code=$(curl -s -L -w "%{http_code}" -o $tmp_script $RUN_SCRIPT_URL)
if echo "$run_file_status_code" | grep -q "^20[0-9]"
then
mv $tmp_script $SCRIPTS_DIR/run.sh
chmod u+x $SCRIPTS_DIR/run.sh
rm -f $SCRIPTS_DIR/install.sh
else
echo "Unable to download run script from $RUN_SCRIPT_URL. Received status code: $run_file_status_code"
echo "http response:"
cat $SCRIPTS_DIR/run.sh
rm -f $SCRIPTS_DIR/run.sh
cat $tmp_script
rm -f $tmp_script
exit 1
fi
}

Loading…
Cancel
Save