X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=btrbk-run;h=7e66bc22335455c9f77c8cd6fae32032372c5330;hb=b311e6f6fa930805674d7d53d67cd033fdbf3367;hp=e30c9c3dd3667d259a46e560773890e3919dd9a9;hpb=f7eaad64a7c5f3bc851f146e1f258d34f398a7d7;p=distro-setup diff --git a/btrbk-run b/btrbk-run index e30c9c3..7e66bc2 100644 --- a/btrbk-run +++ b/btrbk-run @@ -85,6 +85,7 @@ rsync-dirs() { } +pre="${0##*/}:" m() { if $verbose; then printf "$pre %s\n" "$*"; fi; "$@"; } die() { printf "$pre %s\n" "$*" >&2; exit 1; } @@ -116,7 +117,6 @@ if [[ -s $default_args_file ]]; then sleep 5 fi -pre="${0##*/}:" cron=false orig_args=("$@") temp=$(getopt -l cron,pull-reexec,help cl:m:npqs:t:vh "$@") || usage 1 @@ -150,9 +150,18 @@ while true; do esac done -# usefull commands are resume and archive +# only tested commands are resume and archive cmd_arg=${1:-run} +case $cmd_arg in + run|resume|archive) : ;; + *) die "untested command arg" ;; +esac + +if (( $# > 1 )); then + die: "only 1 nonoption arg is supported" +fi + if [[ -v targets && $source ]]; then die "error: -t and -s are mutually exclusive" fi @@ -186,7 +195,9 @@ if [[ ! -v targets && ! $source ]]; then targets=($home kw) ;; tp) - targets=(frodo kd) + # kd disabled temporarily while its hot and i plan to work on it. + #targets=(frodo kd) + targets=(frodo) # might not be connected to the vpn if timeout -s 9 10 ssh kw :; then targets+=(kw) @@ -229,8 +240,17 @@ else # ;; *) prospective_mps=(/a /q) - if [[ $HOSTNAME == "$MAIL_HOST" ]]; then - prospective_mps+=(/o) + if [[ $source ]]; then + source_state="$(ssh $source cat /a/bin/bash_unpublished/source-state)" + eval "$source_state" + source_host="$(ssh $source cat /etc/hostname)" + if [[ $source_host == "$MAIL_HOST" ]]; then + prospective_mps+=(/o) + fi + else + if [[ $HOSTNAME == "$MAIL_HOST" ]]; then + prospective_mps+=(/o) + fi fi ;; esac @@ -247,7 +267,14 @@ fi echo "mountpoints: ${mountpoints[*]}" +##### end command line parsing ######## +if [[ $source ]]; then + if [[ $(ssh $source systemctl is-active btrbk.service) != inactive ]]; then + echo "$0: error: cron btrbk is running on source. exiting out of caution" + exit 1 + fi +fi # pull_reexec stops us from getting into an infinite loop if there is some # kind of weird problem @@ -270,7 +297,6 @@ if ! $pull_reexec && [[ $source ]] && $pulla ; then fi -##### end command line parsing ########