On Saturday the south fridge went offline at 2 AM. Nobody knew until the morning, and the milk was warm. Ana wants a check that runs every night, before anything spoils:
learner@reef:~$ ./fleet.sh ~/fleet.txt
register-north up
…
fridge-south down
web-shop up
5 of 6 upEach machine that is up keeps a file in ~/heartbeats, named after it. A host is up when
~/heartbeats/HOST exists.
Write ~/fleet.sh, make it runnable with chmod u+x ~/fleet.sh, and run it as above.
You have 15 minutes. The clock starts when you start the challenge. If the time runs out, you can still finish.
Everything is from this chapter and the ones before. The tests also run your script on a host file you have never seen.
Objectives
./fleet.sh FILEprintsHOST uporHOST downfor each host inFILE, in order. Comments and blank lines are skipped.- Then it prints how many are up:
5 of 6 up. - It exits with 1 when any host is down, and with 0 when all are up.