-
Notifications
You must be signed in to change notification settings - Fork 0
/
entrypoint.sh
executable file
·72 lines (57 loc) · 2.58 KB
/
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
# This file is provided by the wikibase/wikibase docker image.
if [[ "${DB_SERVER:-}" ]]; then
# Wait for the db to come up
/wait-for-it.sh $DB_SERVER -t 300
# Sometimes it appears to come up and then go back down meaning MW install fails
# So wait for a second and double check!
sleep 1
/wait-for-it.sh $DB_SERVER -t 300
fi
# Run extra scripts everytime
if [ -f /extra-entrypoint-run-first.sh ]; then
source /extra-entrypoint-run-first.sh
fi
# Copy LocalSettings from share if exists
if [ -e "/shared/LocalSettings.php" ]; then
cp /shared/LocalSettings.php /var/www/html/LocalSettings.php
fi
# Do the mediawiki install (only if LocalSettings doesn't already exist)
if [ ! -e "/var/www/html/LocalSettings.php" ]; then
# Test if required environment variables have been set
REQUIRED_VARIABLES=(MW_ADMIN_NAME MW_ADMIN_PASS MW_ADMIN_EMAIL MW_WG_SECRET_KEY DB_SERVER DB_USER DB_PASS DB_NAME)
for i in ${REQUIRED_VARIABLES[@]}; do
eval THISSHOULDBESET=\$$i
if [ -z "$THISSHOULDBESET" ]; then
echo "$i is required but isn't set. You should pass it to docker. See: https://docs.docker.com/engine/reference/commandline/run/#set-environment-variables--e---env---env-file";
exit 1;
fi
done
set -eu
php /var/www/html/maintenance/install.php --dbuser "$DB_USER" --dbpass "$DB_PASS" --dbname "$DB_NAME" --dbserver "$DB_SERVER" --lang "$MW_SITE_LANG" --pass "$MW_ADMIN_PASS" "$MW_SITE_NAME" "$MW_ADMIN_NAME"
# Copy our LocalSettings into place after install from the template
# https://stackoverflow.com/a/24964089/4746236
export DOLLAR='$'
envsubst < /LocalSettings.php.template > /var/www/html/LocalSettings.php
# Copy LocalSettings to shared location
cp /var/www/html/LocalSettings.php /shared/LocalSettings.php
# Run update.php to install Wikibase
php /var/www/html/maintenance/update.php --quick
php /var/www/html/maintenance/resetUserEmail.php --no-reset-password "$MW_ADMIN_NAME" "$MW_ADMIN_EMAIL"
# Run extrascripts on first run
if [ -f /extra-install.sh ]; then
source /extra-install.sh
fi
fi
# Copy LocalSettings to shared location
if [ ! -e "/shared/LocalSettings.php" ]; then
cp /var/www/html/LocalSettings.php /shared/LocalSettings.php
fi
if [[ "${BOTUSER_NAME:-}" ]]; then
php /var/www/html/maintenance/createAndPromote.php $BOTUSER_NAME $BOTUSER_PW --bot
fi
# Starting the cron-service for regular_maintenance
/etc/init.d/cron start
# Run the actual entry point
(cd /var/www/html/extensions/VisualEditor/lib/ve/rebaser;npm start) &
docker-php-entrypoint apache2-foreground