#!/bin/sh -e while ! pg_isready -h $TTRSS_DB_HOST -U $TTRSS_DB_USER; do echo waiting until $TTRSS_DB_HOST is ready... sleep 3 done # We don't need those here (HTTP_HOST would cause false SELF_URL_PATH check failures) unset HTTP_PORT unset HTTP_HOST if ! id app >/dev/null 2>&1; then # what if i actually need a duplicate GID/UID group? addgroup -g $OWNER_GID app || echo app:x:$OWNER_GID:app | \ tee -a /etc/group adduser -D -h /var/www/html -G app -u $OWNER_UID app || \ echo app:x:$OWNER_UID:$OWNER_GID:Linux User,,,:/var/www/html:/bin/ash | tee -a /etc/passwd fi update-ca-certificates || true DST_DIR=/var/www/html/tt-rss SRC_REPO=https://git.tt-rss.org/fox/tt-rss.git [ -e $DST_DIR ] && rm -f $DST_DIR/.app_is_ready export PGPASSWORD=$TTRSS_DB_PASS [ ! -e /var/www/html/index.php ] && cp ${SCRIPT_ROOT}/index.php /var/www/html PSQL="psql -q -h $TTRSS_DB_HOST -U $TTRSS_DB_USER $TTRSS_DB_NAME" if [ ! -d $DST_DIR/.git ]; then mkdir -p $DST_DIR chown $OWNER_UID:$OWNER_GID $DST_DIR echo cloning tt-rss source from $SRC_REPO to $DST_DIR... sudo -u app git clone --depth 1 $SRC_REPO $DST_DIR || echo error: failed to clone master repository. else echo updating tt-rss source in $DST_DIR from $SRC_REPO... chown -R $OWNER_UID:$OWNER_GID $DST_DIR cd $DST_DIR && \ sudo -u app git config core.filemode false && \ sudo -u app git config pull.rebase false && \ sudo -u app git pull origin master || echo error: unable to update master repository. fi if [ ! -e $DST_DIR/index.php ]; then echo "error: tt-rss index.php missing (git clone failed?), unable to continue." exit 1 fi if [ ! -d $DST_DIR/plugins.local/nginx_xaccel ]; then echo cloning plugins.local/nginx_xaccel... sudo -u app git clone https://git.tt-rss.org/fox/ttrss-nginx-xaccel.git \ $DST_DIR/plugins.local/nginx_xaccel || echo warning: failed to clone nginx_xaccel. else if [ -z "$TTRSS_NO_STARTUP_PLUGIN_UPDATES" ]; then echo updating all local plugins... find $DST_DIR/plugins.local/ -maxdepth 1 -mindepth 1 -type d | while read PLUGIN; do if [ -d $PLUGIN/.git ]; then echo updating $PLUGIN... cd $PLUGIN && \ sudo -u app git config core.filemode false && \ sudo -u app git config pull.rebase false && \ sudo -u app git pull origin master || echo warning: attempt to update plugin $PLUGIN failed. fi done else echo updating plugins.local/nginx_xaccel... cd $DST_DIR/plugins.local/nginx_xaccel && \ sudo -u app git config core.filemode false && \ sudo -u app git config pull.rebase false && \ sudo -u app git pull origin master || echo warning: attempt to update plugin nginx_xaccel failed. fi fi cp ${SCRIPT_ROOT}/config.docker.php $DST_DIR/config.php chmod 644 $DST_DIR/config.php for d in cache lock feed-icons; do chmod 777 $DST_DIR/$d find $DST_DIR/$d -type f -exec chmod 666 {} \; done chown -R $OWNER_UID:$OWNER_GID $DST_DIR \ /var/log/php82 $PSQL -c "create extension if not exists pg_trgm" RESTORE_SCHEMA=${SCRIPT_ROOT}/restore-schema.sql.gz if [ -r $RESTORE_SCHEMA ]; then $PSQL -c "drop schema public cascade; create schema public;" zcat $RESTORE_SCHEMA | $PSQL fi # this was previously generated rm -f $DST_DIR/config.php.bak if [ ! -z "${TTRSS_CORE_DUMPS_ENABLED}" ]; then apk add gdb echo "don't forget to enable core dumps on the host:" echo "echo '/tmp/core-%e.%p' > /proc/sys/kernel/core_pattern" echo "then run gdb /usr/sbin/php-fpm82 /tmp/coredump-php-fpm-xyz" # enable core dumps sed -i.bak \ -e 's/;\(rlimit_core\) = .*/\1 = unlimited/' \ -e 's/; *\(process.dumpable\) = .*/\1 = yes/' \ /etc/php82/php-fpm.d/www.conf fi if [ ! -z "${TTRSS_XDEBUG_ENABLED}" ]; then if [ -z "${TTRSS_XDEBUG_HOST}" ]; then export TTRSS_XDEBUG_HOST=$(ip ro sh 0/0 | cut -d " " -f 3) fi echo enabling xdebug with the following parameters: env | grep TTRSS_XDEBUG cat > /etc/php82/conf.d/50_xdebug.ini <> /proc/1/fd/2) & unset ADMIN_USER_PASS unset AUTO_CREATE_USER_PASS # cleanup any old lockfiles rm -vf -- /var/www/html/tt-rss/lock/*.lock touch $DST_DIR/.app_is_ready exec /usr/sbin/php-fpm82 --nodaemonize --force-stderr -R