Skip to content

Instantly share code, notes, and snippets.

@sheerun
Last active April 25, 2017 15:58
Show Gist options
  • Save sheerun/20d71ae5059f663100dbefc3eb7bf2f4 to your computer and use it in GitHub Desktop.
Save sheerun/20d71ae5059f663100dbefc3eb7bf2f4 to your computer and use it in GitHub Desktop.
#!/bin/bash
export NAME=ghost
export [email protected]
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