docker-flarum/startup

61 lines
1.6 KiB
Plaintext
Raw Normal View History

2016-07-17 05:35:13 -04:00
#!/bin/sh
if [ -z "$DB_PASS" ]; then
echo "[ERROR] Mariadb database password must be set !"
exit 1
fi
if [ -z "$FORUM_URL" ]; then
echo "[ERROR] Forum url must be set !"
exit 1
fi
2016-07-17 09:55:22 -04:00
if [ ! -e '/flarum/app/config.php' ]; then
2016-07-17 05:35:13 -04:00
2016-07-17 09:55:22 -04:00
cd /flarum/app/
cat > config.yml <<EOF
2016-07-17 05:35:13 -04:00
databaseConfiguration:
driver: mysql
host: ${DB_HOST}
database: ${DB_NAME}
username: ${DB_USER}
password: ${DB_PASS}
baseUrl: ${FORUM_URL}
EOF
# Mail settings
sed -i -e "s|{{ MAIL_FROM }}|${MAIL_FROM}|g" \
-e "s|{{ MAIL_HOST }}|${MAIL_HOST}|g" \
-e "s|{{ MAIL_PORT }}|${MAIL_PORT}|g" \
-e "s|{{ MAIL_USER }}|${MAIL_USER}|g" \
-e "s|{{ MAIL_PASS }}|${MAIL_PASS}|g" \
2016-07-17 09:55:22 -04:00
-e "s|{{ MAIL_ENCR }}|${MAIL_ENCR}|g" config.sql
2016-07-17 05:35:13 -04:00
# Fix installer, wait fix in beta 6
# PHP Fatal error: Uncaught ReflectionException: Class flarum.config does not
# exist in /flarum/vendor/illuminate/container/Container.php
# https://github.com/flarum/core/commit/7192c4391bee006ccc2de3db6caa89803d72d130
sed -i -e 's|InfoCommand::class,||g' \
2016-07-17 09:55:22 -04:00
-e "s|\['config' => \$app->make('flarum.config')\]|['config' => \$app->isInstalled() ? \$app->make('flarum.config') : []]|g" vendor/flarum/core/src/Console/Server.php
2016-07-17 05:35:13 -04:00
2016-07-17 09:55:22 -04:00
# Set permissions
chown -R flarum:flarum /flarum
2016-07-17 05:35:13 -04:00
# Install flarum (migrate database + assets)
2016-07-17 09:55:22 -04:00
su-exec flarum:flarum php flarum install --file config.yml
2016-07-17 05:35:13 -04:00
# Define flarum settings in database
mysql -h"${DB_HOST}" -u"${DB_USER}" -p"${DB_PASS}" "${DB_NAME}" < config.sql
else
echo "[INFO] Flarum already installed, launch app..."
fi
# Set permissions
chown -R flarum:flarum /flarum
# RUN !
supervisord -c /etc/supervisor/supervisord.conf