diff --git a/scripts/gitea b/scripts/gitea index 7517026..386b4e2 100755 --- a/scripts/gitea +++ b/scripts/gitea @@ -12,11 +12,18 @@ readConfig() { } check() { - if [[ -d "$giteaDir" ]]; then - echo "Cleaning out old Gitea backups..." - rm -f "$giteaDir"/* || return 1 - else - mkdir -p "$giteaDir" | return 1 + GITEA_CONFIG=${GITEA_CONFIG:-/etc/gitea/app.ini} + if [[ ! -r "$GITEA_CONFIG" ]]; then + echo "ERROR: Cannot read gitea app.ini in $GITEA_CONFIG" + return 4 + fi + + GITEA_USER=${GITEA_USER:-git} + GITEA_GROUP=${GITEA_GROUP:-git} + GITEA_HOME=${GITEA_HOME:-$(getent passwd ${GITEA_USER} | cut -f6 -d:)} + if [[ ! -d "$GITEA_HOME" ]]; then + echo "ERROR: Cannot find Gitea home directory" + return 5 fi if [[ -n "$GITEA_BIN" ]]; then @@ -40,17 +47,13 @@ check() { fi fi - GITEA_CONFIG=${GITEA_CONFIG:-/etc/gitea/app.ini} - if [[ ! -r "$GITEA_CONFIG" ]]; then - echo "ERROR: Cannot read gitea app.ini in $GITEA_CONFIG" - return 4 - fi - - GITEA_USER=${GITEA_USER:-git} - GITEA_HOME=${GITEA_HOME:-$(getent passwd ${GITEA_USER} | cut -f6 -d:)} - if [[ ! -d "$GITEA_HOME" ]]; then - echo "ERROR: Cannot find Gitea home directory" - return 5 + if [[ -d "$giteaDir" ]]; then + echo "Cleaning out old Gitea backups..." + rm -f "$giteaDir"/* || return 1 + else + mkdir -p "$giteaDir" | return 1 + chgrp "$GITEA_GROUP" "$giteaDir" + chmod g+wx "$giteaDir" fi }