From 82e652db48e972da71e28d83aaeb78594667853d Mon Sep 17 00:00:00 2001 From: Sean Wilson Date: Sun, 14 Feb 2016 21:03:43 +0000 Subject: [PATCH 1/3] Add arm port of the mediawiki Docker image --- arm7fh-1.24/Dockerfile | 50 ++++++++++++++++++ arm7fh-1.24/README.md | 39 ++++++++++++++ arm7fh-1.24/apache/mediawiki.conf | 19 +++++++ arm7fh-1.24/docker-entrypoint.sh | 85 +++++++++++++++++++++++++++++++ 4 files changed, 193 insertions(+) create mode 100644 arm7fh-1.24/Dockerfile create mode 100644 arm7fh-1.24/README.md create mode 100644 arm7fh-1.24/apache/mediawiki.conf create mode 100755 arm7fh-1.24/docker-entrypoint.sh diff --git a/arm7fh-1.24/Dockerfile b/arm7fh-1.24/Dockerfile new file mode 100644 index 0000000..e0a319d --- /dev/null +++ b/arm7fh-1.24/Dockerfile @@ -0,0 +1,50 @@ +FROM armhf/php:5.6-apache +MAINTAINER Synctree App Force + +ENV MEDIAWIKI_VERSION 1.24 +ENV MEDIAWIKI_FULL_VERSION 1.24.2 + +RUN set -x; \ + apt-get update \ + && apt-get install -y --no-install-recommends \ + g++ \ + libicu52 \ + libicu-dev \ + && pecl install intl \ + && echo extension=intl.so >> /usr/local/etc/php/conf.d/ext-intl.ini \ + && apt-get purge -y --auto-remove g++ libicu-dev \ + && rm -rf /var/lib/apt/lists/* + +RUN docker-php-ext-install mysqli opcache + +RUN set -x; \ + apt-get update \ + && apt-get install -y --no-install-recommends imagemagick \ + && rm -rf /var/lib/apt/lists/* + +RUN a2enmod rewrite + +# https://www.mediawiki.org/keys/keys.txt +RUN gpg --keyserver pool.sks-keyservers.net --recv-keys \ + 441276E9CCD15F44F6D97D18C119E1A64D70938E \ + 41B2ABE817ADD3E52BDA946F72BC1C5D23107F8A \ + 162432D9E81C1C618B301EECEE1F663462D84F01 \ + 1D98867E82982C8FE0ABC25F9B69B3109D3BB7B0 \ + 3CEF8262806D3F0B6BA1DBDD7956EE477F901A30 \ + 280DB7845A1DCAC92BB5A00A946B02565DC00AA7 + +RUN MEDIAWIKI_DOWNLOAD_URL="https://releases.wikimedia.org/mediawiki/$MEDIAWIKI_VERSION/mediawiki-$MEDIAWIKI_FULL_VERSION.tar.gz"; \ + set -x; \ + mkdir -p /usr/src/mediawiki \ + && curl -fSL "$MEDIAWIKI_DOWNLOAD_URL" -o mediawiki.tar.gz \ + && curl -fSL "${MEDIAWIKI_DOWNLOAD_URL}.sig" -o mediawiki.tar.gz.sig \ + && gpg --verify mediawiki.tar.gz.sig \ + && tar -xf mediawiki.tar.gz -C /usr/src/mediawiki --strip-components=1 + + +COPY apache/mediawiki.conf /etc/apache2/ +RUN echo Include /etc/apache2/mediawiki.conf >> /etc/apache2/apache2.conf + +COPY docker-entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] +CMD ["apache2-foreground"] diff --git a/arm7fh-1.24/README.md b/arm7fh-1.24/README.md new file mode 100644 index 0000000..442d917 --- /dev/null +++ b/arm7fh-1.24/README.md @@ -0,0 +1,39 @@ +# What is MediaWiki? + +MediaWiki is a free and open-source wiki app, used to power wiki websites such +as Wikipedia, Wiktionary and Commons, developed by the Wikimedia Foundation and +others. + +> [wikipedia.org/wiki/MediaWiki](https://en.wikipedia.org/wiki/MediaWiki) + +# How to use this image + + docker run --name some-mediawiki --link some-mysql:mysql -d synctree/mediawiki + +The following environment variables are also honored for configuring your +MediaWiki instance: + + - `-e MEDIAWIKI_DB_HOST=ADDR:PORT` (defaults to the address and port of the + linked mysql container) + - `-e MEDIAWIKI_DB_USER=...` (defaults to "root") + - `-e MEDIAWIKI_DB_PASSWORD=...` (defaults to the value of the + `MYSQL_ROOT_PASSWORD` environment variable from the linked mysql container) + - `-e MEDIAWIKI_DB_NAME=...` (defaults to "mediawiki") + +If the `MEDIAWIKI_DB_NAME` specified does not already exist in the given MySQL +container, it will be created automatically upon container startup, provided +that the `MEDIAWIKI_DB_USER` specified has the necessary permissions to create +it. + +To use with an external database server, use `MEDIAWIKI_DB_HOST` (along with +`MEDIAWIKI_DB_USER` and `MEDIAWIKI_DB_PASSWORD` if necessary): + + docker run --name some-mediawiki -e MEDIAWIKI_DB_HOST=10.0.0.1:3306 \ + -e MEDIAWIKI_DB_USER=app -e MEDIAWIKI_DB_PASSWORD=secure synctree/mediawiki + +If you'd like to be able to access the instance from the host without the +container's IP, standard port mappings can be used: + + docker run --name some-mediawiki --link some-mysql:mysql -p 8080:80 -d synctree/mediawiki + +Then, access it via `http://localhost:8080` or `http://host-ip:8080` in a browser. diff --git a/arm7fh-1.24/apache/mediawiki.conf b/arm7fh-1.24/apache/mediawiki.conf new file mode 100644 index 0000000..f1b0450 --- /dev/null +++ b/arm7fh-1.24/apache/mediawiki.conf @@ -0,0 +1,19 @@ + + RewriteEngine On + RewriteBase / + RewriteRule ^index\.php$ - [L] + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule . /index.php [L] + + + + # Ignore .htaccess files + AllowOverride None + + # Serve HTML as plaintext, don't execute SHTML + AddType text/plain .html .htm .shtml .php + + # Don't run arbitrary PHP code. + php_admin_flag engine off + diff --git a/arm7fh-1.24/docker-entrypoint.sh b/arm7fh-1.24/docker-entrypoint.sh new file mode 100755 index 0000000..8ecc754 --- /dev/null +++ b/arm7fh-1.24/docker-entrypoint.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +set -e + +: ${MEDIAWIKI_SITE_NAME:=MediaWiki} + +if [ -z "$MEDIAWIKI_DB_HOST" -a -z "$MYSQL_PORT_3306_TCP" ]; then + echo >&2 'error: missing MYSQL_PORT_3306_TCP environment variable' + echo >&2 ' Did you forget to --link some_mysql_container:mysql ?' + exit 1 +fi + +# if we're linked to MySQL, and we're using the root user, and our linked +# container has a default "root" password set up and passed through... :) +: ${MEDIAWIKI_DB_USER:=root} +if [ "$MEDIAWIKI_DB_USER" = 'root' ]; then + : ${MEDIAWIKI_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD} +fi +: ${MEDIAWIKI_DB_NAME:=mediawiki} + +if [ -z "$MEDIAWIKI_DB_PASSWORD" ]; then + echo >&2 'error: missing required MEDIAWIKI_DB_PASSWORD environment variable' + echo >&2 ' Did you forget to -e MEDIAWIKI_DB_PASSWORD=... ?' + echo >&2 + echo >&2 ' (Also of interest might be MEDIAWIKI_DB_USER and MEDIAWIKI_DB_NAME.)' + exit 1 +fi + +if ! [ -e index.php -a -e includes/DefaultSettings.php ]; then + echo >&2 "MediaWiki 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/mediawiki . | tar xf - + echo >&2 "Complete! MediaWiki has been successfully copied to $(pwd)" +fi + +: ${MEDIAWIKI_SHARED:=/var/www-shared/html} +if [ -d "$MEDIAWIKI_SHARED" ]; then + # If there is no LocalSettings.php but we have one under the shared + # directory, symlink it + if [ -e "$MEDIAWIKI_SHARED/LocalSettings.php" -a ! -e LocalSettings.php ]; then + ln -s "$MEDIAWIKI_SHARED/LocalSettings.php" LocalSettings.php + echo >&2 "no LocalSettings.php but one in shared." + fi + + # If the images directory only contains a README, then link it to + # $MEDIAWIKI_SHARED/images, creating the shared directory if necessary + if [ "$(ls images)" = "README" -a ! -L images ]; then + rm -fr images + mkdir -p "$MEDIAWIKI_SHARED/images" + ln -s "$MEDIAWIKI_SHARED/images" images + fi +fi + +: ${MEDIAWIKI_DB_HOST:=${MYSQL_PORT_3306_TCP#tcp://}} + +TERM=dumb php -- "$MEDIAWIKI_DB_HOST" "$MEDIAWIKI_DB_USER" "$MEDIAWIKI_DB_PASSWORD" "$MEDIAWIKI_DB_NAME" <<'EOPHP' +connect_error) { + file_put_contents('php://stderr', 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n"); + exit(1); +} + +if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($argv[4]) . '`')) { + file_put_contents('php://stderr', 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n"); + $mysql->close(); + exit(1); +} + +$mysql->close(); +EOPHP + +chown -R www-data: . + +export MEDIAWIKI_SITE_NAME MEDIAWIKI_DB_HOST MEDIAWIKI_DB_USER MEDIAWIKI_DB_PASSWORD MEDIAWIKI_DB_NAME + +exec "$@" From 6c61540edb76fb0c8280b0c2d9aea0d06df2b002 Mon Sep 17 00:00:00 2001 From: Sean Wilson Date: Sat, 27 Feb 2016 17:29:01 +0000 Subject: [PATCH 2/3] Rename the arm to the correct 'hf', also touch up README --- {arm7fh-1.24 => arm7hf-1.24}/Dockerfile | 0 {arm7fh-1.24 => arm7hf-1.24}/README.md | 11 ++++++++--- {arm7fh-1.24 => arm7hf-1.24}/apache/mediawiki.conf | 0 {arm7fh-1.24 => arm7hf-1.24}/docker-entrypoint.sh | 1 - 4 files changed, 8 insertions(+), 4 deletions(-) rename {arm7fh-1.24 => arm7hf-1.24}/Dockerfile (100%) rename {arm7fh-1.24 => arm7hf-1.24}/README.md (81%) rename {arm7fh-1.24 => arm7hf-1.24}/apache/mediawiki.conf (100%) rename {arm7fh-1.24 => arm7hf-1.24}/docker-entrypoint.sh (98%) diff --git a/arm7fh-1.24/Dockerfile b/arm7hf-1.24/Dockerfile similarity index 100% rename from arm7fh-1.24/Dockerfile rename to arm7hf-1.24/Dockerfile diff --git a/arm7fh-1.24/README.md b/arm7hf-1.24/README.md similarity index 81% rename from arm7fh-1.24/README.md rename to arm7hf-1.24/README.md index 442d917..71e1b84 100644 --- a/arm7fh-1.24/README.md +++ b/arm7hf-1.24/README.md @@ -8,7 +8,7 @@ others. # How to use this image - docker run --name some-mediawiki --link some-mysql:mysql -d synctree/mediawiki + docker run --name some-mediawiki --link some-mysql:mysql -d spwilson2/mediawiki The following environment variables are also honored for configuring your MediaWiki instance: @@ -29,11 +29,16 @@ To use with an external database server, use `MEDIAWIKI_DB_HOST` (along with `MEDIAWIKI_DB_USER` and `MEDIAWIKI_DB_PASSWORD` if necessary): docker run --name some-mediawiki -e MEDIAWIKI_DB_HOST=10.0.0.1:3306 \ - -e MEDIAWIKI_DB_USER=app -e MEDIAWIKI_DB_PASSWORD=secure synctree/mediawiki + -e MEDIAWIKI_DB_USER=app -e MEDIAWIKI_DB_PASSWORD=secure spwilson2/rpi-mediawiki If you'd like to be able to access the instance from the host without the container's IP, standard port mappings can be used: - docker run --name some-mediawiki --link some-mysql:mysql -p 8080:80 -d synctree/mediawiki + docker run --name some-mediawiki --link some-mysql:mysql -p 8080:80 -d spwilson2/rpi-mediawiki Then, access it via `http://localhost:8080` or `http://host-ip:8080` in a browser. + +Once you have set up your media wiki, you'll need to add the LocalSettings.php file output to +the docker container. + + docker run --name some-mediawiki -v /path/on-docker-host/to/LocalSettings.php:/var/www-shared/html/LocalSettings.php --link some-mysql:mysql -d spwilson2/rpi-mediawiki diff --git a/arm7fh-1.24/apache/mediawiki.conf b/arm7hf-1.24/apache/mediawiki.conf similarity index 100% rename from arm7fh-1.24/apache/mediawiki.conf rename to arm7hf-1.24/apache/mediawiki.conf diff --git a/arm7fh-1.24/docker-entrypoint.sh b/arm7hf-1.24/docker-entrypoint.sh similarity index 98% rename from arm7fh-1.24/docker-entrypoint.sh rename to arm7hf-1.24/docker-entrypoint.sh index 8ecc754..988162c 100755 --- a/arm7fh-1.24/docker-entrypoint.sh +++ b/arm7hf-1.24/docker-entrypoint.sh @@ -43,7 +43,6 @@ if [ -d "$MEDIAWIKI_SHARED" ]; then # directory, symlink it if [ -e "$MEDIAWIKI_SHARED/LocalSettings.php" -a ! -e LocalSettings.php ]; then ln -s "$MEDIAWIKI_SHARED/LocalSettings.php" LocalSettings.php - echo >&2 "no LocalSettings.php but one in shared." fi # If the images directory only contains a README, then link it to From b20527da2994148f4821a423e9cfb3df170d8d21 Mon Sep 17 00:00:00 2001 From: Sean Wilson Date: Thu, 3 Mar 2016 13:29:21 -0600 Subject: [PATCH 3/3] Starting work on upgraded mediawiki --- arm7hf-1.26/Dockerfile | 57 ++++++++++++++++++++ arm7hf-1.26/README.md | 44 ++++++++++++++++ arm7hf-1.26/apache/mediawiki.conf | 19 +++++++ arm7hf-1.26/docker-entrypoint.sh | 88 +++++++++++++++++++++++++++++++ 4 files changed, 208 insertions(+) create mode 100644 arm7hf-1.26/Dockerfile create mode 100644 arm7hf-1.26/README.md create mode 100644 arm7hf-1.26/apache/mediawiki.conf create mode 100755 arm7hf-1.26/docker-entrypoint.sh diff --git a/arm7hf-1.26/Dockerfile b/arm7hf-1.26/Dockerfile new file mode 100644 index 0000000..216d4f1 --- /dev/null +++ b/arm7hf-1.26/Dockerfile @@ -0,0 +1,57 @@ +FROM armhf/php:7.0-apache +MAINTAINER Sean Wilson + +ENV MEDIAWIKI_VERSION 1.26 +ENV MEDIAWIKI_FULL_VERSION 1.26.2 + +#TODO: Look at these +RUN set -x; \ + apt-get update \ + && apt-get install -y --no-install-recommends \ + g++ \ + libicu52 \ + libicu-dev \ + && pecl install intl \ + && echo extension=intl.so >> /usr/local/etc/php/conf.d/ext-intl.ini \ + && apt-get purge -y --auto-remove g++ libicu-dev \ + && rm -rf /var/lib/apt/lists/* + +#TODO: Whot is this +RUN docker-php-ext-install mysqli opcache + +#TODO: Look at this. +RUN set -x; \ + apt-get update \ + && apt-get install -y --no-install-recommends imagemagick \ + && rm -rf /var/lib/apt/lists/* + +#TODO: Whot is this +RUN a2enmod rewrite + +# https://www.mediawiki.org/keys/keys.txt +# TODO: Change +#RUN gpg --keyserver pool.sks-keyservers.net --recv-keys \ +# 441276E9CCD15F44F6D97D18C119E1A64D70938E \ +# 41B2ABE817ADD3E52BDA946F72BC1C5D23107F8A \ +# 162432D9E81C1C618B301EECEE1F663462D84F01 \ +# 1D98867E82982C8FE0ABC25F9B69B3109D3BB7B0 \ +# 3CEF8262806D3F0B6BA1DBDD7956EE477F901A30 \ +# 280DB7845A1DCAC92BB5A00A946B02565DC00AA7 + +RUN MEDIAWIKI_DOWNLOAD_URL="https://releases.wikimedia.org/mediawiki/$MEDIAWIKI_VERSION/mediawiki-$MEDIAWIKI_FULL_VERSION.tar.gz"; \ + set -x; \ + mkdir -p /usr/src/mediawiki \ + && curl -fSL "$MEDIAWIKI_DOWNLOAD_URL" -o mediawiki.tar.gz \ + && curl -fSL "${MEDIAWIKI_DOWNLOAD_URL}.sig" -o mediawiki.tar.gz.sig \ + && gpg --verify mediawiki.tar.gz.sig \ + && tar -xf mediawiki.tar.gz -C /usr/src/mediawiki --strip-components=1 + + +#TODO: looks at this, looks good just try to understand +COPY apache/mediawiki.conf /etc/apache2/ +RUN echo Include /etc/apache2/mediawiki.conf >> /etc/apache2/apache2.conf + +COPY docker-entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] +#TODO might need to change +CMD ["apache2-foreground"] diff --git a/arm7hf-1.26/README.md b/arm7hf-1.26/README.md new file mode 100644 index 0000000..71e1b84 --- /dev/null +++ b/arm7hf-1.26/README.md @@ -0,0 +1,44 @@ +# What is MediaWiki? + +MediaWiki is a free and open-source wiki app, used to power wiki websites such +as Wikipedia, Wiktionary and Commons, developed by the Wikimedia Foundation and +others. + +> [wikipedia.org/wiki/MediaWiki](https://en.wikipedia.org/wiki/MediaWiki) + +# How to use this image + + docker run --name some-mediawiki --link some-mysql:mysql -d spwilson2/mediawiki + +The following environment variables are also honored for configuring your +MediaWiki instance: + + - `-e MEDIAWIKI_DB_HOST=ADDR:PORT` (defaults to the address and port of the + linked mysql container) + - `-e MEDIAWIKI_DB_USER=...` (defaults to "root") + - `-e MEDIAWIKI_DB_PASSWORD=...` (defaults to the value of the + `MYSQL_ROOT_PASSWORD` environment variable from the linked mysql container) + - `-e MEDIAWIKI_DB_NAME=...` (defaults to "mediawiki") + +If the `MEDIAWIKI_DB_NAME` specified does not already exist in the given MySQL +container, it will be created automatically upon container startup, provided +that the `MEDIAWIKI_DB_USER` specified has the necessary permissions to create +it. + +To use with an external database server, use `MEDIAWIKI_DB_HOST` (along with +`MEDIAWIKI_DB_USER` and `MEDIAWIKI_DB_PASSWORD` if necessary): + + docker run --name some-mediawiki -e MEDIAWIKI_DB_HOST=10.0.0.1:3306 \ + -e MEDIAWIKI_DB_USER=app -e MEDIAWIKI_DB_PASSWORD=secure spwilson2/rpi-mediawiki + +If you'd like to be able to access the instance from the host without the +container's IP, standard port mappings can be used: + + docker run --name some-mediawiki --link some-mysql:mysql -p 8080:80 -d spwilson2/rpi-mediawiki + +Then, access it via `http://localhost:8080` or `http://host-ip:8080` in a browser. + +Once you have set up your media wiki, you'll need to add the LocalSettings.php file output to +the docker container. + + docker run --name some-mediawiki -v /path/on-docker-host/to/LocalSettings.php:/var/www-shared/html/LocalSettings.php --link some-mysql:mysql -d spwilson2/rpi-mediawiki diff --git a/arm7hf-1.26/apache/mediawiki.conf b/arm7hf-1.26/apache/mediawiki.conf new file mode 100644 index 0000000..f1b0450 --- /dev/null +++ b/arm7hf-1.26/apache/mediawiki.conf @@ -0,0 +1,19 @@ + + RewriteEngine On + RewriteBase / + RewriteRule ^index\.php$ - [L] + RewriteCond %{REQUEST_FILENAME} !-f + RewriteCond %{REQUEST_FILENAME} !-d + RewriteRule . /index.php [L] + + + + # Ignore .htaccess files + AllowOverride None + + # Serve HTML as plaintext, don't execute SHTML + AddType text/plain .html .htm .shtml .php + + # Don't run arbitrary PHP code. + php_admin_flag engine off + diff --git a/arm7hf-1.26/docker-entrypoint.sh b/arm7hf-1.26/docker-entrypoint.sh new file mode 100755 index 0000000..8c11ae4 --- /dev/null +++ b/arm7hf-1.26/docker-entrypoint.sh @@ -0,0 +1,88 @@ +#!/bin/bash + +set -e + +: ${MEDIAWIKI_SITE_NAME:=MediaWiki} + +if [ -z "$MEDIAWIKI_DB_HOST" -a -z "$MYSQL_PORT_3306_TCP" ]; then + echo >&2 'error: missing MYSQL_PORT_3306_TCP environment variable' + echo >&2 ' Did you forget to --link some_mysql_container:mysql ?' + exit 1 +fi + +# if we're linked to MySQL, and we're using the root user, and our linked +# container has a default "root" password set up and passed through... :) +: ${MEDIAWIKI_DB_USER:=root} +if [ "$MEDIAWIKI_DB_USER" = 'root' ]; then + : ${MEDIAWIKI_DB_PASSWORD:=$MYSQL_ENV_MYSQL_ROOT_PASSWORD} +fi +: ${MEDIAWIKI_DB_NAME:=mediawiki} + +if [ -z "$MEDIAWIKI_DB_PASSWORD" ]; then + echo >&2 'error: missing required MEDIAWIKI_DB_PASSWORD environment variable' + echo >&2 ' Did you forget to -e MEDIAWIKI_DB_PASSWORD=... ?' + echo >&2 + echo >&2 ' (Also of interest might be MEDIAWIKI_DB_USER and MEDIAWIKI_DB_NAME.)' + exit 1 +fi + +if ! [ -e index.php -a -e includes/DefaultSettings.php ]; then + echo >&2 "MediaWiki 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/mediawiki . | tar xf - + echo >&2 "Complete! MediaWiki has been successfully copied to $(pwd)" +fi + +#TODO: Change this into symlinks for all the folders that will need to be backed up. +# otherwise we can just naively backup /var/lib/www +# +#: ${MEDIAWIKI_SHARED:=/var/www-shared/html} +#if [ -d "$MEDIAWIKI_SHARED" ]; then +# # If there is no LocalSettings.php but we have one under the shared +# # directory, symlink it +# if [ -e "$MEDIAWIKI_SHARED/LocalSettings.php" -a ! -e LocalSettings.php ]; then +# ln -s "$MEDIAWIKI_SHARED/LocalSettings.php" LocalSettings.php +# fi +# +# # If the images directory only contains a README, then link it to +# # $MEDIAWIKI_SHARED/images, creating the shared directory if necessary +# if [ "$(ls images)" = "README" -a ! -L images ]; then +# rm -fr images +# mkdir -p "$MEDIAWIKI_SHARED/images" +# ln -s "$MEDIAWIKI_SHARED/images" images +# fi +#fi + +: ${MEDIAWIKI_DB_HOST:=${MYSQL_PORT_3306_TCP#tcp://}} + +TERM=dumb php -- "$MEDIAWIKI_DB_HOST" "$MEDIAWIKI_DB_USER" "$MEDIAWIKI_DB_PASSWORD" "$MEDIAWIKI_DB_NAME" <<'EOPHP' +connect_error) { + file_put_contents('php://stderr', 'MySQL Connection Error: (' . $mysql->connect_errno . ') ' . $mysql->connect_error . "\n"); + exit(1); +} + +if (!$mysql->query('CREATE DATABASE IF NOT EXISTS `' . $mysql->real_escape_string($argv[4]) . '`')) { + file_put_contents('php://stderr', 'MySQL "CREATE DATABASE" Error: ' . $mysql->error . "\n"); + $mysql->close(); + exit(1); +} + +$mysql->close(); +EOPHP + +# Change permissions for all folders to www-data user. +chown -R www-data: . + +export MEDIAWIKI_SITE_NAME MEDIAWIKI_DB_HOST MEDIAWIKI_DB_USER MEDIAWIKI_DB_PASSWORD MEDIAWIKI_DB_NAME + +exec "$@"