A comprehensive collection of automation scripts for system administration, maintenance, and operations across multiple platforms.
This repository contains production-ready automation scripts designed to streamline system administration tasks, improve operational efficiency, and maintain system health across Linux and Windows environments. All scripts follow consistent coding standards with comprehensive documentation and error handling.
- Cross-Platform Support: Scripts for both Linux (Bash) and Windows (PowerShell)
- Security Hardening: Automated security configurations based on industry best practices (MITRE ATT&CK)
- Database Management: Backup, maintenance, and optimization for MySQL, PostgreSQL, MongoDB, Oracle, MS SQL Server, Redis, and Cassandra
- System Monitoring: Real-time monitoring of resources, services, security logs, and disk space
- Network Operations: Firewall configuration, SSL certificate generation, and network diagnostics
- User Management: Comprehensive user and group administration tools
- Backup Solutions: Automated backup systems with compression and retention policies
- Performance Tuning: Database optimization, system cleanup, and health checks
automation-scripts/
βββ src/
β βββ linux/ # Bash scripts for Linux systems
β β βββ get_distro_information.sh
β β βββ get_hostname.sh
β β βββ get_network_info.sh
β β βββ get_system_resources.sh
β β βββ get_top_processes.sh
β β βββ debian_hardening.sh
β β βββ red_hat_hardening.sh
β β βββ backup_system.sh
β β βββ cleanup_system.sh
β β βββ configure_firewall.sh
β β βββ database_backup.sh
β β βββ generate_ssl_certificate.sh
β β βββ manage_users.sh
β β βββ monitor_disk_space.sh
β β βββ monitor_security_logs.sh
β β βββ monitor_services.sh
β β βββ mysql_maintenance.sh
β β βββ postgresql_maintenance.sh
β β βββ setup_docker.sh
β β βββ setup_lamp_stack.sh
β β βββ system_health_check.sh
β βββ windows/ # PowerShell scripts for Windows systems
β βββ Get-SystemInformation.ps1
β βββ Get-SystemResources.ps1
β βββ Get-NetworkDiagnostics.ps1
β βββ Test-SystemHealth.ps1
β βββ Set-WindowsHardening.ps1
β βββ Set-FirewallRules.ps1
β βββ Backup-System.ps1
β βββ Backup-Database.ps1
β βββ Optimize-System.ps1
β βββ Manage-LocalUsers.ps1
β βββ Watch-ServiceMonitor.ps1
β βββ Watch-SecurityLogs.ps1
βββ workspace/
β βββ automation-scripts.code-workspace
βββ README.md
| Script | Description |
|---|---|
get_distro_information.sh |
Retrieves Linux distribution details |
get_hostname.sh |
Displays system hostname |
get_network_info.sh |
Shows network interface configuration and connectivity |
get_system_resources.sh |
Monitors CPU, memory, and disk usage |
get_top_processes.sh |
Lists top processes by CPU and memory consumption |
monitor_disk_space.sh |
Monitors disk usage with threshold alerts |
monitor_services.sh |
Monitors critical services and auto-restarts if down |
monitor_security_logs.sh |
Analyzes security logs for suspicious activities |
system_health_check.sh |
Comprehensive system health assessment with reporting |
| Script | Description |
|---|---|
debian_hardening.sh |
Security hardening for Debian-based systems (Ubuntu, Debian) |
red_hat_hardening.sh |
Security hardening for RHEL-based systems (CentOS, Rocky, Alma) |
configure_firewall.sh |
Interactive firewall configuration (UFW/firewalld/iptables) |
generate_ssl_certificate.sh |
Generates self-signed SSL certificates for Apache/Nginx |
- Automatic security updates
- SSH hardening with random port assignment
- Kernel parameter tuning
- Audit logging configuration
- Firewall setup (UFW/firewalld)
- Fail2Ban integration
- File permission hardening
- Password policy enforcement
- SELinux/AppArmor configuration
- Service disabling (unnecessary/insecure)
| Script | Description |
|---|---|
database_backup.sh |
Multi-database backup solution (MySQL, PostgreSQL, MongoDB, Oracle, MS SQL, Redis, Cassandra) |
mysql_maintenance.sh |
Comprehensive MySQL maintenance and optimization |
postgresql_maintenance.sh |
Comprehensive PostgreSQL maintenance and optimization |
- Automated backups with compression
- Table optimization and defragmentation
- Index analysis and rebuilding
- Query performance analysis
- Log rotation and cleanup
- WAL/Binary log management
- Statistics updates
- Bloat detection
- Performance reporting
| Script | Description |
|---|---|
backup_system.sh |
System-wide backup (configs, packages, cron jobs, home directories) |
cleanup_system.sh |
System cleanup (cache, logs, temp files, old kernels) |
manage_users.sh |
Interactive user management tool |
| Script | Description |
|---|---|
setup_lamp_stack.sh |
Automated LAMP stack installation (Apache, MySQL, PHP) |
setup_docker.sh |
Docker and Docker Compose installation with configuration |
| Script | Description |
|---|---|
Get-SystemInformation.ps1 |
Retrieves comprehensive Windows system information |
Get-SystemResources.ps1 |
Monitors CPU, memory, disk, and network usage with thresholds |
Test-SystemHealth.ps1 |
Comprehensive system health check with detailed reporting |
Watch-ServiceMonitor.ps1 |
Monitors critical services and auto-restarts if stopped |
Watch-SecurityLogs.ps1 |
Monitors security logs for suspicious activities and threats |
Get-NetworkDiagnostics.ps1 |
Comprehensive network diagnostics and troubleshooting |
| Script | Description |
|---|---|
Set-WindowsHardening.ps1 |
Security hardening based on best practices (UAC, Firewall, Defender) |
Set-FirewallRules.ps1 |
Interactive Windows Firewall management with rule creation/management |
Manage-LocalUsers.ps1 |
Comprehensive local user and group management |
- Windows Firewall configuration (all profiles)
- Windows Defender configuration
- SMBv1 protocol disabling
- UAC (User Account Control) configuration
- PowerShell v2 disabling
- Automatic updates enabling
- Password policy enforcement
- Audit policy configuration
- Guest account disabling
- RDP security configuration
- AutoRun disabling
- Event log size configuration
- Unnecessary service disabling
| Script | Description |
|---|---|
Backup-System.ps1 |
Comprehensive system backup (registry, tasks, logs, configurations) |
Optimize-System.ps1 |
System optimization and cleanup (temp files, cache, disk optimization) |
Backup-Database.ps1 |
Multi-database backup (SQL Server, MySQL, PostgreSQL, MongoDB) |
- System information backup
- Installed programs list
- Windows features
- Scheduled tasks
- Network configuration
- Registry keys (selective)
- Event logs (Application, System, Security)
- User profile listings
- Compression and retention management
- SQL Server (native backup)
- MySQL (mysqldump)
- PostgreSQL (pg_dump)
- MongoDB (mongodump)
- Automated compression
- Retention policy management
For Linux:
- Bash shell (version 4.0+)
- Root/sudo access for system-level operations
- Required packages vary by script (scripts will check and notify)
For Windows:
- PowerShell 5.1 or later
- Administrator privileges for system-level operations
- Clone the repository:
git clone https://github.com/mgnischor/automation-scripts.git
cd automation-scripts- For Linux - Make scripts executable:
chmod +x src/linux/*.sh- Run a Linux script:
sudo ./src/linux/system_health_check.sh- For Windows - Run PowerShell as Administrator and execute:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
.\src\windows\Test-SystemHealth.ps1sudo ./src/linux/system_health_check.shsudo ./src/linux/debian_hardening.shsudo ./src/linux/database_backup.sh allsudo ./src/linux/mysql_maintenance.shsudo ./src/linux/manage_users.shsudo ./src/linux/monitor_disk_space.sh.\src\windows\Test-SystemHealth.ps1.\src\windows\Set-WindowsHardening.ps1.\src\windows\Backup-Database.ps1.\src\windows\Watch-ServiceMonitor.ps1.\src\windows\Manage-LocalUsers.ps1.\src\windows\Get-NetworkDiagnostics.ps1Most scripts include configurable variables at the top of the file:
# Example configuration section
BACKUP_DIR="/var/backups"
RETENTION_DAYS=7
EMAIL="admin@example.com"
THRESHOLD=80Edit these variables according to your environment before running the scripts.
- Credentials: Scripts prompt for passwords when needed. Never hardcode sensitive information.
- Permissions: Scripts check for root/sudo access and will warn if insufficient privileges.
- Logging: All operations are logged with timestamps for audit purposes.
- Backups: Always create backups before making system changes.
- Testing: Test scripts in a non-production environment first.
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Follow the existing code style and documentation standards
- Add appropriate comments and logging
- Test thoroughly
- Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Use consistent indentation (4 spaces)
- Include header comments with file information
- Add function documentation
- Implement error handling
- Provide meaningful log messages
- Follow the existing naming conventions
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Miguel Nischor
- Email: miguel@datatower.tech
- GitHub: @mgnischor
- Security hardening based on MITRE ATT&CK framework
- Best practices from industry-standard security benchmarks (CIS, NIST)
- Community feedback and contributions
Current Version: 1.0.0
Status: Active Development
- Linux system administration scripts
- Database backup and maintenance
- Security hardening automation
- System monitoring and health checks
- Windows PowerShell scripts
- Advanced database maintenance for Windows (Oracle, Redis, Cassandra)
- Kubernetes/Docker orchestration scripts
- Cloud provider integration (AWS, Azure, GCP)
- Ansible playbook alternatives
- Web-based dashboard for monitoring
- Automated testing and CI/CD integration
Please use the GitHub Issues page to report bugs or request features.
For questions or support, please open an issue or contact the author directly.