initial commit
This commit is contained in:
67
02/02-k-git-server-deploy.04.sh
Executable file
67
02/02-k-git-server-deploy.04.sh
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
#===============================================================================
|
||||
# ШАГ 4: СОЗДАНИЕ SYSTEMD UNIT
|
||||
#===============================================================================
|
||||
# Запуск: sudo bash 02-k-git-server-deploy.04.sh
|
||||
#===============================================================================
|
||||
|
||||
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
|
||||
source "$SCRIPT_DIR/02-k-git-server-deploy.00.sh"
|
||||
|
||||
init_log
|
||||
check_root
|
||||
|
||||
print_header "ШАГ 4: СОЗДАНИЕ SYSTEMD UNIT"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# 4.1 Создание unit-файла
|
||||
#-------------------------------------------------------------------------------
|
||||
print_subheader "Создание systemd unit"
|
||||
|
||||
cat > /etc/systemd/system/gitea.service << EOF
|
||||
[Unit]
|
||||
Description=Gitea (Git with a cup of tea)
|
||||
After=network.target
|
||||
Wants=network.target
|
||||
|
||||
[Service]
|
||||
User=git
|
||||
Group=git
|
||||
WorkingDirectory=$GITEA_DATA
|
||||
Environment=USER=git HOME=$GIT_HOME GITEA_WORK_DIR=$GITEA_DATA
|
||||
ExecStart=$GITEA_BIN web --config $GITEA_CONFIG
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
|
||||
# Безопасность
|
||||
CapabilityBoundingSet=CAP_NET_BIND_SERVICE
|
||||
AmbientCapabilities=CAP_NET_BIND_SERVICE
|
||||
NoNewPrivileges=true
|
||||
ProtectSystem=strict
|
||||
ProtectHome=read-only
|
||||
ReadWritePaths=$GITEA_DATA /etc/gitea $GIT_HOME
|
||||
PrivateTmp=true
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
print_success "Systemd unit создан"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# 4.2 Перезагрузка systemd
|
||||
#-------------------------------------------------------------------------------
|
||||
print_subheader "Перезагрузка systemd"
|
||||
|
||||
systemctl daemon-reload
|
||||
print_success "Systemd перезагружен"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# 4.3 Включение автозапуска
|
||||
#-------------------------------------------------------------------------------
|
||||
print_subheader "Включение автозапуска"
|
||||
|
||||
systemctl enable gitea
|
||||
print_success "Автозапуск Gitea включён"
|
||||
|
||||
print_success "Шаг 4 завершён: Systemd unit создан"
|
||||
Reference in New Issue
Block a user