chiark / gitweb /
cryptop.public: Don't check an ACL.
[distorted-keys] / keys.in
diff --git a/keys.in b/keys.in
index 357651ff8f7f2a0954c5b7143ffc183f24569ae1..2676d5626f78597287a9e292fcafd83cac46fb17 100755 (executable)
--- a/keys.in
+++ b/keys.in
@@ -7,98 +7,44 @@
 
 ###----- Licensing notice ---------------------------------------------------
 ###
-### This program is free software; you can redistribute it and/or modify
+### This file is part of the distorted.org.uk key management suite.
+###
+### distorted-keys 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 2 of the License, or
 ### (at your option) any later version.
 ###
-### This program is distributed in the hope that it will be useful,
+### distorted-keys 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, write to the Free Software Foundation,
+### along with distorted-keys; if not, write to the Free Software Foundation,
 ### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
 set -e
-
-quis=${0##*/}
-PACKAGE=@PACKAGE@
-VERSION=@VERSION@
-
-: ${KEYS=@pkgconfdir@}
+: ${ETC=@pkgconfdir@}
+: ${KEYS=@pkgstatedir@}
 : ${KEYSLIB=@pkglibdir@}
-export KEYS KEYSLIB
+export ETC KEYS KEYSLIB
 
-###--------------------------------------------------------------------------
-### Help.
+. "$KEYSLIB"/keyfunc.sh
 
 usage="usage: $quis COMMAND [ARGUMENTS ...]"
+prefix=keys
 
-version () {
-  echo "$PACKAGE version $VERSION"
-}
-
-help () {
-  rc=0
-  version
-  case $# in
-    0)
-      cat <<EOF
-
-$usage
-
-Options:
-  -h           Show this help text.
-  -v           Show the program version number.
-
-Commands installed:
-EOF
-      cd "$KEYSLIB"
-      for i in *; do
-       case "$i" in *.*) continue ;; esac
-       if [ ! -x "$i" ]; then continue; fi
-       sed -n "/<<HELP/{n;s/^/ $i /;p;q;}" "$i"
-      done
-      ;;
-    *)
-      for i in "$@"; do
-       echo
-       if [ ! -x "$KEYSLIB"/"$i" ]; then
-         echo >&2 "$quis: unrecognized command \`$i'"
-         rc=1
-         continue
-       elif ! KEYS_HELP=t "$KEYSLIB"/"$i"; then
-         rc=1
-       fi
-      done
-      ;;
-  esac
-  return $rc
-}
-
-###--------------------------------------------------------------------------
-### Command dispatch.
-
+## Parse options.
 while getopts "hv" opt; do
   case "$opt" in
-    h) help; exit ;;
+    h) cmd_help; exit ;;
     v) version; exit ;;
-    *) echo >&2 "$usage"; exit 1 ;;
+    *) usage_err ;;
   esac
 done
-shift $((OPTIND - 1))
-
-case $# in 0) echo >&2 "$usage"; exit 1 ;; esac
-cmd=$1; shift
-case "$cmd" in help) help "$@"; exit ;; esac
-if [ ! -x "$KEYSLIB"/"$cmd" ]; then
-  echo >&2 "$quis: unrecognized command \`$cmd'"
-  exit 1
-fi
+shift $(( $OPTIND - 1 ))
 
-unset KEYS_HELP
-exec "$KEYSLIB"/"$cmd" "$@"
+## Dispatch.
+dispatch "$@"
 
 ###----- That's all, folks --------------------------------------------------