. lib/path_tmp_timestamped
BIN_NAME="$(basename $0)"
-CMD_CLAIM=claim
-CMD_HELP=help
-CMD_KEYS=keys
-CMD_ORGPULL=orgpull
PATH_BORG_CONF_SECURITY="${PATH_BORG_CONF}/security"
PATH_BORG_CONF_KEYS="${PATH_BORG_CONF}/keys"
echo "Usage: ${BIN_NAME} COMMAND"
echo "Wrapper around certain borgbackup usages.\n"
echo "Available commands:\n"
- echo " ${CMD_CLAIM} PATH register file of PATH as key to repo at \"$(location_from_servername SERVERNAME)\", with SERVERNAME the filename portion of PATH"
- echo " ${CMD_HELP} print this help and exit"
- echo " ${CMD_KEYS} list known repos in ID, key filename, and alleged location"
- echo " ${CMD_ORGPULL} pull most recent org directory available in repos"
+ echo " claim PATH register file of PATH as key to repo at \"$(location_from_servername SERVERNAME)\", with SERVERNAME the filename portion of PATH"
+ echo " help print this help and exit"
+ echo " keys list known repos in ID, key filename, and alleged location"
+ echo " orgpull pull most recent org directory available in repos"
}
# exits
}
# commands
+COMMANDS='claim help keys orgpull'
_check_args_beyond() {
_N_MAX_ARGS="$1"
fi
}
-CMD__claim() {
+cmd_claim() {
_check_args_beyond 1 "$@"
_PATH_SOURCE="$1"
_ensure_no_overwrite_at() {
chmod u+rw "${_PATH_TARGET_KEY}" "${_PATH_TARGET_LOCATION}"
}
-CMD__help() {
+cmd_help() {
_check_args_beyond 0 "$@"
_print_usage
}
-CMD__keys() {
+cmd_keys() {
_check_args_beyond 0 "$@"
_exit_ok() {
echo "(none, since directory ${1})"
done
}
-CMD__orgpull() {
+cmd_orgpull() {
_check_args_beyond 0 "$@"
_NAME_ARCHIVE=orgdir
if [ "$#" -lt 1 ]; then
error_exit_with_usage "missing command."
fi
-CMD_FUNC="CMD__$1"
-set +e
-type "${CMD_FUNC}" > /dev/null 2>&1
-RESULT="$?"
-set -e
-if [ ! "${RESULT}" = 0 ]; then
+for CMD in COMMANDS; do
+ if [ "$1" = "${CMD}" ]; then
+ break
+ fi
+done
+if [ -z "${CMD}" ]; then
error_exit_with_usage "unknown command: ${1}"
fi
shift 1
-"${CMD_FUNC}" $@
+"cmd_$1"