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

20 lines
449 B
Bash

#!/usr/bin/env bash
# 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