nix-git/examples/block-while-remote-file-exists.sh

21 lines
474 B
Bash
Raw Normal View History

2023-11-15 13:54:37 +01:00
#!/usr/bin/env bash
2023-11-22 14:32:35 +01:00
set -eu -o pipefail
2023-11-15 13:54:37 +01:00
# As long as there is the file `stay-alive` at host `yodaNas`,
# this loop blocks/waits.
while :; do
2023-11-22 14:32:35 +01:00
result="$(ssh yodaNas 'ls stay-alive 2>&1')" || :
2023-11-15 13:54:37 +01:00
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