This document is written for any human or LLM who will add, review, or refactor scripts in this repository.
Follow these rules exactly so every script remains 100 % self-contained and copy-paste friendly.
repo-root
├── linux
│ ├── raid
│ │ └── mdstat
│ │ ├── mdstat.sh # executable
│ │ └── readme.md # docs
│ └── …
├── windows
│ ├── hyperv
│ │ └── check-vms
│ │ ├── check-vms.ps1
│ │ └── readme.md
│ └── …
└── planning.md # ← this file
- One script = one directory
- Directory name = script name without extension
- The only two mandatory files are the script and readme.md
- Put extra helpers (systemd units, sample configs, etc.) inside the same directory if you really need them.
- Linux →
#!/usr/bin/env bash - Windows →
#Requires -Version 5.1(or higher) at the top of the.ps1
The first 25–40 lines must be an easily editable config block:
############################ USER CONFIG ############################
SEND_TO="discord" # discord | slack | email | none
DISCORD_WEBHOOK="" # leave empty to disable
CRITICAL_THRESHOLD=1 # how many failed disks before alert
#####################################################################Everything below that line must be able to run unchanged when the user supplies the same values via arguments.
Support long options only, no cryptic short flags.
./mdstat.sh \
--output discord \
--discord-webhook "https://discord.com/api/…" \
--critical-threshold 2If an argument is omitted, fall back to the value in the config block.
0= OK1= problem detected but already reported2= usage / argument error3= internal error (set -e triggered, etc.)
- Normal mode → one concise line:
OK: md0, md1 healthy - Verbose mode (
-vor--verbose) → multi-line, human friendly - JSON mode (
-jor--json) → single line, machine readable - All errors go to
stderr - Never print secrets (webhook URLs, passwords)
Copy-paste skeleton for every new script directory:
# mdstat.sh
Lightweight monitor for Linux software-RAID (mdadm).
## Quick start (one-liner)
```bash
wget -qO- https://raw.githubusercontent.com/HyberHost/Scripts/main/linux/raid/mdstat/mdstat.sh | bash
```
## Install dependencies
```bash
# Debian/Ubuntu
sudo apt-get install -y mdadm curl jq
# RHEL/CentOS
sudo yum install -y mdadm curl jq
```
## Run locally
```bash
git clone https://github.com/HyberHost/Scripts.git
cd linux/raid/mdstat
./mdstat.sh
```
## Cron example
```
# m h dom mon dow command
*/5 * * * * /opt/scripts/mdstat.sh --output discord --discord-webhook "https://discord.com/api/…"
```
## Command-line options
| Option | Default | Description |
|----------------------|---------|--------------------------------------|
| `--output` | none | discord, slack, email, none |
| `--discord-webhook` | (cfg) | Override Discord webhook URL |
| `--critical` | 1 | Number of failed disks before alert |
| `-v, --verbose` | false | Multi-line human output |
| `-j, --json` | false | Single-line JSON output |
| `-h, --help` | — | Show usage |
## Exit codes
0 = healthy, 1 = problem reported, 2 = usage error, 3 = runtime error- Always use
set -euo pipefail(Bash) or$ErrorActionPreference = 'Stop'(PowerShell) - Never
cdoutside the script directory; work with absolute paths - Log to
/var/log/...only when a--logfileswitch is supplied - Provide
--dry-runwhenever the script changes something (mount, resize, restart, etc.) - Keep shebang lines at column 0, no blank lines before them
- Use
curl -fsSLorInvoke-RestMethodfor downloads; never usecurl -kor--insecure - Add
| head -c 1Mor similar when youwgeta user-supplied URL to avoid blowing memory - If you must cache, place cache under
/tmp/__SCRIPTNAME__.cacheandtrapremoval on exit - Do not add colour codes unless
--coloris explicitly given - If you add colour, respect
NO_COLORenvironment variable
- To deprecate a script, add a note at the top of its readme.md and open an issue for discussion.
- To remove a script, submit a PR that deletes the directory and updates any references in documentation.
Each script's readme.md must include:
- One-liner description
- Quick start (one-liner)
- Dependency list
- Cron example
- Command-line options table
- Exit codes
- Repo uses CalVer:
YYYY.MM.DD.patch(e.g.2025.12.27.1) - GitHub release must attach a zipped snapshot of the whole repo; users behind corporate proxies prefer ZIP over
git clone - Tag must match folder name for every script touched in that release
- Keep
mainbranch always deployable; use PR + squash merge
- One script lives alone in its own directory
- Top editable config block + argument override
- readme.md with dependencies, one-liner, cron sample, exit codes
- Output short & clear; optional verbose or JSON
- Bash or PowerShell only
- Follow the checklist and you’re done