forked from mautic/docker-mautic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker-entrypoint.sh
executable file
·72 lines (58 loc) · 2.61 KB
/
docker-entrypoint.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
set -e
if [ -n "$MYSQL_PORT_3306_TCP" ]; then
if [ -z "$MAUTIC_DB_HOST" ]; then
MAUTIC_DB_HOST='mysql'
else
echo >&2 "warning: both MAUTIC_DB_HOST and MYSQL_PORT_3306_TCP found"
echo >&2 " Connecting to MAUTIC_DB_HOST ($MAUTIC_DB_HOST)"
echo >&2 " instead of the linked mysql container"
fi
fi
if [ -z "$MAUTIC_DB_HOST" ]; then
echo >&2 "error: missing MAUTIC_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 MAUTIC_DB_HOST=hostname:port?"
exit 1
fi
# If the DB user is 'root' then use the MySQL root password env var
: ${MAUTIC_DB_USER:=root}
if [ "$MAUTIC_DB_USER" = 'root' ]; then
: ${MAUTIC_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD}
fi
: ${MAUTIC_DB_NAME:=mautic}
if [ -z "$MAUTIC_DB_PASSWORD" ]; then
echo >&2 "error: missing required MAUTIC_DB_PASSWORD environment variable"
echo >&2 " Did you forget to -e MAUTIC_DB_PASSWORD=... ?"
echo >&2
echo >&2 " (Also of interest might be MAUTIC_DB_USER and MAUTIC_DB_NAME.)"
exit 1
fi
if ! [ -e index.php -a -e app/AppKernel.php ]; then
echo >&2 "Mautic not found in $(pwd) - copying now..."
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
tar cf - --one-file-system -C /usr/src/mautic . | tar xf -
echo >&2 "Complete! Mautic has been successfully copied to $(pwd)"
fi
# Ensure the MySQL Database is created
php /makedb.php "$MAUTIC_DB_HOST" "$MAUTIC_DB_USER" "$MAUTIC_DB_PASSWORD" "$MAUTIC_DB_NAME"
echo >&2 "========================================================================"
echo >&2
echo >&2 "This server is now configured to run Mautic!"
echo >&2 "You will need the following database information to install Mautic:"
echo >&2 "Host Name: $MAUTIC_DB_HOST"
echo >&2 "Database Name: $MAUTIC_DB_NAME"
echo >&2 "Database Username: $MAUTIC_DB_USER"
echo >&2 "Database Password: $MAUTIC_DB_PASSWORD"
echo >&2
echo >&2 "========================================================================"
# Write the database connection to the config so the installer prefills it
if ! [ -e app/config/local.php ]; then
php /makeconfig.php "$MAUTIC_DB_HOST" "$MAUTIC_DB_USER" "$MAUTIC_DB_PASSWORD" "$MAUTIC_DB_NAME"
# Make sure our web user owns the config file if it exists
chown www-data:www-data app/config/local.php
fi
exec "$@"