diff --git a/entrypoint.sh b/entrypoint.sh index 39eca8a..f108bb6 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -7,13 +7,18 @@ run_unprivileged() { echo "[INFO] Creating non-root user..." if [ ! -d "/home/worker" ]; then useradd -m worker +fi +if [[ "$(stat -c "%U:%G" /opt/crackerjack/.git)" != "worker:worker" ]]; then + echo "[INFO] Fixing ownership of .git folder" # fixes an issue where git would complain about dubious ownership (the root user owns the git clone) chown worker:worker -R .git fi -echo "[INFO] Taking ownership of data directory." -mkdir -p /opt/crackerjack/data && chown -R worker:worker /opt/crackerjack/data +if [[ "$(stat -c "%U:%G" /opt/crackerjack/data)" != "worker:worker" ]]; then + echo "[INFO] Taking ownership of data directory." + mkdir -p /opt/crackerjack/data && chown -R worker:worker /opt/crackerjack/data +fi echo '[INFO] Initializing DB and running migrations.' python3 -m flask db init