From 0e76e569cf0079e5c1735bc888ffd6b4a298c2c9 Mon Sep 17 00:00:00 2001 From: xeruf <27jf@pm.me> Date: Fri, 21 Jun 2024 17:40:32 +0300 Subject: [PATCH] bin: terminate ssh socket when push-production aborts --- README.md | 3 ++- bin/push-production.sh | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 665b9161..c415de27 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,8 @@ Der Workflow speichert die generierten Seiten im `live` branch des Repositories, welcher nach Benachrichtigung durch einen Webhook von [caddy](./Caddyfile) gepullt wird. Bei Änderungen am Caddyfile oder dem Docker image -muss [push-production.sh](./bin/push-production.sh) mit dem GITHUB_SECRET des Webhooks ausgeführt werden. +muss [push-production.sh](./bin/push-production.sh) mit dem GITHUB_SECRET des Webhooks ausgeführt werden +(bei credential-abfrage beliebigen Text eingeben). Der Docker container lässt sich auch lokal mit [test-production.sh](./bin/test-production.sh) testen, wobei der Caddy Webserver auf port 80 via [localhost](http://localhost) erreichbar wird. diff --git a/bin/push-production.sh b/bin/push-production.sh index 9297bb14..f47b81a9 100755 --- a/bin/push-production.sh +++ b/bin/push-production.sh @@ -5,12 +5,16 @@ port=8200 if test -z "$GITHUB_SECRET"; then echo "No github secret set. Start with GITHUB_SECRET=, or enter below." - LC_ALL=C tr -dc '[:alnum:]' < /dev/urandom | head -c32 | cat - echo "" + #LC_ALL=C tr -dc '[:alnum:]' < /dev/urandom | head -c32 | cat + #echo "" read -r -p 'GitHub secret to use: ' GITHUB_SECRET fi + ssh -M -S /tmp/ssh-ctrl-socket -fnNT -L 5000:localhost:5000 $server +onkill() { ssh -S /tmp/ssh-ctrl-socket -O exit $server; } +trap onkill SIGTERM + ssh -S /tmp/ssh-ctrl-socket -O check $server || exit 1 docker login localhost:5000 || exit 1