Project — Linux Automation Scripts¶
Beginner portfolio build — ship three reliable Bash scripts an ops team can actually run.
Project Overview¶
Goal: Deliver a mini toolkit of Linux automation scripts with strict mode, quoting, logging, and documented exit codes.
Deliverable for your portfolio:
bin/host-info.sh— host facts (hostname, kernel, uptime, disk summary)bin/check-disk.sh— threshold-based disk alert withRESULTon stdoutbin/backup-dir.sh— tar backup of a configured directory with retention- Shared
lib/common.sh(log helpers) README.mdwith usage and exit taxonomyvalidate.shsmoke suite
Estimated cost: £0.
Goals¶
- All scripts use
#!/usr/bin/env bashandset -euo pipefail - Paths and arguments are quoted
- Diagnostics go to stderr; machine-readable lines to stdout
- Smoke tests cover success and usage-failure paths
- README explains how to schedule with cron
Stack¶
| Piece | Choice |
|---|---|
| Language | Bash 4.2+ |
| Layout | bin/, lib/, config/, out/, tests/ or validate.sh |
| Scheduling | Documented crontab examples |
Prerequisites¶
- Tutorials: Writing Your First Script, Variables, Quoting, and Arithmetic, Control Flow — Conditionals, Linux Admin Automation
- Labs: Create Your First Script, Monitor Disk Usage, Build a Backup Utility
Milestones¶
Milestone 1 — Layout and common library¶
Create repo layout and lib/common.sh with log / die.
Milestone 2 — Host info and disk check¶
Implement fact dump and disk monitor; document exit codes 0/2/3.
Milestone 3 — Backup helper¶
Timestamped archives under out/backups/ with --retain-days.
Milestone 4 — Validation and README¶
validate.sh runs happy path + --help failures; README shows cron examples with absolute paths.
Success criteria¶
- Another engineer runs
./validate.shsuccessfully on Ubuntu - Scripts refuse unsafe paths outside a configured prefix
- No secrets in the repository
Related¶
- Next: Linux Administration Toolkit
- Cheat sheet: Shell Scripting
- Quiz: Shell Scripting for DevOps Fundamentals