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

88 lines
2.3 KiB
Cheetah
Raw Normal View History

#!/bin/bash
set -eu -o pipefail
init_composer() {
set -eu
2021-02-17 16:21:51 +00:00
if ! type composer > /dev/null 2>&1; then
apt update -yqq && apt install -yqq curl git unzip zip
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
}
2020-10-19 15:33:22 +00:00
composer_install() {
set -eu
2021-02-17 16:21:51 +00:00
cd /var/www/html/ && composer update && composer install
}
init_db() {
set -eu
if ! type mysql > /dev/null 2>&1; then
2021-02-16 16:10:31 +00:00
apt update -qq && apt install -yqq mariadb-client
fi
PASSWORD=$(cat /run/secrets/db_password)
2020-10-24 01:56:05 +00:00
# FIXME 3wc: replace with sql.php, not sure how to parse output:
# stdClass Object
#(
# [TOTAL] => 58
#)
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)
2020-09-16 20:19:23 +00:00
if [[ "${TABLE_COUNT}" == "0" ]]; then
2021-02-17 16:21:51 +00:00
php /var/www/html/maintenance/generateSchemaSql.php
php /var/www/html/maintenance/sql.php /var/www/html/maintenance/tables-generated.sql
php /var/www/html/maintenance/sql.php /var/www/html/maintenance/tables.sql
php /var/www/html/maintenance/sql.php /var/www/html/maintenance/interwiki.sql
2020-10-24 01:56:05 +00:00
# FIXME run createAndPromote.php with $ADMIN_USERNAME
2020-09-16 20:19:23 +00:00
else
2021-02-17 08:40:28 +00:00
php /var/www/html/maintenance/update.php --quick
2020-09-16 20:19:23 +00:00
fi
if [ -n "${OPENID_ENABLED-}" ]; then
2021-02-17 08:40:28 +00:00
php /var/www/html/maintenance/update.php --quick
fi
2020-09-16 20:19:23 +00:00
}
init_extensions() {
2020-09-16 20:19:23 +00:00
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
2020-10-19 15:22:57 +00:00
if [ ! -d /var/www/html/extensions/OpenIDConnect ]; then
git clone --depth 1 -b REL1_35 \
2020-10-15 16:26:40 +00:00
https://gerrit.wikimedia.org/r/mediawiki/extensions/OpenIDConnect \
/var/www/html/extensions/OpenIDConnect
fi
2020-09-16 20:19:23 +00:00
fi
}
main() {
2020-09-16 20:19:23 +00:00
set -eu
init_extensions
init_composer
2020-10-19 15:33:22 +00:00
composer_install
2021-02-17 16:21:51 +00:00
init_db
}
main
apache2-foreground