#!/bin/bash set -euo pipefail sudo apt update -y sudo apt install -y postgresql # 创建用户(带存在判断) sudo -u postgres psql < /etc/systemd/system/gitea.service << EOF [Unit] Description=Gitea (Git with a cup of tea) After=syslog.target After=network.target [Service] User=gitea Group=gitea WorkingDirectory=/var/lib/gitea/ ExecStart=/usr/local/bin/gitea web --config /var/lib/gitea/custom/conf/app.ini Restart=always Environment=USER=gitea HOME=/home/gitea [Install] WantedBy=multi-user.target EOF' sudo systemctl daemon-reload sudo systemctl start gitea sudo systemctl enable gitea sudo systemctl status gitea echo "ok"