replace per-app deploy scripts with generic deploy.sh

Dispatch now validates the command format and routes to a single
deploy.sh that handles any app. This fixes first-deploy failures
for new apps (dispatch no longer needs a static case list) and
simplifies new-app.sh (no deploy script or dispatch update needed).

Also adds input validation to new-app.sh, set -euo pipefail to
deploy scripts, and dnf module reset before nodejs install.
This commit is contained in:
2026-03-13 17:00:59 -04:00
parent 587b671e61
commit 7d5f0920b7
7 changed files with 35 additions and 41 deletions
+6 -9
View File
@@ -1,12 +1,9 @@
#!/bin/bash
set -euo pipefail
case "$SSH_ORIGINAL_COMMAND" in
deploy-nginx) sudo /opt/hantim/scripts/deploy-nginx.sh ;;
deploy-timothykim) sudo /opt/hantim/scripts/deploy-timothykim.sh ;;
*)
echo "Unknown command: $SSH_ORIGINAL_COMMAND"
echo "Available: deploy-nginx, deploy-timothykim"
exit 1
;;
esac
if [[ "$SSH_ORIGINAL_COMMAND" =~ ^deploy-[a-zA-Z0-9._-]+$ ]]; then
sudo /opt/hantim/scripts/deploy.sh "$SSH_ORIGINAL_COMMAND"
else
echo "Unknown command: $SSH_ORIGINAL_COMMAND"
exit 1
fi
-2
View File
@@ -1,2 +0,0 @@
#!/bin/bash
cd /opt/hantim && git pull && cd docker/nginx && docker compose pull && docker compose up -d
-2
View File
@@ -1,2 +0,0 @@
#!/bin/bash
cd /opt/hantim && git pull && cd docker/timothykim.net && docker compose pull && docker compose up -d
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
set -euo pipefail
APP="${1#deploy-}"
cd /opt/hantim
git pull
cd "docker/$APP"
docker compose pull
docker compose up -d
+6 -13
View File
@@ -8,6 +8,12 @@ if [ -z "${1:-}" ]; then
fi
APP="$1"
if ! [[ "$APP" =~ ^[a-zA-Z0-9][a-zA-Z0-9._-]*$ ]]; then
echo "Error: app name must be alphanumeric (hyphens, dots, underscores allowed)."
exit 1
fi
REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
if [ -d "$REPO_ROOT/docker/$APP" ]; then
@@ -30,17 +36,6 @@ networks:
external: true
EOF
echo "Creating scripts/deploy-$APP.sh..."
cat > "$REPO_ROOT/scripts/deploy-$APP.sh" <<EOF
#!/bin/bash
cd /opt/hantim && git pull && cd docker/$APP && docker compose pull && docker compose up -d
EOF
chmod +x "$REPO_ROOT/scripts/deploy-$APP.sh"
echo "Adding $APP to deploy-dispatch.sh..."
sed -i "/^ \*)$/i\\ deploy-$APP) sudo /opt/hantim/scripts/deploy-$APP.sh ;;" \
"$REPO_ROOT/scripts/deploy-dispatch.sh"
echo "Creating .gitea/workflows/deploy-$APP.yml..."
mkdir -p "$REPO_ROOT/.gitea/workflows"
cat > "$REPO_ROOT/.gitea/workflows/deploy-$APP.yml" <<'OUTER'
@@ -69,9 +64,7 @@ sed -i "s/APP_PLACEHOLDER/$APP/g" "$REPO_ROOT/.gitea/workflows/deploy-$APP.yml"
echo ""
echo "Done! Files created:"
echo " - docker/$APP/compose.yml"
echo " - scripts/deploy-$APP.sh"
echo " - .gitea/workflows/deploy-$APP.yml"
echo " - Updated scripts/deploy-dispatch.sh"
echo ""
echo "Next steps:"
echo " 1. Edit docker/$APP/compose.yml to fit your app"