freshrss-app/start.sh

63 lines
2.2 KiB
Bash
Raw Normal View History

2017-02-17 08:45:48 +00:00
#!/bin/bash
set -eu
mkdir -p /run/php/session /app/data/extensions
2017-02-17 10:28:42 +00:00
2017-02-17 08:45:48 +00:00
if ! [ -f /app/data/.installed ]; then
2019-04-04 17:18:10 +00:00
echo "==> Fresh installation, setting up..."
rsync -a /app/code/data-orig/ /app/data/
php cli/do-install.php \
--environment production --default_user admin \
2020-03-27 06:21:07 +00:00
--db-type mysql --db-host "${CLOUDRON_MYSQL_HOST}" \
--db-user "${CLOUDRON_MYSQL_USERNAME}" --db-password "${CLOUDRON_MYSQL_PASSWORD}" \
--db-base "${CLOUDRON_MYSQL_DATABASE}" --db-prefix "" \
2019-04-04 17:18:10 +00:00
--disable_update
2023-10-27 08:36:22 +00:00
2023-10-27 10:12:30 +00:00
if [[ -z "${CLOUDRON_OIDC_ISSUER:-}" ]]; then
2023-10-27 08:36:22 +00:00
php cli/create-user.php --user admin --password changeme --language en
fi
2019-04-04 17:18:10 +00:00
touch /app/data/.installed
echo "==> Done."
2017-02-17 08:45:48 +00:00
fi
if [[ ! -f /app/data/php.ini ]]; then
echo -e "; Add custom PHP configuration in this file\n; Settings here are merged with the package's built-in php.ini\n\n" > /app/data/php.ini
fi
2019-04-04 17:18:10 +00:00
echo "==> Symlinking log file"
rm -f /app/data/users/_/log_api.txt
touch /tmp/log_api.txt
ln -s /tmp/log_api.txt /app/data/users/_/log_api.txt
2018-05-31 16:36:49 +00:00
# We have to copy instead of symlinking extensions (see #2)
2019-04-04 17:18:10 +00:00
echo "==> Copying packaged extensions"
2017-02-18 10:51:44 +00:00
for f in $(ls /app/code/extensions-orig); do
2018-05-31 16:36:49 +00:00
rm -rf "/app/data/extensions/$f"
cp -r "/app/code/extensions-orig/$f" "/app/data/extensions"
2017-02-18 10:51:44 +00:00
done
2019-04-04 17:18:10 +00:00
echo "==> Updating config file"
2023-10-27 13:15:41 +00:00
if [[ -z "${CLOUDRON_OIDC_ISSUER:-}" ]]; then
extra_args="--default_user admin"
[[ ! -f /app/data/.oauth_crypto_passphrase ]] && openssl rand -base64 42 > /app/data/.oauth_crypto_passphrase
export OIDC_CRYPTO_PASSPHRASE=$(</app/data/.oauth_crypto_passphrase) # used in apache config
else
extra_args="--auth_type http_auth"
fi
php cli/reconfigure.php ${extra_args} --base_url "https://${CLOUDRON_APP_DOMAIN}" \
2020-03-27 06:21:07 +00:00
--db-type mysql --db-host "${CLOUDRON_MYSQL_HOST}" \
--db-user "${CLOUDRON_MYSQL_USERNAME}" --db-password "${CLOUDRON_MYSQL_PASSWORD}" \
--db-base "${CLOUDRON_MYSQL_DATABASE}" --db-prefix "" \
--disable_update
2019-04-04 17:18:10 +00:00
echo "==> Setting permissions"
chown -R www-data.www-data /run/php /app/data /tmp/log_api.txt
2017-02-17 08:45:48 +00:00
2019-04-04 17:18:10 +00:00
echo "==> Starting apache"
2017-02-17 08:45:48 +00:00
APACHE_CONFDIR="" source /etc/apache2/envvars
rm -f "${APACHE_PID_FILE}"
2023-10-27 10:12:30 +00:00
exec /usr/sbin/apache2 -D FOREGROUND $([[ -n "$CLOUDRON_OIDC_ISSUER" ]] && echo '-D OIDC_ENABLED')