This commit is contained in:
2023-04-16 21:38:32 +08:00
parent a0849e40ef
commit 0b6c876a0f
59 changed files with 1026 additions and 189 deletions

View File

@@ -2,8 +2,7 @@
##################################################
# Mount dir #
# - /var/lib/gitea #
# - /var/log/gitea #
# - /opt/gitea #
##################################################
set -euo pipefail
@@ -31,39 +30,140 @@ function Quit {
function Usage {
Print 'This container should run with
**root user**
**/var/{lib,log}/gitea mounted from host**
**/opt/gitea mounted from host**
'
}
function RestoreConf {
if [ -z "$(ls gitea/)" ]; then
Print Restore default config files and quit ...
tar zxf gitea.tgz
exit
fi
function GenerateConf {
Print Generating app.ini ...
mkdir -p custom/conf
cat > custom/conf/app.ini <<-EOF
APP_NAME = Gitea
RUN_USER = gitea
RUN_MODE = prod
[repository]
ROOT = /opt/gitea/repos
SCRIPT_TYPE = bash
[security]
PASSWORD_COMPLEXITY = off
DISABLE_GIT_HOOKS = false
[indexer]
ISSUE_INDEXER_TYPE = bleve
ISSUE_INDEXER_PATH = /opt/gitea/indexers/issues.bleve
REPO_INDEXER_ENABLED = true
REPO_INDEXER_PATH = /opt/gitea/indexers/repos.bleve
MAX_FILE_SIZE = 1048576
REPO_INDEXER_INCLUDE = **.go,**.yml,**.toml,**.c,**.h,**makefile,**.py,**.txt,**.ini,**.rs,**.sh,**.md,**Dockerfile*,**docker-entrypoint*,**.cnf,**.conf,**.json,**.sql,**.xml,**.js,**.jsx,**.vue,**.ts,**.tsx,**.html,**.css,**.scss,**.less
[queue.issue_indexer]
ISSUE_INDEXER_QUEUE_TYPE = levelqueue
ISSUE_INDEXER_QUEUE_DIR = /opt/gitea/indexers/issues.queue
UPDATE_BUFFER_LEN = 20
[server]
APP_DATA_PATH = /opt/gitea/data
PROTOCOL = http
HTTP_ADDR = 0.0.0.0
HTTP_PORT = 3000
#PROTOCOL = unix
#HTTP_ADDR = /sock/gitea
#UNIX_SOCKET_PERMISSION = 666
#DOMAIN = x.x.x
#ROOT_URL = http://x.x.x
DISABLE_SSH = true
START_SSH_SERVER = false
SSH_DOMAIN = x.x.x
SSH_PORT = 3622
LFS_START_SERVER = true
OFFLINE_MODE = false
ENABLE_GZIP = true
[database]
DB_TYPE = sqlite3
PATH = /opt/gitea/data/gitea.db
SSL_MODE = disable
[mailer]
ENABLED = false
[service]
REGISTER_EMAIL_CONFIRM = false
ENABLE_NOTIFY_MAIL = false
DISABLE_REGISTRATION = true
ALLOW_ONLY_EXTERNAL_REGISTRATION = false
ENABLE_CAPTCHA = true
REQUIRE_SIGNIN_VIEW = true
DEFAULT_KEEP_EMAIL_PRIVATE = true
DEFAULT_ALLOW_CREATE_ORGANIZATION = false
DEFAULT_ENABLE_TIMETRACKING = true
NO_REPLY_ADDRESS =
[picture]
DISABLE_GRAVATAR = true
ENABLE_FEDERATED_AVATAR = false
[openid]
ENABLE_OPENID_SIGNIN = false
ENABLE_OPENID_SIGNUP = false
[attachment]
ENABLED = true
ALLOWED_TYPES = */*
MAX_SIZE = 1024
MAX_FILES = 5
STORAGE_TYPE = local
PATH = /opt/gitea/attachments
[session]
PROVIDER = memory
[time]
FORMAT = RFC3339
[log]
ROOT_PATH = /opt/gitea/log
MODE = file
LEVEL = warn
ROUTER = file
[git]
PATH =
HOME_PATH = /opt/gitea/data/git-home
[lfs]
PATH = /opt/gitea/lfs
[webhook]
ALLOWED_HOST_LIST = *
EOF
}
function ChangeOwner {
Print Change file owner ...
chown -R gitea.www-data gitea/ /var/log/gitea/
Print Changing file owner ...
chown -R gitea:gitea /opt/gitea
}
function StartProc {
Print Start gitea ...
Print Starting gitea ...
su - gitea -c '
gitea web \
--work-path /var/lib/gitea \
--custom-path /var/lib/gitea/custom \
--config /var/lib/gitea/custom/conf/app.ini
' &>> /var/log/gitea/gitea.out &
gitea \
--work-path /opt/gitea \
--custom-path /opt/gitea/custom \
--config /opt/gitea/custom/conf/app.ini \
web
' &>> /opt/gitea/log/gitea.out &
PIDS="$PIDS $!"
Print Gitea started.
}
function Main {
local pid=
cd /var/lib
cd /opt/gitea
Usage
RestoreConf
[ -e custom/conf ] || GenerateConf
ChangeOwner
StartProc
trap "GOT_SIGTERM=1; Print Got SIGTERM ..." SIGTERM