This repository has been archived on 2021-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
mediawiki/entrypoint.sh.tmpl

69 lines
1.7 KiB
Bash
Executable File

#!/bin/bash
set -eu -o pipefail
init_php() {
if ! type composer > /dev/null 2>&1; then
apt update && apt install -y curl git unzip
curl -sS https://getcomposer.org/installer -o /tmp/composer-setup.php
php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer --version=1.10.15
composer -V
fi
}
init_db() {
set -eu
if ! type mysql > /dev/null 2>&1; then
apt update && apt install -y mariadb-client
fi
PASSWORD=$(cat /run/secrets/db_password)
TABLE_COUNT=$(mysql -u "${DB_USER}" --password="$PASSWORD" -h "${DB_HOST}" "${DB_NAME}" -e "SELECT count(*) AS TOTAL FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'mediawiki';" -N -B)
if [[ "${TABLE_COUNT}" == "0" ]]; then
mysql -u "${DB_USER}" --password="$PASSWORD" -h "${DB_HOST}" "${DB_NAME}" < /var/www/html/maintenance/tables.sql
else
php /var/www/html/maintenance/update.php
fi
}
install_extensions() {
if [ ! -d /var/www/html/extensions/PluggableAuth ]; then
git clone --depth 1 -b REL1_32 \
https://gerrit.wikimedia.org/r/p/mediawiki/extensions/PluggableAuth \
/var/www/html/extensions/PluggableAuth
fi
if [ -n "$SAML_ENABLED" ]; then
if [ ! -d /var/www/html/extensions/SimpleSAMLphp ]; then
git clone --depth 1 -b REL1_32 \
https://gerrit.wikimedia.org/r/p/mediawiki/extensions/SimpleSAMLphp \
/var/www/html/extensions/SimpleSAMLphp
fi
fi
if [ -n "$OPENID_ENABLED" ]; then
if [ ! -d /var/www/html/extensions/OpenIDConnect]; then
git clone --depth 1 -b REL1_35 \
https://gerrit.wikimedia.org/r/admin/repos/mediawiki/extensions/OpenIDConnect
/var/www/html/extensions/OpenIDConnect
fi
fi
}
main() {
set -eu
a2enmod rewrite
install_extensions
init_db
init_php
}
main
/docker-entrypoint.sh apache2-foreground "$@"