Skip to content

Instantly share code, notes, and snippets.

@madblobfish
Created June 23, 2017 08:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madblobfish/70a2515e6b8d57eb3ae1e299b6e6be73 to your computer and use it in GitHub Desktop.
Save madblobfish/70a2515e6b8d57eb3ae1e299b6e6be73 to your computer and use it in GitHub Desktop.
Systemd service file to pull a git repositoy when recieveing tcp packets (webhook)
[Unit]
Description=Autopull through webhook
After=network.target
[Service]
User=<user>
Type=simple
Environment="GITPATH=%h/somegitfolder/"
Environment="PORT=9999"
Environment="LOGFILE=%h/.gitpull.log"
ExecStart=/bin/bash -xc 'echo -e "HTTP/1.1 204 No Content\\r\\nConnection: close\\r\\n\\r" | nc -l 0.0.0.0 -p ${PORT} | base64 | paste -d' ' <(date +%Y-%m-%dT%H:%M:%S) - >> ${LOGFILE}; cd ${GITPATH}; git pull'
Restart=always
StartLimitInterval=1min
StartLimitBurst=60
[Install]
WantedBy=multi-user.target
# adapted from http://chrisberkhout.com/blog/simple-webhook/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment