From 63196d6d10cdc764c48efb8c0ae034b829a44e6b Mon Sep 17 00:00:00 2001 From: "Bradley M. Kuhn" Date: Sat, 30 Nov 2013 14:59:08 -0500 Subject: [PATCH] Script to run calendar and handle git details. --- calendar-run.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100755 calendar-run.sh diff --git a/calendar-run.sh b/calendar-run.sh new file mode 100755 index 0000000..002f201 --- /dev/null +++ b/calendar-run.sh @@ -0,0 +1,68 @@ +#!/bin/bash +# Copyright (C) 2013 Bradley M. Kuhn +# +# The copyright holders wish that this script could be placed into the public +# domain. However, should such a public domain dedication not be possible, +# the copyright holders grant a waiver and/or license under the terms of +# CC0-1.0, as published by Creative Commons, Inc. A copy of CC0-1.0 can be +# found in the same repository as this README.md file under the filename +# CC0-1.0.txt. If this document has been separated from the repository, a +# copy of CC0-1.0 can be found on Creative Commons' website at: +# http://creativecommons.org/publicdomain/zero/1.0/legalcode + +/usr/bin/lockfile -r 8 ~/.running-calendar + +remove_lock() { + /bin/rm -f ~/.running-calendar +} +# It's a TRAP!!! +trap remove_lock INT TERM EXIT + +set -e + +HOME_MACHINE=baptist.ebb.org + +~/hacks/Small-Hacks/calendar-export.plx ~/Public-Configuration/calendar-export-home.config + +cd ~/calendars + +cd ~/calendars/personal/private/bkuhn + +git checkout -q master +/usr/bin/rsync -q --exclude .git --delete -Hav ~/calendars/staging/personal/ ~/calendars/personal/private/bkuhn/ +/usr/bin/git add . + +set +e +/usr/bin/git commit -a -m'Automated calendar import from Emacs diary' > /dev/null +set -e +/usr/bin/git status > /dev/null + +# Make sure machine is up. set -e will ensure that. +/bin/ping -q -w 20 -c 5 $HOME_MACHINE > /dev/null 2>&1 + +cd ~/calendars/personal/private/bkuhn +git push -q ${HOME_MACHINE} master +git checkout -q webdav +git pull -q ${HOME_MACHINE} webdav + +~/hacks/Small-Hacks/calendar-import.plx ~/Public-Configuration/calendar-export-home.config + +git checkout -q master +git merge -q webdav -m'Automated merge from webdav branch' + +if [ ! -z "$WORK_MACHINE" ]; then + ~/hacks/Small-Hacks/calendar-export.plx ~/Public-Configuration/calendar-export-work.config + + cd ~/calendars/work/public/bkuhn + + /usr/bin/git checkout master + /usr/bin/rsync -q --exclude .git --delete -Hav ~/calendars/staging/work/ ~/calendars/work/private/bkuhn/ + /usr/bin/git commit -a -m'Automated calendar import from Emacs diary' + + # Make sure machine is up. set -e will ensure that. + /bin/ping -q -w 20 -c 5 $WORK_MACHINE > /dev/null 2>&1 + cd ~/calendars/work/public/bkuhn + git push ${WORK_MACHINE} master +fi + +remove_lock