echo " ${CMD_ORGPULL} pull most recent org directory available in repos"
}
+# exits
+
error_exit() {
echo "${PREFIX_ABORTING}$1"
exit 1
exit 1
}
-check_args_beyond() {
- _CMD="$1"
- shift 1
- if [ "$#" -gt 0 ]; then
- _MSG="unexpected arguments beyond command '${_CMD}': $@"
- error_exit "${_MSG}"
- fi
-}
+# commands beyond print_usage
-_path_repo_location() {
- echo "${PATH_BORG_CONF_SECURITY}/${1}/location"
-}
+_path_repo_location() { echo "${PATH_BORG_CONF_SECURITY}/${1}/location" }
cmd_keys() {
_PATH_CONF_KEYS="${PATH_BORG_CONF}/keys"
- echo "Known keys as per ${PATH_BORG_CONF}:"
- if [ ! -d "${_PATH_CONF_KEYS}" ]; then
- echo "(none, since no ${_PATH_CONF_KEYS})"
+ _exit_ok() {
+ echo "(none, since directory ${1}."
exit 0
+ }
+ echo "Known keys, as per ${_PATH_BORG_CONF_KEYS}:"
+ if [ ! -d "${_PATH_CONF_KEYS}" ]; then
+ exit_ok "non-existant"
fi
_KEYFILES="$(ls -1 ${_PATH_CONF_KEYS})"
if [ -z "${_KEYFILES}" ]; then
- echo "(none, directory empty)"
- exit 0
+ exit_ok "empty"
fi
echo "${_KEYFILES}" | while read _FILENAME; do
_KEY_ID=$(head -1 "${_PATH_CONF_KEYS}/${_FILENAME}" | cut -d' ' -f2)
- _LOCATION=?
+ printf "${KEY_ID} ${_FILENAME} "
_PATH_LOC="$(cat $(_path_repo_location ${_KEY_ID}))"
if [ -f "${_PATH_LOC}" ]; then
- _LOCATION="$(cat ${_PATH_LOC})"
+ printf '%s\n' "$(cat ${_PATH_LOC})"
+ else
+ printf '?\n'
fi
- echo "${_KEY_ID} ${_FILENAME} ${_LOCATION}"
done
}
borg extract --verbose "${_REPO}::${_ARCHIVE}"
}
+# parse args to execution
+
+check_args_beyond() {
+ _CMD="$1"
+ shift 1
+ if [ "$#" -gt 0 ]; then
+ _MSG="unexpected arguments beyond command '${_CMD}': $@"
+ error_exit "${_MSG}"
+ fi
+}
+
if [ "$#" -lt 1 ]; then
error_exit_with_usage "missing command."
elif [ "$1" = "${CMD_HELP}" ]; then