From 979633675677e621531107826ffccbd830ec6442 Mon Sep 17 00:00:00 2001 From: malmert Date: Sat, 22 Nov 2025 14:25:35 +0100 Subject: [PATCH] setup script update --- setup_build_server.sh | 103 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 102 insertions(+), 1 deletion(-) diff --git a/setup_build_server.sh b/setup_build_server.sh index 270bb0c..c10fc1a 100644 --- a/setup_build_server.sh +++ b/setup_build_server.sh @@ -77,4 +77,105 @@ After=network.target User=$USER_ROOT WorkingDirectory=$BACKEND_DIR ExecStart=$BACKEND_DIR/venv/bin/uvicorn src.main:app --host 0.0.0.0 --port 8000 -Restar +Restart=always + +[Install] +WantedBy=multi-user.target +EOL + +systemctl daemon-reload +systemctl enable $BACKEND_SERVICE +systemctl restart $BACKEND_SERVICE + +# ----------------------------- +# Nginx Setup +# ----------------------------- +echo "==> Configure Nginx" +cat >$NGINX_SITE < Install Gitea Runner" +RUNNER_DIR="/opt/gitea-runner" +mkdir -p $RUNNER_DIR +cd $RUNNER_DIR + +# Download aktueller gitea-runner (Linux x64) +GITEA_RUNNER_BIN="actions-runner-linux-x64-2.305.0.tar.gz" +wget -O $GITEA_RUNNER_BIN "https://dl.gitea.io/gitea/runner/latest/actions-runner-linux-x64.tar.gz" +tar xzf $GITEA_RUNNER_BIN +rm $GITEA_RUNNER_BIN + +# Runner konfigurieren +./config.sh --url "https://gitea.malmert.de/marcus/mitm-webserver" --token $RUNNER_TOKEN --name $RUNNER_NAME --unattended --replace + +# Systemd Service für Runner +./svc.sh install +./svc.sh start + +# ----------------------------- +# Gitea Runner Job Script +# ----------------------------- +echo "==> Setup auto-build script" +BUILD_SCRIPT="$RUNNER_DIR/build.sh" +cat >$BUILD_SCRIPT <<'EOL' +#!/bin/bash +set -e + +APP_DIR="/opt/mitm-webserver" +FRONTEND_DIR="$APP_DIR/frontend" +BACKEND_DIR="$APP_DIR/backend" +BACKEND_SERVICE="mitm-backend" + +cd $APP_DIR +git reset --hard +git pull + +# Build Frontend +cd $FRONTEND_DIR +npm install +npm run build + +# Backend Dependencies +cd $BACKEND_DIR +source venv/bin/activate +pip install -r requirements.txt +deactivate + +# Restart backend +systemctl restart $BACKEND_SERVICE +EOL + +chmod +x $BUILD_SCRIPT + +echo "==> Setup complete! Gitea Runner will automatically build on push." +echo "Frontend: http:///" +echo "Backend API: http:///api/"