|
|
@ -1,7 +1,10 @@
|
|
|
|
#!/bin/bash
|
|
|
|
#!/bin/bash
|
|
|
|
set -ex
|
|
|
|
set -ex
|
|
|
|
|
|
|
|
|
|
|
|
POSTFIXADMIN_DB_TYPE=sqlite
|
|
|
|
POSTFIXADMIN_DB_TYPE=${POSTFIXADMIN_DB_TYPE:=sqlite}
|
|
|
|
|
|
|
|
POSTFIXADMIN_DB_HOST=${POSTFIXADMIN_DB_HOST:=""}
|
|
|
|
|
|
|
|
POSTFIXADMIN_DB_USER=${POSTFIXADMIN_DB_USER:=""}
|
|
|
|
|
|
|
|
POSTFIXADMIN_DB_PASSWORD=${POSTFIXADMIN_DB_PASSWORD:=""}
|
|
|
|
|
|
|
|
|
|
|
|
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
|
|
|
|
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
|
|
|
|
if ! [ -e index.php -a -e scripts/postfixadmin-cli.php ]; then
|
|
|
|
if ! [ -e index.php -a -e scripts/postfixadmin-cli.php ]; then
|
|
|
@ -14,24 +17,27 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
|
|
|
|
echo >&2 "Complete! Postfixadmin has been successfully copied to $PWD"
|
|
|
|
echo >&2 "Complete! Postfixadmin has been successfully copied to $PWD"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ -n "${!POSTGRES_ENV_POSTGRES_*}" ]; then
|
|
|
|
case "${POSTFIXADMIN_DB_TYPE}" in
|
|
|
|
: "${POSTFIXADMIN_DB_TYPE:=pgsql}"
|
|
|
|
sqlite)
|
|
|
|
: "${POSTFIXADMIN_DB_HOST:=postgres}"
|
|
|
|
;;
|
|
|
|
: "${POSTFIXADMIN_DB_USER:=${POSTGRES_ENV_POSTGRES_USER}}"
|
|
|
|
mysqli)
|
|
|
|
: "${POSTFIXADMIN_DB_PASSWORD:=${POSTGRES_ENV_POSTGRES_PASSWORD:-}}"
|
|
|
|
: "${POSTFIXADMIN_DB_PORT:=3306}"
|
|
|
|
: "${POSTFIXADMIN_DB_NAME:=${POSTGRES_ENV_POSTGRES_DB:-}}"
|
|
|
|
;;
|
|
|
|
fi
|
|
|
|
pgsql)
|
|
|
|
|
|
|
|
: "${POSTFIXADMIN_DB_PORT:=5432}"
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
|
|
|
|
|
|
|
echo >&2 "${POSTFIXADMIN_DB_TYPE} is not a supported value."
|
|
|
|
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|
|
|
|
|
|
|
|
|
|
|
|
if [ -n "${!MYSQL_ENV_MYSQL_*}" ]; then
|
|
|
|
if [ "${POSTFIXADMIN_DB_TYPE}" != "sqlite" ]; then
|
|
|
|
: "${POSTFIXADMIN_DB_TYPE:=mysqli}"
|
|
|
|
if [ -z "${POSTFIXADMIN_DB_USER}" -o -z "${POSTFIXADMIN_DB_PASSWORD}" ]; then
|
|
|
|
: "${POSTFIXADMIN_DB_HOST:=mysql}"
|
|
|
|
echo >&2 'Error: POSTFIXADMIN_DB_USER and POSTFIXADMIN_DB_PASSWORD must be specified. '
|
|
|
|
: "${POSTFIXADMIN_DB_USER:=${MYSQL_ENV_MYSQL_USER:-root}}"
|
|
|
|
exit 1
|
|
|
|
if [ "$POSTFIXADMIN_DB_USER" = 'root' ]; then
|
|
|
|
|
|
|
|
: "${POSTFIXADMIN_DB_PASSWORD:=${MYSQL_ENV_MYSQL_ROOT_PASSWORD}}"
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
: "${POSTFIXADMIN_DB_PASSWORD:=${MYSQL_ENV_MYSQL_PASSWORD}}"
|
|
|
|
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
: "${POSTFIXADMIN_DB_NAME:=${MYSQL_ENV_MYSQL_DATABASE:postfix}}"
|
|
|
|
timeout 15 bash -c "until echo > /dev/tcp/${POSTFIXADMIN_HOST}/${POSTFIXADMIN_DB_PORT}; do sleep 0.5; done"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$POSTFIXADMIN_DB_TYPE" = 'sqlite' ]; then
|
|
|
|
if [ "$POSTFIXADMIN_DB_TYPE" = 'sqlite' ]; then
|
|
|
@ -51,9 +57,7 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
|
|
|
|
\$CONF['database_user'] = '${POSTFIXADMIN_DB_USER}';
|
|
|
|
\$CONF['database_user'] = '${POSTFIXADMIN_DB_USER}';
|
|
|
|
\$CONF['database_password'] = '${POSTFIXADMIN_DB_PASSWORD}';
|
|
|
|
\$CONF['database_password'] = '${POSTFIXADMIN_DB_PASSWORD}';
|
|
|
|
\$CONF['database_name'] = '${POSTFIXADMIN_DB_NAME}';
|
|
|
|
\$CONF['database_name'] = '${POSTFIXADMIN_DB_NAME}';
|
|
|
|
|
|
|
|
|
|
|
|
\$CONF['setup_password'] = '${POSTFIXADMIN_SETUP_PASSWORD}';
|
|
|
|
\$CONF['setup_password'] = '${POSTFIXADMIN_SETUP_PASSWORD}';
|
|
|
|
|
|
|
|
|
|
|
|
\$CONF['configured'] = true;
|
|
|
|
\$CONF['configured'] = true;
|
|
|
|
?>" | tee config.local.php
|
|
|
|
?>" | tee config.local.php
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -61,9 +65,9 @@ if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
|
|
|
|
echo "Postfixadmin related environment variables have been ignored."
|
|
|
|
echo "Postfixadmin related environment variables have been ignored."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ -f setup.php ]; then
|
|
|
|
if [ -f upgrade.php ]; then
|
|
|
|
echo " ** Running database / environment setup.php "
|
|
|
|
echo " ** Running database / environment upgrade.php "
|
|
|
|
php setup.php
|
|
|
|
php upgrade.php
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|