RHEL 9 · Bash 5 · Production-Ready ShellCheck Verified

BASH
AUTOMATION
TOOLKIT

5 hardened sysadmin scripts with strict error handling, structured logging, and automated recovery — built for Linux operations teams.

5 Scripts
RHEL 9 Platform
0 Dependencies
set -euo Strict Mode
01
QUICK INSTALL
Deploy to RHEL 9 in under 60 seconds
01
Clone the Repository

Pull the toolkit from GitHub into a system-wide location accessible by root.

git clone https://github.com/samiulAsumel/bash-automation-toolkit.git \
  /opt/bash-automation-toolkit
02
Set Execute Permissions

Grant execute bits to all scripts. Root ownership ensures no unprivileged modification.

cd /opt/bash-automation-toolkit
chmod +x scripts/*.sh
chown -R root:root scripts/
03
Verify with ShellCheck

Run static analysis on all scripts. All 5 pass with zero warnings on ShellCheck 0.9.0.

shellcheck scripts/*.sh
# All 5 scripts: No issues found.
04
Deploy the Cron Schedule

Install the full automation schedule. All scripts run as root via root's crontab.

sudo crontab -e
# Paste the full schedule from section 04 below
05
Add to PATH (Optional)

Make scripts accessible from anywhere without typing the full path.

echo 'export PATH="$PATH:/opt/bash-automation-toolkit/scripts"' \
  >> ~/.bashrc
source ~/.bashrc
06
Run a Test Script

Verify the installation by running the health check script.

cd /opt/bash-automation-toolkit
sudo ./scripts/service_health.sh
# Expected: [INFO] === Health check complete — Failures: 0 ===
Requirements RHEL / CentOS / Rocky 9 · Bash 5.0+ · Root access · systemd · bc, tar, find, awk (coreutils)
02
THE SCRIPTS
Click any terminal to replay the demo
01
user_setup.sh
User Provisioning

Creates a Linux user with a primary group, enforced password change on first login, and per-user sudoers file validated by visudo before activation.

user_setup.sh
Usage sudo ./scripts/user_setup.sh <username> <groupname>
Log: /var/log/user_setup.log
02
backup.sh
Backup & Archive

Archives /home and /etc into date-stamped .tar.gz files, verifies integrity after each archive, and auto-prunes backups older than 7 days.

backup.sh
Usage sudo ./scripts/backup.sh
Log: /var/log/backup.log
03
disk_monitor.sh
Disk Alerting

Scans every real mounted partition. Logs WARN at 80% and CRITICAL at 95% usage. Exit codes 0/1/2 integrate cleanly with monitoring pipelines.

disk_monitor.sh
Cron (every 30 min) */30 * * * * /opt/bash-automation-toolkit/scripts/disk_monitor.sh
Log: /var/log/disk_alert.log
04
service_health.sh
Service Watchdog

Polls sshd, nginx, and firewalld via systemctl. On failure: captures diagnostic output, restarts the service, re-enables it if disabled, and confirms recovery.

service_health.sh
Cron (every 5 min) */5 * * * * /opt/bash-automation-toolkit/scripts/service_health.sh
Log: /var/log/service_health.log
05
system_report.sh
Daily System Report

Generates a full-page system snapshot: hostname, OS, kernel, uptime, load averages, CPU usage (live 1-second sample), memory, disk, network interfaces, logged-in users, last 5 failed login attempts, critical service status, and recent journal errors. Saves to /root/reports/report_YYYY-MM-DD.txt.

system_report.sh
Cron (daily at 6 AM) 0 6 * * * /opt/bash-automation-toolkit/scripts/system_report.sh
Output: /root/reports/report_YYYY-MM-DD.txt
03
SCRIPT REFERENCE
Every parameter, behavior, edge case, and exit code — documented
04
CRON REFERENCE
Full schedule — paste into sudo crontab -e
# Bash Automation Toolkit — full crontab
# Daily backup at 2:00 AM
0 2 * * * /opt/bash-automation-toolkit/scripts/backup.sh

# Disk check every 30 minutes
*/30 * * * * /opt/bash-automation-toolkit/scripts/disk_monitor.sh

# Service health check every 5 minutes
*/5 * * * * /opt/bash-automation-toolkit/scripts/service_health.sh

# Daily system report at 6:00 AM
0 6 * * * /opt/bash-automation-toolkit/scripts/system_report.sh
05
DRY RUN RESULTS
bash -n + ShellCheck 0.9.0 · run 2026-05-16
5/5 Passed
user_setup.sh
bash -n shellcheck
No issues found.
backup.sh
bash -n shellcheck
No issues found.
disk_monitor.sh
bash -n shellcheck
Fixed: wired EXCLUDE_TYPES array into df -x flags.
service_health.sh
bash -n shellcheck
Fixed: removed two unused placeholder constants.
system_report.sh
bash -n shellcheck
Fixed: > "$FILE": > "$FILE" (truncate idiom).
06
ENGINEERING STANDARDS
Every script ships with these guarantees
Strict Mode
set -euo pipefail + trap ERR with line numbers on every failure. No silent errors, ever.
Structured Logging
Every event logged with ISO timestamp and [INFO|WARN|ERROR|CRITICAL] severity. Machine-parseable format.
Auto-Retention
Backups pruned after 7 days. Reports pruned after 30 days. find -mtime +N -delete on every run.
Exit Codes
Meaningful exit codes on all scripts — 0 (success), 1 (warn/error), 2 (critical). Nagios/Zabbix compatible.
Root Safety
Root check at entry via $EUID. Input validated before any destructive operation. 13 reserved system accounts blocked.
No Embedded Secrets
Passwords are never stored, echoed, or logged. Interactive prompts only. Sudoers validated by visudo -cf.
07
INTERACTIVE PLAYGROUND
Simulated execution — 100% frontend · no server · no root needed
Frontend Only
Parameters
user_setup.sh
Copied!