Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 45 lines (36 sloc) 1.03 KB
#!/bin/bash
set -e -f -u -o pipefail
# shellcheck disable=SC1090
source "${HOME}/bin/backup-to-rsync-net-lib"
usage() {
printf "Usage: %s [--test-keys-only]\\n" "$0"
}
main() {
local test_keys_only=0
if [[ "$#" -eq 1 && "$1" == "--test-keys-only" ]]; then
test_keys_only=1
shift
fi
if [[ "$#" -ne 0 ]]; then
usage
return 1
fi
# This requires that "retrieve" is a symlink to "update".
local hostname_for_key="retrieve" subdir="sentinel"
if ! check_ssh_key_exists --pull "${hostname_for_key}" "${subdir}" \
"${test_keys_only}"; then
return 1
fi
if [[ "${test_keys_only}" -eq 1 ]]; then
return 0
fi
local destdir
destdir="$(mktemp -d -t sentinel.XXXXXXXXXX)"
# I want ${destdir} to be expanded now, because when we exit successfully it
# will be out of scope and cannot be expanded.
# shellcheck disable=SC2064
trap "rm -rf \"${destdir}\"" EXIT
run_rsync --pull "${hostname_for_key}" "${subdir}" "${destdir}"
"${HOME}/bin/check_backup_sentinels" "${destdir}/sentinel"
}
main "$@"
You can’t perform that action at this time.