-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathinstall-distribution-package.sh
executable file
·55 lines (47 loc) · 1.71 KB
/
install-distribution-package.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
#!/bin/bash
# Configure ########################
SYSTEM_ROOT_FOLDER=/home/dserver # No trailing / !
SYSTEM_ROOT_FOLDER_OWNER=dserver
####################################
MEDIAWIKI_CANASTA_ARCHIVE=mediawiki-root-w-folder-1.35.0-3.2.1.tar.gz
MEDIAWIKI_ROOT_FOLDER=$SYSTEM_ROOT_FOLDER/mediawiki_root
APACHE_CONTAINER_NAME=mediawiki_canasta
MYSQL_HOST=127.0.0.1
DATABASE_NAME=mediawiki
MYSQL_USER=mediawiki
MYSQL_USER_PASSWORD=mediawikipass
MYSQL_ROOT_PASSWORD=mysqlpassword
requiredFiles=( "docker-compose.yml" "$MEDIAWIKI_CANASTA_ARCHIVE" )
for file in "${requiredFiles[@]}"
do
if [ ! -e "$file" ]; then
echo "$file is missing!"
exit 1
fi
done
echo "Run docker-compose..."
sudo -S docker-compose down \
&& sudo -S docker-compose up -d \
&& sudo -S chown -R $SYSTEM_ROOT_FOLDER_OWNER:www-data mediawiki_root
sleep 5
echo "Extract..."
mkdir --parents $MEDIAWIKI_ROOT_FOLDER/w
tar -xzf $SYSTEM_ROOT_FOLDER/$MEDIAWIKI_CANASTA_ARCHIVE -C $MEDIAWIKI_ROOT_FOLDER/w
sleep 5
echo "Ensure permissions..."
sudo chown -R www-data $MEDIAWIKI_ROOT_FOLDER/w/images
sleep 5
echo "Create database and user..."
sudo -S docker exec $APACHE_CONTAINER_NAME bash -c \
"mysql -h $MYSQL_HOST -u root -p$MYSQL_ROOT_PASSWORD \
-e \" CREATE DATABASE $DATABASE_NAME;
CREATE USER '$MYSQL_USER'@'$MYSQL_HOST' IDENTIFIED BY '$MYSQL_USER_PASSWORD';
GRANT ALL PRIVILEGES ON $DATABASE_NAME.* TO '$MYSQL_USER'@'$MYSQL_HOST'; \""
echo "Import database..."
sudo -S docker exec $APACHE_CONTAINER_NAME bash -c \
"mysql -h $MYSQL_HOST -u root -p$MYSQL_ROOT_PASSWORD \
mediawiki < /var/www/html/w/db.sql"
echo "Update..."
sudo -S docker exec $APACHE_CONTAINER_NAME /bin/bash -c \
'cd w; php maintenance/update.php'
echo "http://localhost:80"