#### begin pre-checks #####
+# when we are on a plane, ping 800, wait a log longer.
+if ! pingms=$(ping -c2 8.8.8.8 2>/dev/null | sed -nr 's,^rtt .*/([1-9][0-9]*)\.[0-9]*/[^/]*$,\1,p'); then
+ wait_factor=10
+else
+ regex="^[1-9][0-9]*$"
+ if [[ $pingms =~ $regex ]]; then
+ wait_factor=$(( pingms / 20 ))
+ if (( wait_factor == 0 )); then
+ wait_factor=1
+ fi
+ else
+ wait_factor=10
+ fi
+fi
+ssh_timeout="timeout -s 9 $(( 6 * wait_factor ))"
+
# 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
root_size=$(( 1024 * 1024 * 2000 )) #2tb
percent_used=10
zone=$(date +%z)
- elif remote_str=$(timeout -s 9 6 ssh root@$h "$remote_str_cmd"); then
+ elif remote_str=$($ssh_timeout ssh root@$h "$remote_str_cmd"); then
mapfile -t tmp_array <<<"$remote_str"
zone="${tmp_array[0]}"
IFS=" " read -r root_size percent_used <<<"${tmp_array[1]}"
# This is a separate ssh because the command can fail and thatis ok.
if ! $force; then
locked=false
- if lock_info=$(timeout -s 9 6 ssh $h DISPLAY=:0 xscreensaver-command -time); then
+ if lock_info=$($ssh_timeout ssh $h DISPLAY=:0 xscreensaver-command -time); then
if [[ $lock_info != *non-blanked* ]]; then
locked=true
fi