#!/bin/sh
-#shuber, 2008-10-18
+# Copyright (c) 2013 Stefan Huber
#
-# This script does a decrypt-edit-encrypt cycle with gpg and OpenOffice.
-# The concrete editing program (ooffice) can be set by the variable
-# $CMD. The detection if the file has been altered is done by a hash sum
-# algorithm which can be set by $SUMCMD.
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use,
+# copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following
+# conditions:
#
-# Changelog:
-# * 2008-10-18 Initial version
-# * 2008-10-19 Introducing a CRYPTID variable
-# Checking if crypted file has same checksum
-# * 2010-10-23 ooffice only spawns OpenOffice and gives control back
-# to shell. Hence, we have to wait for pid now.
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+
+# Author: Stefan Huber <shuber@sthu.org>
+
+#
+# This script does a decrypt-edit-encrypt cycle with gpg and OpenOffice resp.
+# LibreOffice files.
-CMD="libreoffice"
SUMCMD="sha1sum"
-CRYPTID="user@example.org"
+CRYPTID=""
+CMD="/usr/bin/libreoffice"
+[ -x ${CMD} ] || CMD="/usr/bin/ooffice"
+
+[ -f "$HOME/.office-gpg.cfg" ] && source "$HOME/.office-gpg.cfg"
+
+if [ -z "$CRYPTID" ]; then
+ echo "No CRYPTID set in $HOME/.office-gpg.cfg"
+ exit 1
+fi
#No valid invocation
if [ $# -ne 1 ]