All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
60 lines
1.6 KiB
Bash
Executable File
60 lines
1.6 KiB
Bash
Executable File
#!/bin/bash
|
|
set -e
|
|
|
|
# Wait for MySQL/MariaDB
|
|
echo "Waiting for MySQL/MariaDB..."
|
|
MAX_RETRY=45
|
|
RETRY=1
|
|
while ! mysql --protocol TCP -h"$MYSQL_HOST" -u"$MYSQL_USER" -p"$MYSQL_PASSWORD" -e "show databases;" > /dev/null 2>&1; do
|
|
sleep 1
|
|
RETRY=`expr $RETRY + 1`
|
|
if [ $RETRY -gt $MAX_RETRY ]; then
|
|
>&2 echo "We have been waiting for MySQL too long already; failing."
|
|
exit 1
|
|
fi;
|
|
done
|
|
|
|
# Set up Flarum
|
|
if [[ -e '/flarum/app/public/assets/.installed.lock' ]]; then
|
|
# If Flarum has already been installed, just create a config file
|
|
echo "Creating config file..."
|
|
cat << EOF > /flarum/app/config.php
|
|
<?php return array (
|
|
'debug' => ${DEBUG:-false},
|
|
'offline' => false,
|
|
'database' => array (
|
|
'driver' => 'mysql',
|
|
'host' => '${MYSQL_HOST:-mysql}',
|
|
'port' => '${MYSQL_PORT:-3306}',
|
|
'database' => '${MYSQL_DATABASE:-flarum}',
|
|
'username' => '${MYSQL_USER:-flarum}',
|
|
'password' => '${MYSQL_PASSWORD:-flarum}',
|
|
'charset' => 'utf8mb4',
|
|
'collation' => 'utf8mb4_unicode_ci',
|
|
'prefix' => '',
|
|
'strict' => false,
|
|
),
|
|
'url' => '${SITE_URL:-http://localhost}',
|
|
'paths' => array (
|
|
'api' => 'api',
|
|
'admin' => 'admin',
|
|
),
|
|
);
|
|
EOF
|
|
else
|
|
# Else build the config template and run the command line installer
|
|
cd /flarum
|
|
php make_config.php
|
|
cd /flarum/app
|
|
php flarum install -f /flarum/config.yaml
|
|
rm -f /flarum/config.yaml
|
|
touch /flarum/app/public/assets/.installed.lock
|
|
fi
|
|
|
|
# first arg is `-f` or `--some-option`
|
|
if [[ "${1#-}" != "$1" ]]; then
|
|
set -- apache2-foreground "$@"
|
|
fi
|
|
|
|
exec "$@"
|