#! /bin/sh ### ### Front-end dispatch for key-management scripts ### ### (c) 2011 Mark Wooding ### ###----- Licensing notice --------------------------------------------------- ### ### 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 2 of the License, 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, 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@} : ${KEYSLIB=@pkglibdir@} export KEYS KEYSLIB ###-------------------------------------------------------------------------- ### Help. usage="usage: $quis COMMAND [ARGUMENTS ...]" version () { echo "$PACKAGE version $VERSION" } help () { rc=0 version case $# in 0) cat <&2 "$quis: unrecognized command \`$i'" rc=1 continue elif ! KEYS_HELP=t "$KEYSLIB"/"$i"; then rc=1 fi done ;; esac return $rc } ###-------------------------------------------------------------------------- ### Command dispatch. while getopts "hv" opt; do case "$opt" in h) help; exit ;; v) version; exit ;; *) echo >&2 "$usage"; exit 1 ;; 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 unset KEYS_HELP exec "$KEYSLIB"/"$cmd" "$@" ###----- That's all, folks --------------------------------------------------