From cc648eb8789a1ca929c4cd92cb89c53bd6f436d5 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 21 May 2022 20:02:42 +0300 Subject: [PATCH] * perform all operations on git repositories under 'app' user * initially clone master repo with --depth 1 to reduce first startup time * only check updates for actual git repos in plugins.local/ --- app/startup.sh | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/app/startup.sh b/app/startup.sh index e3fb6f3..9fcbc34 100755 --- a/app/startup.sh +++ b/app/startup.sh @@ -34,14 +34,18 @@ 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 -R $OWNER_UID:$OWNER_GID $DST_DIR + echo cloning tt-rss source from $SRC_REPO to $DST_DIR... - git clone $SRC_REPO $DST_DIR || echo error: failed to clone master repository. + 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 && \ - git config core.filemode false && \ - git config pull.rebase false && \ - git pull origin master || echo error: unable to update master repository. + 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 @@ -51,26 +55,29 @@ fi if [ ! -d $DST_DIR/plugins.local/nginx_xaccel ]; then echo cloning plugins.local/nginx_xaccel... - git clone https://git.tt-rss.org/fox/ttrss-nginx-xaccel.git \ + 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 - echo updating $PLUGIN... - - cd $PLUGIN && \ - git config core.filemode false && \ - git config pull.rebase false && \ - git pull origin master || echo warning: attempt to update plugin $PLUGIN failed. + 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 && \ - git config core.filemode false && \ - git config pull.rebase false && \ - git pull origin master || echo warning: attempt to update plugin nginx_xaccel failed. + 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