2020-09-07 19:09:46 +00:00
#!/bin/bash
set -eu -o pipefail
2020-10-19 14:50:47 +00:00
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
2023-03-12 01:14:00 +00:00
php /tmp/composer-setup.php --install-dir=/usr/local/bin --filename=composer --version=2.5.4
2021-02-17 16:21:51 +00:00
composer -V
2020-10-19 14:50:47 +00:00
fi
}
2020-10-19 15:33:22 +00:00
composer_install() {
2020-10-19 14:50:47 +00:00
set -eu
2021-02-17 16:21:51 +00:00
cd /var/www/html/ && composer update && composer install
2020-10-15 16:11:54 +00:00
}
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
2020-10-15 16:11:54 +00:00
fi
2020-09-07 21:04:41 +00:00
2020-10-05 23:32:46 +00:00
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
#)
2020-10-05 23:32:46 +00:00
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-07 21:04:41 +00:00
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
fi
2021-02-16 14:22:51 +00:00
2023-06-25 20:17:02 +00:00
php /var/www/html/maintenance/update.php --quick
2020-09-16 20:19:23 +00:00
}
2021-02-16 16:08:47 +00:00
init_extensions() {
2023-05-30 21:46:40 +00:00
2020-09-16 20:19:23 +00:00
if [ ! -d /var/www/html/extensions/PluggableAuth ]; then
2023-09-09 12:51:45 +00:00
git clone --depth 1 -b REL1_40 \
2020-09-16 20:19:23 +00:00
https://gerrit.wikimedia.org/r/p/mediawiki/extensions/PluggableAuth \
/var/www/html/extensions/PluggableAuth
fi
2020-10-24 17:01:17 +00:00
if [ -n " ${ SAML_ENABLED - } " ]; then
2020-10-15 16:23:45 +00:00
if [ ! -d /var/www/html/extensions/SimpleSAMLphp ]; then
2023-09-09 12:51:45 +00:00
git clone --depth 1 -b REL1_40 \
2020-10-15 16:23:45 +00:00
https://gerrit.wikimedia.org/r/p/mediawiki/extensions/SimpleSAMLphp \
/var/www/html/extensions/SimpleSAMLphp
fi
fi
2020-10-24 17:01:17 +00:00
if [ -n " ${ OPENID_ENABLED - } " ]; then
2020-10-19 15:22:57 +00:00
if [ ! -d /var/www/html/extensions/OpenIDConnect ]; then
2023-09-09 12:51:45 +00:00
git clone --depth 1 -b REL1_40 \
2020-10-15 16:26:40 +00:00
https://gerrit.wikimedia.org/r/mediawiki/extensions/OpenIDConnect \
2020-10-15 16:23:45 +00:00
/var/www/html/extensions/OpenIDConnect
fi
2020-09-16 20:19:23 +00:00
fi
2023-04-01 19:09:11 +00:00
2023-05-30 21:46:40 +00:00
if [ -n " ${ MOBILEFRONTEND_ENABLED - } " ]; then
if [ ! -d /var/www/html/extensions/MobileFrontend ]; then
2023-09-09 12:51:45 +00:00
git clone --depth 1 -b REL1_40 \
2023-05-30 21:46:40 +00:00
https://github.com/wikimedia/mediawiki-extensions-MobileFrontend.git \
/var/www/html/extensions/MobileFrontend
fi
fi
2023-04-01 19:09:11 +00:00
if [ -n " ${ MSU_ENABLED - } " ]; then
if [ ! -d /var/www/html/extensions/MsUpload ]; then
2023-09-09 12:51:45 +00:00
git clone --depth 1 -b REL1_40 \
2023-04-01 19:09:11 +00:00
https://gerrit.wikimedia.org/r/mediawiki/extensions/MsUpload \
/var/www/html/extensions/MsUpload
fi
fi
if [ -n " ${ PAGEFORMS_ENABLED - } " ]; then
if [ ! -d /var/www/html/extensions/PageForms ]; then
2023-09-09 12:51:45 +00:00
git clone --depth 1 -b REL1_40 \
2023-04-01 19:09:11 +00:00
https://gerrit.wikimedia.org/r/mediawiki/extensions/PageForms \
/var/www/html/extensions/PageForms
fi
fi
if [ -n " ${ PAGESCHEMAS_ENABLED - } " ]; then
if [ ! -d /var/www/html/extensions/PageSchemas ]; then
2023-09-09 12:51:45 +00:00
git clone --depth 1 -b REL1_40 \
2023-04-01 19:09:11 +00:00
https://gerrit.wikimedia.org/r/mediawiki/extensions/PageSchemas \
/var/www/html/extensions/PageSchemas
fi
fi
if [ -n " ${ MARKDOWN_ENABLED - } " ]; then
if [ ! -d /var/www/html/extensions/WikiMarkdown ]; then
2023-05-08 20:25:52 +00:00
git clone --depth 1 \
https://github.com/kuenzign/WikiMarkdown \
2023-04-01 19:09:11 +00:00
/var/www/html/extensions/WikiMarkdown
fi
fi
2020-09-07 19:09:46 +00:00
}
2023-05-14 23:10:00 +00:00
init_skins() {
if [ -n " ${ TWEEKI_ENABLED - } " ]; then
if [ ! -d /var/www/html/skins/Tweeki ]; then
git clone --depth 1 \
https://github.com/thaider/Tweeki \
/var/www/html/skins/Tweeki
fi
fi
}
2020-09-07 19:09:46 +00:00
main() {
2020-09-16 20:19:23 +00:00
set -eu
2021-02-16 16:08:47 +00:00
init_extensions
2023-05-30 21:50:22 +00:00
init_skins
2020-10-19 14:50:47 +00:00
init_composer
2020-10-19 15:33:22 +00:00
composer_install
2021-02-17 16:21:51 +00:00
init_db
2020-09-07 19:09:46 +00:00
}
main
2020-10-24 01:56:51 +00:00
apache2-foreground