Skip to content

Instantly share code, notes, and snippets.

@devm33
Last active October 11, 2017 00:04
Show Gist options
  • Save devm33/f04564507762a3a0e8380c5b1e145876 to your computer and use it in GitHub Desktop.
Save devm33/f04564507762a3a0e8380c5b1e145876 to your computer and use it in GitHub Desktop.
Monitor directory for deletion and then push.
[program:gitpush]
command=/home/devm33/gitpush.sh
autostart=true
autorestart=true
startretries=3
stderr_logfile=/var/log/gitpush.err.log
stdout_logfile=/var/log/gitpush.out.log
user=devm33
#!/bin/bash
DELDIR='/var/www/html/wp-content/plugins/simply-static/static-files/'
cd /var/www/static
# git needs $HOME - supervisor doesnt supply it
export HOME=/home/devm33
echo "Started monitoring $(date)"
while inotifywait -q -e delete_self $DELDIR; do
echo "Triggered $(date) $DELETED, waiting before running git"
sleep 3
git add -A && git commit -am "Auto commit $(date)" && git push origin master && echo "Success"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment