nix-git/examples/block-while-remote-file-exists.sh
2023-11-23 12:44:23 +01:00

21 lines
474 B
Bash

#!/usr/bin/env bash
set -eu -o pipefail
# As long as there is the file `stay-alive` at host `yodaNas`,
# this loop blocks/waits.
while :; do
result="$(ssh yodaNas 'ls stay-alive 2>&1')" || :
case "${result}" in
*'No such file or directory')
break
;;
'stay-alive')
printf '%s\n' 'Delaying suspend due to stay-alive file.'
;;
*)
printf '%s\n' 'Delaying suspend due to SSH connectivity problems.'
;;
esac
sleep 10s
done