code.gitea.io/gitea@v1.22.3/docker/rootless/usr/local/bin/docker-setup.sh (about)

     1  #!/bin/bash
     2  
     3  # Prepare git folder
     4  mkdir -p ${HOME} && chmod 0700 ${HOME}
     5  if [ ! -w ${HOME} ]; then echo "${HOME} is not writable"; exit 1; fi
     6  
     7  # Prepare custom folder
     8  mkdir -p ${GITEA_CUSTOM} && chmod 0700 ${GITEA_CUSTOM}
     9  
    10  # Prepare temp folder
    11  mkdir -p ${GITEA_TEMP} && chmod 0700 ${GITEA_TEMP}
    12  if [ ! -w ${GITEA_TEMP} ]; then echo "${GITEA_TEMP} is not writable"; exit 1; fi
    13  
    14  #Prepare config file
    15  if [ ! -f ${GITEA_APP_INI} ]; then
    16  
    17      #Prepare config file folder
    18      GITEA_APP_INI_DIR=$(dirname ${GITEA_APP_INI})
    19      mkdir -p ${GITEA_APP_INI_DIR} && chmod 0700 ${GITEA_APP_INI_DIR}
    20      if [ ! -w ${GITEA_APP_INI_DIR} ]; then echo "${GITEA_APP_INI_DIR} is not writable"; exit 1; fi
    21  
    22      # Set INSTALL_LOCK to true only if SECRET_KEY is not empty and
    23      # INSTALL_LOCK is empty
    24      if [ -n "$SECRET_KEY" ] && [ -z "$INSTALL_LOCK" ]; then
    25          INSTALL_LOCK=true
    26      fi
    27  
    28      # Substitute the environment variables in the template
    29      APP_NAME=${APP_NAME:-"Gitea: Git with a cup of tea"} \
    30      RUN_MODE=${RUN_MODE:-"prod"} \
    31      RUN_USER=${USER:-"git"} \
    32      SSH_DOMAIN=${SSH_DOMAIN:-"localhost"} \
    33      HTTP_PORT=${HTTP_PORT:-"3000"} \
    34      ROOT_URL=${ROOT_URL:-""} \
    35      DISABLE_SSH=${DISABLE_SSH:-"false"} \
    36      SSH_PORT=${SSH_PORT:-"2222"} \
    37      SSH_LISTEN_PORT=${SSH_LISTEN_PORT:-$SSH_PORT} \
    38      DB_TYPE=${DB_TYPE:-"sqlite3"} \
    39      DB_HOST=${DB_HOST:-"localhost:3306"} \
    40      DB_NAME=${DB_NAME:-"gitea"} \
    41      DB_USER=${DB_USER:-"root"} \
    42      DB_PASSWD=${DB_PASSWD:-""} \
    43      INSTALL_LOCK=${INSTALL_LOCK:-"false"} \
    44      DISABLE_REGISTRATION=${DISABLE_REGISTRATION:-"false"} \
    45      REQUIRE_SIGNIN_VIEW=${REQUIRE_SIGNIN_VIEW:-"false"} \
    46      SECRET_KEY=${SECRET_KEY:-""} \
    47      envsubst < /etc/templates/app.ini > ${GITEA_APP_INI}
    48  fi
    49  
    50  # Replace app.ini settings with env variables in the form GITEA__SECTION_NAME__KEY_NAME
    51  environment-to-ini --config ${GITEA_APP_INI}