chore: rewrite freshrss setup tasks in entrypoint script
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

This commit is contained in:
Robert Kaussow 2021-06-08 00:01:38 +02:00
parent c3d9f9a619
commit 70a233fbf5
Signed by: xoxys
GPG Key ID: 4E692A2EAECC03C0
1 changed files with 32 additions and 19 deletions

View File

@ -9,30 +9,43 @@ if [ -n "${FRESHRSS_POSTGRES_SSL_ROOTCERT}" ] && [ ! -f "/var/www/.postgresql/ro
fi
printf "\nPrepare FreshRSS...\n"
PREP=$(/usr/bin/php -f ./cli/prepare.php)
if [ $? -ne 0 ]; then
echo "$PREP"
exit 1
/usr/bin/php -f ./cli/prepare.php >/dev/null 2>&1
/usr/bin/php -f ./cli/do-install.php -- --api_enabled \
--base_url "${FRESHRSS_BASE_URL:-http://localhost/}" \
--db-base "${FRESHRSS_DB_BASE}" \
--db-host "${FRESHRSS_DB_HOST:-localhost}" \
--db-password "${FRESHRSS_DB_PASSWORD}" \
--db-type "${FRESHRSS_DB_TYPE:-sqlite}" \
--db-user "${FRESHRSS_DB_USER}" \
--default_user "${FRESHRSS_DEFAULT_USER:-_}" \
--language "${FRESHRSS_LANGUAGE:-en}" >/dev/null 2>&1
EXITCODE=$?
if [ $EXITCODE -eq 3 ]; then
printf 'FreshRSS already installed, no change performed\n'
elif [ $EXITCODE -eq 0 ]; then
printf 'FreshRSS successfully installed\n'
else
printf 'FreshRSS error during installation\n'
exit $EXITCODE
fi
if [ "${FRESHRSS_DEFAULT_USER}" ]; then
printf "\nEnsure default user exists...\n"
UCREATE=$(/usr/bin/php ./cli/create-user.php --user "$FRESHRSS_DEFAULT_USER" --password "$FRESHRSS_DEFAULT_PASSWORD" 2>&1)
if [ $? -ne 0 ]; then
case "$UCREATE" in
*"username already taken"*) ;;
*)
echo "$UCREATE"
rm -rf "/var/www/app/data/users/$FRESHRSS_DEFAULT_USER"
exit 1
;;
esac
fi
printf "Result: success\n\n"
fi
/usr/bin/php ./cli/create-user.php --user "$FRESHRSS_DEFAULT_USER" --password "$FRESHRSS_DEFAULT_PASSWORD" --language "${FRESHRSS_LANGUAGE:-en}" >/dev/null 2>&1
EXITCODE=$?
if [ -f "/var/www/app/data/do-install.txt" ]; then
rm -rf /var/www/app/data/do-install.txt
if [ $EXITCODE -eq 3 ]; then
printf 'FreshRSS user already exists, no change performed\n'
elif [ $EXITCODE -eq 0 ]; then
printf 'FreshRSS user successfully created\n'
./cli/list-users.php | xargs -n1 ./cli/actualize-user.php --user "$FRESHRSS_DEFAULT_USER"
else
rm -f /tmp/out.txt /tmp/err.txt
printf 'FreshRSS error during the creation of a user\n'
exit $EXITCODE
fi
fi
supercronic /etc/crontabs/nginx &