-
Notifications
You must be signed in to change notification settings - Fork 1
/
docker-php-entrypoint
executable file
·49 lines (41 loc) · 1.25 KB
/
docker-php-entrypoint
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
#!/bin/bash
set -e
cd /var/www/html
TIMEOUT=100 wait-for-it.sh $KIMAI_MYSQL_HOSTNAME:3306
echo "Running as $(whoami)"
if [ ! -f ".initialized" ]; then
echo "Setting up Kimai..."
mkdir -p include
cat << EOF > includes/autoconf.php
<?php
\$server_hostname = "${KIMAI_MYSQL_HOSTNAME}";
\$server_database = "${KIMAI_MYSQL_DATABASE}";
\$server_username = "${KIMAI_MYSQL_USERNAME}";
\$server_password = "${KIMAI_MYSQL_PASSWORD}";
\$server_prefix = "kimai_";
\$language = "en";
\$password_salt = "${KIMAI_SALT}";
\$defaultTimezone = "UTC";
\$skin = "standard";
\$authenticator = "kimai";
\$billable = array (
0 => 0,
1 => 50,
2 => 100,
);
EOF
echo "DROP DATABASE $KIMAI_MYSQL_DATABASE; CREATE DATABASE ${KIMAI_MYSQL_DATABASE}" |\
mysql -h $KIMAI_MYSQL_HOSTNAME -u $KIMAI_MYSQL_USERNAME -p$KIMAI_MYSQL_PASSWORD $KIMAI_MYSQL_DATABASE
echo "Importing Kimai fixtures..."
cat /root/kimai_dump.sql |\
mysql -h $KIMAI_MYSQL_HOSTNAME -u $KIMAI_MYSQL_USERNAME -p$KIMAI_MYSQL_PASSWORD $KIMAI_MYSQL_DATABASE
echo "Setting up initial stuff"
php /var/www/html/setup.php
rm -rf installer
touch .initialized
fi
# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
set -- apache2-foreground "$@"
fi
exec "$@"