[Unit] Description=画个标 Gitea Webhook 自动部署 After=network.target [Service] Type=simple User=ubuntu ExecStart=/usr/bin/python3 -c " import http.server, subprocess, json class H(http.server.BaseHTTPRequestHandler): def do_POST(self): length = int(self.headers.get('Content-Length', 0)) body = self.rfile.read(length) try: data = json.loads(body) if body else {} ref = data.get('ref', '') if ref == 'refs/heads/main': subprocess.Popen(['/bin/bash', '/opt/drawlogo/deploy/deploy.sh'], stdout=open('/opt/drawlogo/.deploy.log', 'a'), stderr=subprocess.STDOUT) except Exception as e: pass self.send_response(200) self.end_headers() self.wfile.write(b'ok') def log_message(self, format, *args): pass http.server.HTTPServer(('127.0.0.1', 7890), H).serve_forever() " Restart=always RestartSec=5 [Install] WantedBy=multi-user.target