Created
July 6, 2018 06:50
-
-
Save dwdraju/7bc3bb353cfff7928e41ce05d7a68c77 to your computer and use it in GitHub Desktop.
git pull sync
This file contains hidden or 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 | |
| LOCKFILE=/home/ubuntu/docker.lock | |
| if [ -e ${LOCKFILE} ] && kill -0 `cat ${LOCKFILE}`; then | |
| echo "already running" | |
| exit | |
| fi | |
| # make sure the lockfile is removed when we exit and then claim it | |
| trap "rm -f ${LOCKFILE}; exit" INT TERM EXIT | |
| echo $$ > ${LOCKFILE} | |
| #do git pull | |
| cd /home/ubuntu/[git-folder] | |
| git pull | |
| sleep 1s | |
| rm -f ${LOCKFILE} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment