Skip to content

Commit

Permalink
Fixes: #5142, closes: #5143 - contrib/packager.io/preinstall.sh does …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
jr-timme authored and mgruner committed May 8, 2024
1 parent 199f617 commit 506c295
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions contrib/packager.io/preinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 506c295

Please sign in to comment.