From 3b2b3507e591c50b19caa22f75915059f2db1db2 Mon Sep 17 00:00:00 2001 From: Shivering Ocelot Date: Sun, 30 Aug 2026 17:33:31 -0500 Subject: [PATCH] deployment files and script --- deploy/run.sh | 93 +++++++++++++++++++++++++++++++++ deploy/template/launch-hub.sh | 8 +++ deploy/template/nginx.conf | 29 ++++++++++ deploy/template/systemd.service | 11 ++++ 4 files changed, 141 insertions(+) create mode 100644 deploy/run.sh create mode 100644 deploy/template/launch-hub.sh create mode 100644 deploy/template/nginx.conf create mode 100644 deploy/template/systemd.service diff --git a/deploy/run.sh b/deploy/run.sh new file mode 100644 index 0000000..1007072 --- /dev/null +++ b/deploy/run.sh @@ -0,0 +1,93 @@ +#!/bin/bash +set -euo pipefail +cd "$(dirname "$0")" + +host="root@hub.hordelab.com" + +run_nginx() { + echo "Uploading nginx config file" + scp template/nginx.conf "$host:/etc/nginx/sites-enabled/hub.hordelab.com" + ssh "$host" -t " + nginx -s reload + + # full process is currently broken + #certbot --keep -d hub.hordelab.com + + # uncomment if needed + #certbot certonly -d hub.hordelab.com + + #nginx -s reload + " +} + +run_service() { + echo "Uploading Launcher and Service" + scp template/launch-hub.sh "$host:/var/horde/launch-hub.sh" + scp template/systemd.service "$host:/etc/systemd/system/horde-hub.service" + ssh "$host" -t " + systemctl daemon-reload + systemctl enable horde-hub.service + systemctl start horde-hub.service + " +} + +run_update() { + echo "Updating repository" + ssh "$host" -t " + source ~/.nvm/nvm.sh #? + + cd /var/horde/hub + git pull + make install + " +} + +restart_service() { + echo "Restarting horde-hub.service" + ssh "$host" -t "systemctl restart horde-hub.service" +} + +# Determine which stages to run +stages=() +if [[ $# -eq 0 ]]; then + # Interactive prompts when no arguments are given + read -p "Run nginx deployment? [Y/n] " choice + if [[ -z "$choice" || "$choice" =~ ^[Yy]$ ]]; then + stages+=(nginx) + fi + + read -p "Run service deployment? [Y/n] " choice + if [[ -z "$choice" || "$choice" =~ ^[Yy]$ ]]; then + stages+=(service) + fi + + read -p "Run update (git pull + make install)? [Y/n] " choice + if [[ -z "$choice" || "$choice" =~ ^[Yy]$ ]]; then + stages+=(update) + fi +else + # Parse arguments + for arg in "$@"; do + case "$arg" in + nginx|service|update) + stages+=("$arg") + ;; + *) + echo "Unknown argument: $arg" >&2 + exit 1 + ;; + esac + done +fi + +# Execute selected stages +for stage in "${stages[@]}"; do + case "$stage" in + nginx) run_nginx ;; + service) run_service ;; + update) run_update ;; + esac +done + +# Final stage: always restart the systemd service at the end +restart_service \ No newline at end of file diff --git a/deploy/template/launch-hub.sh b/deploy/template/launch-hub.sh new file mode 100644 index 0000000..4a17ad7 --- /dev/null +++ b/deploy/template/launch-hub.sh @@ -0,0 +1,8 @@ + +export OPENAI_API_KEY=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 +export REPLICATE_API_KEY=r8_J1lnphqfZNUtK9CIh81SE4uHWWKJuvR3tr8S2 +export OPENROUTER_API_KEY=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 +export HORDE_DATA_DIR=/var/horde/hub-data + +echo Starting Horde Server +/var/horde/hub/.venv/bin/python3 /var/horde/hub/backend/src/app.py \ No newline at end of file diff --git a/deploy/template/nginx.conf b/deploy/template/nginx.conf new file mode 100644 index 0000000..c601eb1 --- /dev/null +++ b/deploy/template/nginx.conf @@ -0,0 +1,29 @@ +# Only describe the http server, certbot will install https for us +server { + listen 80; + listen [::]:80; + server_name hub.hordelab.com; + + return 301 https://$host$request_uri; +} + + +server { + listen 443 ssl; + listen [::]:443 ssl; + + server_name hub.hordelab.com; + + ssl_certificate /etc/letsencrypt/live/hub.hordelab.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/hub.hordelab.com/privkey.pem; + + location / { + proxy_pass http://localhost:5000; + proxy_http_version 1.1; + + # Websocket support + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + } +} diff --git a/deploy/template/systemd.service b/deploy/template/systemd.service new file mode 100644 index 0000000..4a9bfaa --- /dev/null +++ b/deploy/template/systemd.service @@ -0,0 +1,11 @@ +[Unit] +Description=Horde Hub +After=network.target + +[Service] +Type=simple +Restart=always +ExecStart=bash /var/horde/launch-hub.sh + +[Install] +WantedBy=multi-user.target