From c41e717d3d2f617dedd961afec33213855ff69eb Mon Sep 17 00:00:00 2001 From: Marian Steinbach Date: Sun, 5 May 2019 22:42:48 +0200 Subject: [PATCH] Update devops stuff --- devops/README.md | 32 ++++++++++++++++++++++++++++++++ devops/functions.bash | 14 ++++++++++++++ devops/ssh.sh | 16 ++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 devops/functions.bash create mode 100755 devops/ssh.sh diff --git a/devops/README.md b/devops/README.md index e95c92a..747bad2 100644 --- a/devops/README.md +++ b/devops/README.md @@ -39,3 +39,35 @@ devops/run-job.sh screenshotter ```nohighlight devops/deploy-webapp.sh ``` + +## Einloggen per SSH + +``` +export FLOATING_IP=195.201.252.221 # Floating IP im hetzner-Projekt +ssh -o StrictHostKeyChecking=no -q root@$FLOATING_IP +``` + +## LetsEncrypt Zertifikat erneuern + +Hostname: `green-spider.netzbegruenung.de` + +``` +docker-compose stop webapp +docker run -it --rm -p 443:443 -p 80:80 --name certbot \ + -v /etc/letsencrypt:/etc/letsencrypt \ + -v /var/lib/letsencrypt:/var/lib/letsencrypt \ + certbot/certbot certonly --standalone -n --email marian@sendung.de --agree-tos -d green-spider.netzbegruenung.de +docker-compose up -d webapp +``` + +## IPv6 "Floating IP" temporär an Device binden + +``` +sudo ip addr add 2a01:4f8:1c0c:811f::1 dev eth0 +``` + +## curl-Zugriff mittels IPv6 + +``` +curl https://[2a01:4f8:1c0c:811f::1] +``` diff --git a/devops/functions.bash b/devops/functions.bash new file mode 100644 index 0000000..842fa61 --- /dev/null +++ b/devops/functions.bash @@ -0,0 +1,14 @@ +# Gets the IP address with description "webapp" +# and stores it in the $IP_IP variable +function get_ip() +{ + echo "Getting IP address" + + RESPONSE=$(curl -s https://api.hetzner.cloud/v1/floating_ips \ + -H "Content-Type: application/json" \ + -H "Authorization: Bearer $API_TOKEN") + + IP_ID=$(echo $RESPONSE | jq -r '.floating_ips[] | select(.description == "webapp") | select(.type == "ipv4") | .id') + IP_IP=$(echo $RESPONSE | jq -r '.floating_ips[] | select(.description == "webapp") | select(.type == "ipv4") | .ip') +} + diff --git a/devops/ssh.sh b/devops/ssh.sh new file mode 100755 index 0000000..ddba4ce --- /dev/null +++ b/devops/ssh.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +# Log in to webapp server via SSH + +API_TOKEN_SECRET="secrets/hetzner-api-token.sh" +test -f $API_TOKEN_SECRET || { echo >&2 "File $API_TOKEN_SECRET does not exist."; exit 1; } +source $API_TOKEN_SECRET + +source devops/functions.bash + +get_ip + +echo "Use this command for SSH access:" +echo "ssh -o StrictHostKeyChecking=no root@${IP_IP}" + +ssh -o StrictHostKeyChecking=no root@${IP_IP}