From 4b3effc19f52cb9e0d528a0536fa915cf8512639 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 7 Apr 2021 03:37:23 +0200 Subject: [PATCH] Try updating Firebird password file again if we failed once This might help with sporadic failures in Travis CI Firebird build, which sometimes fails with weird errors like this: Unable to complete network request to host "localhost". Failed to establish a connection. unable to open database Error setting new SYSDBA password Note that dpkg-reconfigure does not return an error in this case, so we need to check the password file itself to see if it was updated. --- scripts/ci/install_firebird.sh | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/scripts/ci/install_firebird.sh b/scripts/ci/install_firebird.sh index 44c814e7..8fb91e7c 100755 --- a/scripts/ci/install_firebird.sh +++ b/scripts/ci/install_firebird.sh @@ -39,6 +39,13 @@ sudo apt-get install -qq expect ${firebird_server_package} firebird-dev # wouldn't be asked to change the password after the initial installation. export DEBIAN_FRONTEND=teletype +num_tries=1 +wait_time=6 # seconds + +while true; do + +echo "Reconfiguring Firebird (attempt #$num_tries):" + # Expect script feeding dpkg-reconfigure prompts sudo --preserve-env /usr/bin/expect - << ENDMARK spawn dpkg-reconfigure -plow $firebird_server_package @@ -52,8 +59,30 @@ expect eof ENDMARK # End of Expect script -echo "Firebird: cat /etc/firebird/$firebird_version/SYSDBA.password" -sudo grep ISC_ /etc/firebird/$firebird_version/SYSDBA.password +# Check that we've actually updated the password file as we sometimes fail to +# do it with "Unable to complete network request to host localhost." error. +firebird_password_file="/etc/firebird/$firebird_version/SYSDBA.password" + +# We have to be careful with grep as the password may or not be quoted, even +# with the same Firebird version (2.5) on the same system (Ubuntu Xenial), +# depending on whether we're running on Travis or GitHub CI. +if sudo cat "$firebird_password_file" | egrep -q 'ISC_PASSWORD="?masterkey'; then + echo "Successfully updated $firebird_password_file:" + sudo grep ISC_ $firebird_password_file + break +fi + +if [[ $num_tries -gt 10 ]]; then + echo "Failed to update Firebird password file after $num_tries attempts." + exit 1 +fi + +echo "Failed to reconfigure Firebird, retrying in $wait_time seconds..." +sleep $wait_time +((num_tries++)) + +done + echo echo "Firebird: restarting" sudo service $firebird_server_service restart