This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
export NAME=ghost | |
export TARGET=root@1.2.3.4 | |
export SERVICE=$(mktemp) | |
cat > $SERVICE <<EOF | |
[Unit] | |
Description=Ghost | |
After=docker.service | |
Requires=docker.service | |
[Service] | |
TimeoutStartSec=0 | |
Restart=always | |
ExecStartPre=-/usr/bin/docker stop ghost | |
ExecStartPre=-/usr/bin/docker rm ghost | |
ExecStartPre=/usr/bin/docker pull ghost:latest | |
ExecStart=/usr/bin/docker run --rm --name ghost -p 80:2368 ghost | |
[Install] | |
WantedBy=multi-user.target | |
EOF | |
echo "Uploading $NAME service..." | |
rsync $SERVICE $TARGET:/etc/systemd/system/$NAME.service | |
echo "Restarting $NAME service..." | |
ssh $TARGET "systemctl daemon-reload && systemctl restart ghost --no-block" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment