Просмотр исходного кода

Fixes: #5142, closes: #5143 - contrib/packager.io/preinstall.sh does not check the db adapter setting and fails if both psql and mysql are installed

Make sure the correct database is used depending on the adapter setting


(cherry picked from commit 506c295c1d15f8dc19fc8bb69af1fb721bf10f49)
jr-timme 10 месяцев назад
Родитель
Сommit
6baf144b23
1 измененных файлов с 3 добавлено и 2 удалено
  1. 3 2
      contrib/packager.io/preinstall.sh

+ 3 - 2
contrib/packager.io/preinstall.sh

@@ -18,6 +18,7 @@ if [[ -f /opt/zammad/config/database.yml ]]; then
    DB_USER="$(grep -m 1 '^[[:space:]]*username:' < /opt/zammad/config/database.yml | sed -e 's/.*username:[[:space:]]*//g')"
    DB_PASS="$(grep -m 1 '^[[:space:]]*password:' < /opt/zammad/config/database.yml | sed -e 's/.*password:[[:space:]]*//g')"
    DB_SOCKET="$(grep -m 1 '^[[:space:]]*socket:' < /opt/zammad/config/database.yml | sed -e 's/.*socket:[[:space:]]*//g')"
+   DB_ADAPTER="$(grep -m 1 '^[[:space:]]*adapter:' < /opt/zammad/config/database.yml | sed -e 's/.*adapter:[[:space:]]*//g')"
 else
    # Skip this whole script if we can't find our database file
    echo "Warning: Could not find database.yml"
@@ -27,7 +28,7 @@ fi
 if [ "${DB_HOST}x" == "x" ]; then
    DB_HOST="localhost"
 fi
-if [ -n "$(which psql 2> /dev/null)" ]; then
+if [ -n "$(which psql 2> /dev/null)" ] && [ "${DB_ADAPTER}" == 'postgresql' ]; then
    if [ "${DB_PORT}x" == "x" ]; then
       DB_PORT="5432"
    fi
@@ -38,7 +39,7 @@ if [ -n "$(which psql 2> /dev/null)" ]; then
       pg_isready -q
       state=$?
    fi
-elif [ -n "$(which mysql 2> /dev/null)" ]; then
+elif [ -n "$(which mysql 2> /dev/null)" ] && [ "${DB_ADAPTER}" == 'mysql2' ]; then
    if [ "${DB_PORT}x" == "x" ]; then
       DB_PORT="3306"
    fi