Update devops stuff

This commit is contained in:
Marian Steinbach 2019-05-05 22:42:48 +02:00
parent 9f7efddc61
commit c41e717d3d
3 changed files with 62 additions and 0 deletions

View file

@ -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]
```

14
devops/functions.bash Normal file
View file

@ -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')
}

16
devops/ssh.sh Executable file
View file

@ -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}