5 hardened sysadmin scripts with strict error handling, structured logging, and automated recovery — built for Linux operations teams.
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
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/
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.
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
Make scripts accessible from anywhere without typing the full path.
echo 'export PATH="$PATH:/opt/bash-automation-toolkit/scripts"' \ >> ~/.bashrc source ~/.bashrc
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 ===
Creates a Linux user with a primary group, enforced password change
on first login, and per-user sudoers file validated by
visudo before activation.
sudo ./scripts/user_setup.sh <username>
<groupname>
/var/log/user_setup.log
Archives /home and /etc into date-stamped
.tar.gz files, verifies integrity after each archive,
and auto-prunes backups older than 7 days.
sudo ./scripts/backup.sh
/var/log/backup.log
Scans every real mounted partition. Logs WARN at 80%
and CRITICAL at 95% usage. Exit codes
0/1/2
integrate cleanly with monitoring pipelines.
*/30 * * * *
/opt/bash-automation-toolkit/scripts/disk_monitor.sh
/var/log/disk_alert.log
Polls sshd, nginx, and
firewalld via systemctl. On failure:
captures diagnostic output, restarts the service, re-enables it if
disabled, and confirms recovery.
*/5 * * * *
/opt/bash-automation-toolkit/scripts/service_health.sh
/var/log/service_health.log
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.
0 6 * * *
/opt/bash-automation-toolkit/scripts/system_report.sh
/root/reports/report_YYYY-MM-DD.txt
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
EXCLUDE_TYPES array into
df -x flags.
> "$FILE" →
: > "$FILE" (truncate idiom).
set -euo pipefail + trap ERR with line
numbers on every failure. No silent errors, ever.
[INFO|WARN|ERROR|CRITICAL] severity. Machine-parseable
format.
find -mtime +N -delete on every run.
$EUID. Input validated before
any destructive operation. 13 reserved system accounts blocked.
visudo -cf.