From 7ac472b552dd272ac53fa147e3fe186c51cf9ed7 Mon Sep 17 00:00:00 2001 From: Janne Mareike Koschinski <janne@kuschku.de> Date: Tue, 5 Apr 2022 20:32:14 +0200 Subject: [PATCH] feat: change entrypoint to be designed for jobs/cronjobs instead --- Dockerfile | 8 +++++++- docker-entrypoint.sh | 38 +++++++++----------------------------- 2 files changed, 16 insertions(+), 30 deletions(-) diff --git a/Dockerfile b/Dockerfile index ce8bb0f..a0dec3d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,13 @@ RUN apt-get update && \ rm -rf /var/lib/apt/lists/* ADD docker-entrypoint.sh /docker-entrypoint.sh - + +RUN addgroup --system --gid 1000 seafile-sync && \ + adduser --system --ingroup seafile-sync --uid 1000 --shell /bin/sh --home /config seafile-sync + +USER seafile-sync + +ENV TASK="sync" ENV LIBRARY="" ENV SERVER="" ENV EMAIL="" diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index cd7f82d..daaf755 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -3,41 +3,21 @@ set -Eeo pipefail trap "exit" INT -seaf-cli init -d /seafile-data +mkdir -p ~/seafile +seaf-cli init -d ~/seafile seaf-cli start -tail -f ~/.ccnet/logs/seafile.log & - -until [ -S /seafile-data/seafile-data/seafile.sock ]; do - sleep 1; -done if [ -z "$OTP_TOKEN" ]; then echo "syncing library" - date - seaf-cli sync -l "$LIBRARY" -s "$SERVER" -d "/sync" -u "$EMAIL" -p "$PASSWORD" + seaf-cli "$TASK" -l "$LIBRARY" -s "$SERVER" -d "/sync" -u "$EMAIL" -p "$PASSWORD" else echo "syncing library with OTP" - date - seaf-cli sync -l "$LIBRARY" -s "$SERVER" -d "/sync" -u "$EMAIL" -p "$PASSWORD" --tfa $(oathtool --totp -b "$OTP_TOKEN") + seaf-cli "$TASK" -l "$LIBRARY" -s "$SERVER" -d "/sync" -u "$EMAIL" -p "$PASSWORD" --tfa $(oathtool --totp -b "$OTP_TOKEN") fi -maxretry=4 -retry=0 - -lastoutput="" -output="" - -while [ "$retry" -le "$maxretry" ]; do - ps aux | grep seafile | grep -v grep > /dev/null 2> /dev/null || { - retry=$(expr $retry + 1); - } - output=$(seaf-cli status) - if [[ "$output" != "$lastoutput" ]]; then - date - echo "$output" - lastoutput="$output" - fi - sleep 5 +until seaf-cli status | grep synchronized; do + seaf-cli status + sleep 5 done -echo "Seafile not running" -exit 1 + +seaf-cli stop -- GitLab