Skip to content

Commit

Permalink
Fix makemysql abnormal exit checks (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
ja5087 authored and Justin Zhang committed Mar 12, 2022
1 parent 1acf9bd commit 39e403b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
5 changes: 2 additions & 3 deletions makeservices/easywp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ fi
echo "Resetting database password..."
# Do not exit immediately if makemysql fails, as we need to display some error message...
set +e
sqlpass=$(makemysql --quiet)
# I don't know if this will work... Just make sure no abnormal exit code first!
if [ $? ] || [[ -z "$sqlpass" ]]; then
# Make sure exit code is normal
if ! sqlpass=$(makemysql --quiet) || [[ -z "$sqlpass" ]]; then
echo -e "\\033[31mError:\\033[00m Could not retrieve database password. Run makemysql to see the issue."
exit 1
fi
Expand Down
3 changes: 1 addition & 2 deletions makeservices/makemysql
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ done
# The correctness of this line relies on the fact that
# makemysql-real will output the new password ONLY on the
# last line. The --quiet will also make sure it only output the password...
PASS=$(sudo -u mysql /opt/share/utils/makeservices/makemysql-real --quiet)

if [ $? ] ; then
if ! PASS=$(sudo -u mysql /opt/share/utils/makeservices/makemysql-real --quiet) ; then
echo 'makemysql-real did not exit properly.'
echo 'Run "sudo -u mysql /opt/share/utils/makeservices/makemysql-real" for a more verbose output.'
echo 'Additionally, you may contact staff members for help. This script will stop.'
Expand Down

0 comments on commit 39e403b

Please sign in to comment.