feat(core): address LAST shellcheck "error" warning and make y/n questions in upgrade use the same variable.

This commit is contained in:
purple 2023-12-22 13:31:44 +01:00
parent 5aaf41e668
commit 1c4389ebf7

View file

@ -1367,38 +1367,49 @@ if [[ $2 == "-upgrade" ]]; then VCMD="y"
quit_red "[FATAL] Your development directory contains files. To protect you against accidental data loss, you are unable to upgrade unless you clear your .blueprint/dev folder." quit_red "[FATAL] Your development directory contains files. To protect you against accidental data loss, you are unable to upgrade unless you clear your .blueprint/dev folder."
fi fi
if [[ $@ == *"dev"* ]]; then
# Confirmation question for developer upgrade.
if [[ $3 == "dev" ]]; then
log_blue "[INPUT] Upgrading to the latest dev build will update Blueprint to an unstable work-in-progress preview of the next version. Continue? (y/N)" log_blue "[INPUT] Upgrading to the latest dev build will update Blueprint to an unstable work-in-progress preview of the next version. Continue? (y/N)"
read -r YN1 read -r YN
if [[ ( ${YN1} != "y"* ) && ( ${YN1} != "Y"* ) ]]; then log_bright "[INFO] Upgrade cancelled.";exit 1;fi if [[ ( ${YN} != "y"* ) && ( ${YN} != "Y"* ) ]]; then log_bright "[INFO] Upgrade cancelled.";exit 1;fi
YN=""
fi fi
# Confirmation question for both developer and stable upgrade.
log_blue "[INPUT] Upgrading will wipe your .blueprint folder and will overwrite your extensions. Continue? (y/N)" log_blue "[INPUT] Upgrading will wipe your .blueprint folder and will overwrite your extensions. Continue? (y/N)"
read -r YN2 read -r YN
if [[ ( ${YN2} != "y"* ) && ( ${YN2} != "Y"* ) ]]; then log_bright "[INFO] Upgrade cancelled.";exit 1;fi if [[ ( ${YN} != "y"* ) && ( ${YN} != "Y"* ) ]]; then log_bright "[INFO] Upgrade cancelled.";exit 1;fi
YN=""
# Last confirmation question for both developer and stable upgrade.
log_blue "[INPUT] This is the last warning before upgrading/wiping Blueprint. Type 'continue' to continue, all other input will be taken as 'no'." log_blue "[INPUT] This is the last warning before upgrading/wiping Blueprint. Type 'continue' to continue, all other input will be taken as 'no'."
read -r YN3 read -r YN
if [[ ${YN3} != "continue" ]]; then log_bright "[INFO] Upgrade cancelled.";exit 1;fi if [[ ${YN} != "continue" ]]; then log_bright "[INFO] Upgrade cancelled.";exit 1;fi
YN=""
log_bright "[INFO] Blueprint is upgrading.. Please do not turn off your machine." log_bright "[INFO] Blueprint is upgrading.. Please do not turn off your machine."
cp blueprint.sh .blueprint.sh.bak cp blueprint.sh .blueprint.sh.bak
if [[ $@ == *" dev" ]]; then if [[ $3 == "dev" ]]; then bash tools/update.sh ${FOLDER} dev
bash tools/update.sh ${FOLDER} dev else bash tools/update.sh ${FOLDER}; fi
else
bash tools/update.sh ${FOLDER}
fi
chmod +x blueprint.sh chmod +x blueprint.sh
sed -i -E "s|FOLDER=\"/var/www/pterodactyl\" #;|FOLDER=\"$FOLDER\" #;|g" $FOLDER/blueprint.sh sed -i -E "s|FOLDER=\"/var/www/pterodactyl\" #;|FOLDER=\"$FOLDER\" #;|g" $FOLDER/blueprint.sh
mv $FOLDER/blueprint $FOLDER/.blueprint; mv $FOLDER/blueprint $FOLDER/.blueprint;
bash blueprint.sh --post-upgrade bash blueprint.sh --post-upgrade
log_bright "[INFO] Bash might spit out some errors from here on out. Unexpected end of file (eof), command not found and syntax errors are expected behaviour." log_bright "[INFO] Bash might spit out some errors from here on out. Unexpected end of file (eof), command not found and syntax errors are expected behaviour."
# Ask user if they'd like to migrate their database.
log_blue "[INPUT] Do you want to migrate your database? (Y/n)" log_blue "[INPUT] Do you want to migrate your database? (Y/n)"
read -r YN4 read -r YN
if [[ ( ${YN4} == "y" ) || ( ${YN4} == "Y" ) || ( ${YN4} == "" ) ]]; then if [[ ( ${YN} == "y" ) || ( ${YN} == "Y" ) || ( ${YN} == "" ) ]]; then
log_bright "[INFO] Running database migrations.." log_bright "[INFO] Running database migrations.."
php artisan migrate --force php artisan migrate --force
else else
log_bright "[INFO] Database migrations have been skipped." log_bright "[INFO] Database migrations have been skipped."
fi fi
YN=""
# Post-upgrade checks. # Post-upgrade checks.
log_bright "[INFO] Running post-upgrade checks.." log_bright "[INFO] Running post-upgrade checks.."