forked from wikimedia/mediawiki-containers
-
Notifications
You must be signed in to change notification settings - Fork 2
/
mediawiki-containers
executable file
·172 lines (149 loc) · 4.44 KB
/
mediawiki-containers
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/bash
set -e
# Simple shell script to start up MediaWiki + containers.
# Alternative to docker-compose, with automatic docker subnet detection to make
# this work on jessie or sid.
BASEDIR=/srv/mediawiki-containers
DATADIR="$BASEDIR/data"
if [ -d $BASEDIR -a -f $BASEDIR/config ]; then
source $BASEDIR/config
fi
# Set up defaults
if [ -z "$MEDIAWIKI_DOMAIN" ]; then
# Ewww..
MEDIAWIKI_DOMAIN="localhost"
fi
start () {
echo
echo "Starting DNS container.."
docker pull tonistiigi/dnsdock
docker run -d \
--name=dnsdock \
-v /var/run/docker.sock:/run/docker.sock \
tonistiigi/dnsdock
DNS=$(docker inspect --format '{{ .NetworkSettings.IPAddress }}' dnsdock)
echo
echo "Starting mysql(mariadb) container.."
docker pull mariadb
docker run -d \
--name=mysql \
-e SERVICE_NAME=mysql \
-v $DATADIR/mediawiki-mysql:/var/lib/mysql:rw \
-e MYSQL_ROOT_PASSWORD=password \
--dns "$DNS" \
mariadb
echo
echo "Starting mediawiki container.."
docker pull wikimedia/mediawiki
docker run -d \
--name=mediawiki \
-v `pwd`/conf/mediawiki:/conf:ro \
-v $DATADIR/mediawiki-core:/data:rw \
-e MEDIAWIKI_SITE_SERVER="//$MEDIAWIKI_DOMAIN" \
-e MEDIAWIKI_SITE_NAME=MediaWiki \
-e MEDIAWIKI_SITE_LANG=en \
-e MEDIAWIKI_ADMIN_USER=admin \
-e MEDIAWIKI_ADMIN_PASS=rosebud \
-e MEDIAWIKI_UPDATE=true \
-e MEDIAWIKI_DB_USER=root \
-e MEDIAWIKI_DB_HOST=mysql.docker \
-e MEDIAWIKI_DB_PASSWORD=password \
-e MEDIAWIKI_RESTBASE_URL=http://mediawiki-node-services.docker:7231/localhost/v1 \
--dns "$DNS" \
-p 80:80 \
wikimedia/mediawiki
echo
echo "Starting mediawiki-node-services container.."
docker pull wikimedia/mediawiki-node-services
docker run -d \
--name=mediawiki-node-services \
-v $DATADIR/node-services:/data \
-e MEDIAWIKI_API_URL=http://mediawiki.docker/api.php \
--dns "$DNS" \
-p 8142:8142 \
wikimedia/mediawiki-node-services
# Follow the mediawiki container logs
#set -o pipefail
docker logs -f mediawiki
}
stop () {
echo "Stopping and deleting all containers.."
# The containers themselves are stateless (all data is stored in
# /var/lib/mediawiki-containers), so always nuke them.
docker rm -f mediawiki 2>/dev/null || true
docker rm -f mediawiki-node-services 2>/dev/null || true
docker rm -f mysql 2>/dev/null || true
docker rm -f dnsdock 2>/dev/null || true
}
install_git() {
if ! hash git 2>/dev/null;then
echo "Installing git.."
apt-get install -y git
else
echo "[OK] Found git."
fi
}
check_out_mediawiki_containers() {
if [ ! -d "$BASEDIR" ];then
echo "Cloning mediawiki-containers to $BASEDIR.."
git clone https://github.com/wikimedia/mediawiki-containers.git "$BASEDIR"
else
cd "$BASEDIR"
echo "Updating $BASEDIR.."
git pull
fi
cd "$BASEDIR"
}
usage() {
echo "Usage: $0 [start|stop|restart|install]"
}
install() {
while true; do
read -p "Proceed to install / update mediawiki-containers? (y/n): " \
yn </dev/tty
case $yn in
[Yy]* ) break;;
[Nn]* ) echo "Okay, aborting."; exit 1;;
* ) echo "Please answer 'y' or 'n'.";;
esac
done
# User answered 'y'; proceed to install.
# Make sure we have git.
install_git
# Clone / update the mediawiki-containers repository.
check_out_mediawiki_containers
cd $BASEDIR
source ./lib/install.sh
do_install
echo
service mediawiki-containers restart
echo
echo "Your wiki should soon be available at http://$MEDIAWIKI_DOMAIN/."
echo
echo 'To follow the startup progress, run'
echo ' - `docker logs -f mediawiki` for MediaWiki,'
echo ' - `docker logs -f mysql` for MySQL,'
echo ' - `docker logs -f mediawiki-node-services` for services.'
echo
echo 'Following startup via `journalctl -f`.'
journalctl -f | sed '/: AH00558: apache2: /q'
}
if [ "$1" == "stop" ]; then
stop
exit 0
elif [ "$1" == "start" ]; then
start
elif [ "$1" == "restart" ]; then
stop
start
exit 0
elif [ -z "$1" -o "$1" == "install" ]; then
echo "Welcome to MediaWiki-containers!"
echo
install
exit 0
else
echo "Invalid parameter $1"
usage
exit 1
fi