This repository was archived by the owner on Mar 30, 2020. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -378,7 +378,7 @@ Trivial (ba)sh alternatives:
378378when-up
379379-------
380380
381- Waits until a given host is online (determined by ping until executing a given command
381+ Waits until a given host is online (determined by ping until executing a given command)
382382
383383Example:
384384
@@ -393,6 +393,40 @@ Alternatives:
393393
394394
395395
396+ until-error
397+ -------------
398+
399+ Repeat the specific command until it fails - run at least once
400+ always.
401+
402+ Example:
403+
404+ ./until-error ssh example.com -l root -i ~/.ssh/example.com.key
405+
406+ Trivial (ba)sh alternatives:
407+
408+ * while true ; do $cmd; done
409+ * watch -n 2 $cmd
410+
411+
412+
413+ when-down
414+ -------
415+
416+ Waits until a given host is down
417+
418+ Example:
419+
420+ $ ./when-down 1.2.3.4 echo "down"
421+ Waiting for 1.2.3.4 to get down...
422+ down
423+
424+ Alternatives:
425+
426+ * ` until-error ping -c 1 -W 1 1.2.3.4; echo "down" `
427+
428+
429+
396430which-shell
397431-----------
398432
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ #
3+ # About
4+ # -----
5+ # Repeat the command until it fails
6+ #
7+
8+ " $@ "
9+
10+ #
11+ # If the status code was zero then repeat.
12+ #
13+ while [ $? -eq 0 ]; do
14+ " $@ "
15+ done
16+
17+
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+ #
3+ # Wait until a given host is down (determined by ping) then execute the
4+ # given command
5+ #
6+ # Usage:
7+ # ./when-down HOST COMMAND...
8+ #
9+ # Example
10+ # ./when-down 1.2.3.4 ssh 1.2.3.4
11+ #
12+
13+
14+ #
15+ # Ensure we received the correct number of arguments.
16+ #
17+ if [ $# -lt 2 ]; then
18+ echo " Usage: when-down HOST COMMAND..."
19+ exit 1
20+ fi
21+
22+ HOST=$1
23+
24+ echo " Waiting for $HOST to get down..."
25+
26+ true
27+ while [ $? -ne 1 ]; do
28+ ping -c 1 -W 1 $HOST > /dev/null
29+ done
30+
31+ shift
32+ $*
You can’t perform that action at this time.
0 commit comments