Warning, file /sdk/codevis/thirdparty/soci/scripts/ci/install_firebird.sh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 #!/usr/bin/env bash
0002 # Install Firebird server for SOCI in CI builds
0003 #
0004 # Copyright (c) 2013 Mateusz Loskot <mateusz@loskot.net>
0005 #
0006 source ${SOCI_SOURCE_DIR}/scripts/ci/common.sh
0007 
0008 codename=$(lsb_release -sc)
0009 case "$codename" in
0010     trusty | xenial)
0011         firebird_version=2.5
0012         firebird_server_package=firebird2.5-super
0013         firebird_server_service=firebird2.5-super
0014         firebird_expect_enable=$(cat <<EOF
0015 expect "Enable Firebird server?"
0016 send "yes\r"
0017 EOF
0018 )
0019         ;;
0020 
0021     jammy | focal | bionic)
0022         firebird_version=3.0
0023         firebird_server_package=firebird3.0-server
0024         firebird_server_service=firebird3.0
0025         ;;
0026 
0027     *)
0028         echo "*** Can't install Firebird: unknown Ubuntu version $codename! ***"
0029         exit 1
0030 esac
0031 
0032 run_apt install expect ${firebird_server_package} firebird-dev
0033 
0034 # Default frontend is "noninteractive", which prevents dpkg-reconfigure from
0035 # asking anything at all, so change it. Notice that we must do it via
0036 # environment and not using -f option of dpkg-reconfigure because it is
0037 # overridden by the existing environment variable (which is predefined).
0038 #
0039 # OTOH we do need to set priority to low using -p option below as otherwise we
0040 # wouldn't be asked to change the password after the initial installation.
0041 export DEBIAN_FRONTEND=teletype
0042 
0043 num_tries=1
0044 wait_time=6 # seconds
0045 
0046 while true; do
0047 
0048 echo "Reconfiguring Firebird (attempt #$num_tries):"
0049 
0050 # Expect script feeding dpkg-reconfigure prompts
0051 sudo --preserve-env /usr/bin/expect - << ENDMARK
0052 spawn dpkg-reconfigure -plow $firebird_server_package
0053 $firebird_expect_enable
0054 
0055 expect "Password for SYSDBA:"
0056 send "masterkey\r"
0057 
0058 # done
0059 expect eof
0060 ENDMARK
0061 # End of Expect script
0062 
0063 # Check that we've actually updated the password file as we sometimes fail to
0064 # do it with "Unable to complete network request to host localhost." error.
0065 firebird_password_file="/etc/firebird/$firebird_version/SYSDBA.password"
0066 
0067 # We have to be careful with grep as the password may or not be quoted, even
0068 # with the same Firebird version (2.5) on the same system (Ubuntu Xenial),
0069 # depending on whether we're running on Travis or GitHub CI.
0070 if sudo cat "$firebird_password_file" | egrep -q 'ISC_PASSWORD="?masterkey'; then
0071     echo "Successfully updated $firebird_password_file:"
0072     sudo grep ISC_ $firebird_password_file
0073     break
0074 fi
0075 
0076 if [[ $num_tries -gt 10 ]]; then
0077     echo "Failed to update Firebird password file after $num_tries attempts."
0078     exit 1
0079 fi
0080 
0081 echo "Failed to reconfigure Firebird, retrying in $wait_time seconds..."
0082 sleep $wait_time
0083 ((num_tries++))
0084 
0085 done
0086 
0087 echo
0088 echo "Firebird: restarting"
0089 sudo service $firebird_server_service restart
0090 echo "Firebird: DONE"