2015-07-25 18:42:58 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2022-01-18 16:02:00 +00:00
|
|
|
if [ -n "$JOOMLA_DB_PASSWORD_FILE" ] && [ -f "$JOOMLA_DB_PASSWORD_FILE" ]; then
|
2020-08-11 18:13:41 +00:00
|
|
|
JOOMLA_DB_PASSWORD=$(cat "$JOOMLA_DB_PASSWORD_FILE")
|
|
|
|
fi
|
|
|
|
|
2016-01-07 19:53:58 +00:00
|
|
|
if [[ "$1" == apache2* ]] || [ "$1" == php-fpm ]; then
|
2015-08-04 18:07:29 +00:00
|
|
|
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
|
|
|
|
if [ -z "$JOOMLA_DB_HOST" ]; then
|
|
|
|
JOOMLA_DB_HOST='mysql'
|
|
|
|
else
|
|
|
|
echo >&2 "warning: both JOOMLA_DB_HOST and MYSQL_PORT_3306_TCP found"
|
|
|
|
echo >&2 " Connecting to JOOMLA_DB_HOST ($JOOMLA_DB_HOST)"
|
|
|
|
echo >&2 " instead of the linked mysql container"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-07-25 18:42:58 +00:00
|
|
|
if [ -z "$JOOMLA_DB_HOST" ]; then
|
2015-08-04 18:07:29 +00:00
|
|
|
echo >&2 "error: missing JOOMLA_DB_HOST and MYSQL_PORT_3306_TCP environment variables"
|
|
|
|
echo >&2 " Did you forget to --link some_mysql_container:mysql or set an external db"
|
|
|
|
echo >&2 " with -e JOOMLA_DB_HOST=hostname:port?"
|
|
|
|
exit 1
|
2015-07-25 18:42:58 +00:00
|
|
|
fi
|
|
|
|
|
2015-08-04 18:07:29 +00:00
|
|
|
# If the DB user is 'root' then use the MySQL root password env var
|
|
|
|
: ${JOOMLA_DB_USER:=root}
|
2017-08-23 22:29:34 +00:00
|
|
|
if [ "$JOOMLA_DB_USER" = 'root' ]; then
|
2015-08-04 18:07:29 +00:00
|
|
|
: ${JOOMLA_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
|
|
|
|
fi
|
|
|
|
: ${JOOMLA_DB_NAME:=joomla}
|
2015-07-25 18:42:58 +00:00
|
|
|
|
2017-08-23 21:48:48 +00:00
|
|
|
if [ -z "$JOOMLA_DB_PASSWORD" ] && [ "$JOOMLA_DB_PASSWORD_ALLOW_EMPTY" != 'yes' ]; then
|
2015-08-04 18:07:29 +00:00
|
|
|
echo >&2 "error: missing required JOOMLA_DB_PASSWORD environment variable"
|
|
|
|
echo >&2 " Did you forget to -e JOOMLA_DB_PASSWORD=... ?"
|
|
|
|
echo >&2
|
|
|
|
echo >&2 " (Also of interest might be JOOMLA_DB_USER and JOOMLA_DB_NAME.)"
|
|
|
|
exit 1
|
|
|
|
fi
|
2015-07-25 18:42:58 +00:00
|
|
|
|
2017-10-28 13:22:02 +00:00
|
|
|
if ! [ -e index.php -a \( -e libraries/cms/version/version.php -o -e libraries/src/Version.php \) ]; then
|
2015-08-04 18:07:29 +00:00
|
|
|
echo >&2 "Joomla not found in $(pwd) - copying now..."
|
2015-07-25 18:42:58 +00:00
|
|
|
|
2015-08-04 18:07:29 +00:00
|
|
|
if [ "$(ls -A)" ]; then
|
|
|
|
echo >&2 "WARNING: $(pwd) is not empty - press Ctrl+C now if this is an error!"
|
|
|
|
( set -x; ls -A; sleep 10 )
|
|
|
|
fi
|
2015-07-25 18:42:58 +00:00
|
|
|
|
2015-08-04 18:07:29 +00:00
|
|
|
tar cf - --one-file-system -C /usr/src/joomla . | tar xf -
|
2015-07-25 18:42:58 +00:00
|
|
|
|
2015-08-04 18:07:29 +00:00
|
|
|
if [ ! -e .htaccess ]; then
|
|
|
|
# NOTE: The "Indexes" option is disabled in the php:apache base image so remove it as we enable .htaccess
|
|
|
|
sed -r 's/^(Options -Indexes.*)$/#\1/' htaccess.txt > .htaccess
|
|
|
|
chown www-data:www-data .htaccess
|
|
|
|
fi
|
2015-07-25 20:13:54 +00:00
|
|
|
|
2015-08-04 18:07:29 +00:00
|
|
|
echo >&2 "Complete! Joomla has been successfully copied to $(pwd)"
|
2015-07-25 20:13:54 +00:00
|
|
|
fi
|
|
|
|
|
2015-08-04 18:07:29 +00:00
|
|
|
# Ensure the MySQL Database is created
|
|
|
|
php /makedb.php "$JOOMLA_DB_HOST" "$JOOMLA_DB_USER" "$JOOMLA_DB_PASSWORD" "$JOOMLA_DB_NAME"
|
2015-07-25 18:42:58 +00:00
|
|
|
|
2015-08-04 18:07:29 +00:00
|
|
|
echo >&2 "========================================================================"
|
|
|
|
echo >&2
|
|
|
|
echo >&2 "This server is now configured to run Joomla!"
|
2018-08-07 00:30:38 +00:00
|
|
|
echo >&2
|
|
|
|
echo >&2 "NOTE: You will need your database server address, database name,"
|
|
|
|
echo >&2 "and database user credentials to install Joomla."
|
2015-08-04 18:07:29 +00:00
|
|
|
echo >&2
|
|
|
|
echo >&2 "========================================================================"
|
|
|
|
fi
|
2015-07-25 18:42:58 +00:00
|
|
|
|
|
|
|
exec "$@"
|