From 705b5276388de82c00f223cfa05ccedcec19b48e Mon Sep 17 00:00:00 2001 From: malmert Date: Sat, 22 Nov 2025 14:09:25 +0100 Subject: [PATCH] add setup script --- setup_build_server.sh | 80 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 setup_build_server.sh diff --git a/setup_build_server.sh b/setup_build_server.sh new file mode 100644 index 0000000..270bb0c --- /dev/null +++ b/setup_build_server.sh @@ -0,0 +1,80 @@ +#!/bin/bash +set -e + +# ----------------------------- +# Variablen anpassen +# ----------------------------- +REPO_URL="https://gitea.malmert.de/marcus/mitm-webserver.git" +APP_DIR="/opt/mitm-webserver" +FRONTEND_DIR="$APP_DIR/frontend" +BACKEND_DIR="$APP_DIR/backend" +BACKEND_SERVICE="mitm-backend" +NGINX_SITE="/etc/nginx/sites-available/mitm-webserver" +USER_ROOT="root" + +GITEA_RUNNER_URL="https://gitea.malmert.de//api/v1/repos/marcus/mitm-webserver/actions/runners/register" +RUNNER_TOKEN="Kjwkep8nEQet05z1syzi7FSaZZh1Zt340GdJauNt" +RUNNER_NAME="mitm-runner" + +NODE_VERSION="lts/*" # aktuelle LTS Version +PYTHON_VERSION="3" # aktuelle Python 3 Version + +# ----------------------------- +# System aktualisieren & Pakete installieren +# ----------------------------- +echo "==> Update & Upgrade" +apt update && apt upgrade -y +apt install -y git curl build-essential nginx python3 python3-pip python3-venv unzip wget + +# ----------------------------- +# Node.js installieren (LTS) +# ----------------------------- +echo "==> Install Node.js LTS" +curl -fsSL https://deb.nodesource.com/setup_lts.x | bash - +apt install -y nodejs + +# ----------------------------- +# Repository clonen / pull +# ----------------------------- +echo "==> Setup repository" +if [ ! -d "$APP_DIR" ]; then + git clone "$REPO_URL" "$APP_DIR" +else + cd "$APP_DIR" + git reset --hard + git pull +fi + +# ----------------------------- +# Frontend bauen +# ----------------------------- +echo "==> Build Frontend" +cd "$FRONTEND_DIR" +npm install +npm run build + +# ----------------------------- +# Backend vorbereiten +# ----------------------------- +echo "==> Setup Backend" +cd "$BACKEND_DIR" +python3 -m venv venv +source venv/bin/activate +pip install --upgrade pip +pip install -r requirements.txt +deactivate + +# ----------------------------- +# Systemd Service für Backend +# ----------------------------- +echo "==> Setup Systemd Service" +cat >/etc/systemd/system/$BACKEND_SERVICE.service <