at_work=false
at_home=false
+set-location
# set default targets
if [[ ! -v targets && ! $source ]]; then
exit-if-no-default-targets
- set-location
if $at_home; then
if ! $kd_spread && [[ $HOSTNAME != x3 ]]; then
add-x3-target
*)
prospective_mps=()
if [[ $source ]]; then
- source_state="$(ssh $source 'cat /a/bin/bash_unpublished/source-state; echo source_host=$HOSTNAME')"
+ source_state="$(ssh root@$source 'cat /a/bin/bash_unpublished/source-state; echo source_host=$HOSTNAME')"
eval "$source_state"
# shellcheck disable=SC2154 # assigned in the above eval.
if [[ $source_host == "$MAIL_HOST" ]]; then
# todo: this has a timing problem, since btrbk.timer could activate the service after this check.
if ! $fast && [[ $source ]]; then
- if [[ $(ssh $source ps --no-headers -o comm 1) == systemd ]]; then
- status=$(ssh $source systemctl is-active btrbk.service) || : # normally returns 3
+ if [[ $(ssh root@$source ps --no-headers -o comm 1) == systemd ]]; then
+ status=$(ssh root@$source systemctl is-active btrbk.service) || : # normally returns 3
case $status in
inactive|failed) : ;;
*)
locked=false
# note Invalid MIT-MAGIC-COOKIE-1 keyxscreensaver-command: can't open display :0 is expected if
# the system is locked by greeter.
- if lock_info=$($ssh_timeout ssh $h DISPLAY=:0 xscreensaver-command -time); then
+ if lock_info=$($ssh_timeout ssh $h DISPLAY=:0 xscreensaver-command -time 2>/dev/null); then
if [[ $lock_info != *non-blanked* ]]; then
locked=true
fi
if [[ $ret == 0 ]]; then
for tg in ${targets[@]}; do
# todo: get this in ssh_info, less sshing is faster.
- h=$(ssh $tg hostname)
- remote_snaps=$(ssh root@$tg "shopt -s nullglob; echo $snap_list_glob")
+ tmpstr=$(ssh root@$tg "shopt -s nullglob; hostname; echo $snap_list_glob")
+ {
+ read -r h
+ read -r remote_snaps
+ } <<<"$tmpstr"
# a check like this will catch the situation we aim to prevent by running purge
if [[ $local_snaps != "$remote_snaps" ]]; then
localtmp=$(mktemp)
rm $localtmp $remotetmp
ret=1
fi
- if $laptop && ! $at_home && [[ $h == $d_host && $HOSTNAME == "$MAIL_HOST" ]]; then
+ if $laptop && ! $at_home && [[ $h == "$d_host" && $HOSTNAME == "$MAIL_HOST" ]]; then
d ssh root@$tg 'btrbk-spread-wrap &>/dev/null </dev/null &'
fi
cmd=/usr/local/bin/mail-backup-clean