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

This commit is contained in:
tangowithfoxtrot
2024-10-31 09:07:40 -07:00
committed by GitHub
parent 86fd559f40
commit c3ddb7483d

View File

@@ -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
}