blob: d9c8459b1f56b65371883a2bbefb94a310556db2 (
plain)
- #!/bin/sh
- #
- # Copyright © 2013 Jonas Smedegaard <dr@jones.dk>
- # Description: render and publish opening hours webpage from RDF data
- #
- # This program is free software; you can redistribute it and/or modify
- # it under the terms of the GNU General Public License as published by
- # the Free Software Foundation; either version 3, or (at your option)
- # any later version.
- #
- # This program is distributed in the hope that it will be useful, but
- # WITHOUT ANY WARRANTY; without even the implied warranty of
- # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- # General Public License for more details.
- #
- # You should have received a copy of the GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- set -e
- # defaults sensible for the author when invoked from project root
- outfile=hours.html
- infiles="data/*/*.ttl data/*/*/*.ttl"
- rsync_credentials=coreander
- rsync_path=/home/jonas/public_websites/data.biks.dk/hours/index.html
- script=bin/rdf2hours
- # make backup of eventual existing output
- if [ -f $outfile~ ]; then
- echo >&2 "ERROR: old tempfile $outfile~ exist!"
- echo >&2 "Check that script isn't already running, remove the file, and try again."
- exit 1
- fi
- echo "Rendering $outfile..."
- $script $infiles > $outfile~
- if [ -f $outfile ]; then
- echo "Comparing $outfile against older version..."
- errorcode=0
- diff -ruN $outfile $outfile~ || errorcode=$?
- case $errorcode in
- 0) echo "No changes from previous version"; rm $outfile~; exit;;
- 1) printf "Above are changes from previous version. ";;
- *) echo >&2 "ERROR: internal diff error!"; exit $errorcode;;
- esac
- fi
- # ask, publish, and update on-disk file for later comparison
- printf "OK to publish (y/N)? "
- read do_update
- case $do_update in
- y|Y)
- echo "Publishing $outfile..."
- rsync -a $outfile~ $rsync_credentials:$rsync_path
- mv -f $outfile~ $outfile
- echo "Done: $outfile published succesfully!"
- ;;
- *)
- rm $outfile~
- echo "Cancelled, as requested."
- exit
- ;;
- esac
|