###----- 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
+: ${ETC=@pkgconfdir@}
+: ${KEYS=@pkgstatedir@}
+: ${KEYSLIB=@pkgdatadir@}
+export ETC KEYS KEYSLIB
-quis=${0##*/}
-PACKAGE=@PACKAGE@
-VERSION=@VERSION@
-
-: ${KEYS=@pkgconfdir@}
-: ${KEYSLIB=@pkglibdir@}
-export KEYS KEYSLIB
-
-###--------------------------------------------------------------------------
-### Help.
-
-usage="usage: $quis COMMAND [ARGUMENTS ...]"
-
-version () {
- echo "$PACKAGE version $VERSION"
-}
+. "$KEYSLIB"/keyfunc.sh
-help () {
- rc=0
- version
- case $# in
- 0)
- cat <<EOF
+usage="COMMAND [ARGUMENTS ...]"
+prefix=keys
-$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.
+runas @user@ keys "$@"
+## 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 --------------------------------------------------