wiki.social.coop/entrypoint.sh.tmpl

49 lines
1.1 KiB
Cheetah
Raw Normal View History

#!/bin/bash
set -eu -o pipefail
init_db() {
2020-09-16 20:19:23 +00:00
set -eu
2020-09-16 20:19:23 +00:00
if ! type mysql > /dev/null 2>&1; then
apt update && apt install -y mariadb-client
2020-09-16 20:19:23 +00:00
fi
2020-09-16 20:19:23 +00:00
PASSWORD=`cat /run/secrets/db_password`
TABLE_COUNT=$(mysql -u mediawiki --password="$PASSWORD" -h mariadb mediawiki -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
mysql -u mediawiki --password="$PASSWORD" -h mariadb mediawiki < /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 [ ! -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
}
main() {
2020-09-16 20:19:23 +00:00
set -eu
a2enmod rewrite
2020-09-16 20:19:23 +00:00
install_extensions
2020-09-08 00:09:52 +00:00
2020-09-16 20:19:23 +00:00
init_db
}
main
/docker-entrypoint.sh apache2-foreground "$@"