From a7d7b35e0cd73b62321afcbf1f1002cd6de426f1 Mon Sep 17 00:00:00 2001 From: blow-tech Date: Tue, 8 Sep 2026 15:59:55 +0200 Subject: [PATCH 1/2] Fix approved Linux script safety and correctness findings --- .github/workflows/safety.yml | 12 ++ .gitignore | 3 + README.md | 207 +++++--------------------- scripts/Nginx_create.sh | 111 ++++++++------ scripts/appache2_confg.sh | 29 ++-- scripts/audit/FastCheck.sh | 169 +++------------------ scripts/audit/LinuxAudit.sh | 20 ++- scripts/audit/ScanPort.sh | 68 +++------ scripts/backup/backup_rotation.sh | 145 ++++-------------- scripts/backup/backup_script | 110 ++------------ scripts/core/alert_engine.sh | 28 ++++ scripts/core/backup_engine.sh | 42 ++++++ scripts/monitoring/cpu_memory_monitor | 5 +- scripts/monitoring/disk_alert | 106 ++++--------- scripts/monitoring/service_uptime | 99 +++--------- tests/test_safety.py | 94 ++++++++++++ 16 files changed, 449 insertions(+), 799 deletions(-) create mode 100644 .github/workflows/safety.yml create mode 100644 .gitignore create mode 100644 scripts/core/alert_engine.sh create mode 100644 scripts/core/backup_engine.sh create mode 100644 tests/test_safety.py diff --git a/.github/workflows/safety.yml b/.github/workflows/safety.yml new file mode 100644 index 0000000..f7e3a29 --- /dev/null +++ b/.github/workflows/safety.yml @@ -0,0 +1,12 @@ +name: Isolated script safety +on: [push, pull_request] +permissions: + contents: read +jobs: + fixtures: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v4 + - name: Bash syntax and local fixture regressions + run: python3 -m unittest discover -s tests -v diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..41c33c8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ + +__pycache__/ +*.pyc diff --git a/README.md b/README.md index 751a810..6c91d01 100644 --- a/README.md +++ b/README.md @@ -1,189 +1,56 @@ -# ๐Ÿง Linux Admin Scripts +# Linux Admin Scripts -A production-ready collection of Bash scripts for Linux system administration โ€” monitoring, alerting, backup, maintenance, and security auditing. +Bash administration utilities. Validate each script in a disposable lab before production deployment. Syntax checks and fixture tests do not certify an environment or an application backup. -> All scripts include centralized Slack/Teams/Email alerting, lock files, log rotation, and proper error handling. +## Entry points ---- +Use `bash `; several maintained entry points intentionally have no `.sh` extension. -## ๐Ÿ“ Repository Structure +| Path | Behavior and scope | +| --- | --- | +| `scripts/monitoring/server-stats.sh` | Local statistics snapshot; unchanged in the September remediation. | +| `scripts/monitoring/cpu_memory_monitor` | CPU/memory observations; local log and stderr alerts. | +| `scripts/monitoring/disk_alert` | One GNU df collection; warning/critical or unavailable collection returns nonzero. | +| `scripts/monitoring/service_uptime ...` | Explicit service scope, alert-only; never restarts a service. | +| `scripts/backup/backup_script ` | Verified, versioned file archive; retention inventory only. | +| `scripts/backup/backup_rotation.sh` | Versioned daily/weekly archives; requires SRC_DIR, BACKUP_DIR and EXPECTED_BACKUP_SOURCE. | +| `scripts/Nginx_create.sh