"Bournemouth": Same job, three shells
Scenario: "Bournemouth": Same job, three shells
Level: Medium
Type: Do
Tags: bash
Access: Email
Description: This box is a small shell lab. Debian's /bin/sh is dash, your login shell is bash, and zsh is installed. Cron, Docker CMD lines, and most #!/bin/sh scripts do not run bash — and zsh script.sh does not honour a POSIX shebang.
Read /home/admin/lab/00-START-HERE.txt and run the demos with:
/home/admin/lab/compare.sh /home/admin/lab/demos/01-identity.sh
(there are ten snippets under demos/; run-all.sh runs every one).
Then write a script /home/admin/fleet-report.sh that prints a host status table from /home/admin/lab/inventory/ (hosts, disk.tsv, access.log).
Rules:
- One header line exactly: HOST DISK ERR STATUS
- Then one line per host from hosts, in that file's order: NAME DISK ERR STATUS (single spaces, no tabs)
- DISK is the integer from disk.tsv
- ERR is how many access.log lines have that host and code 500
- STATUS is crit if DISK >= 90 or ERR >= 5; else warn if DISK >= 80 or ERR >= 1; else ok
The same file must print that table with no extra lines when run as:
sh /home/admin/fleet-report.sh,
bash /home/admin/fleet-report.sh, and
zsh /home/admin/fleet-report.sh.
demos/10-broken-report.sh is a bash sketch that is not a valid solution.
Root (sudo) Access: True
Test: /home/admin/fleet-report.sh exists. sh, bash, and zsh each print the same report for the inventory files, matching the rules above.
The "Check My Solution" button runs the script /home/admin/agent/check.sh, which you can see and execute.
Time to Solve: 20 minutes.