Create deploy script - close #8

This commit is contained in:
Kegan Myers 2023-06-16 09:51:01 -05:00
parent d71811068e
commit 8221bc2bb2

25
announcer/deploy.sh Executable file
View file

@ -0,0 +1,25 @@
#!/bin/bash
set -Eeuxo pipefail
for HOST in "$@"; do
# copy files to target server
scp ./unhinged-traefik-announcer ${HOST}:unhinged-traefik-announcer.tmp
scp ./unhinged-traefik-announcer.service ${HOST}:unhinged-traefik-announcer.service.tmp
# set permissions of files on remote server
ssh ${HOST} chmod 755 unhinged-traefik-announcer.tmp
ssh ${HOST} chmod 644 unhinged-traefik-announcer.service.tmp
# update the unit and reload systemd
ssh ${HOST} mv unhinged-traefik-announcer.service.tmp unhinged-traefik-announcer.service
ssh ${HOST} systemctl daemon-reload
# restart the service after updating the binary
ssh ${HOST} systemctl stop unhinged-traefik-announcer
ssh ${HOST} mv unhinged-traefik-announcer.tmp /usr/local/bin/unhinged-traefik-announcer
ssh ${HOST} systemctl enable unhinged-traefik-announcer
ssh ${HOST} systemctl start unhinged-traefik-announcer
# make sure things are ok
sleep 1
ssh ${HOST} systemctl status unhinged-traefik-announcer
done