BashUpdate is a comprehensive Bash script for performing routine system updates and maintenance on Debian-based systems. It updates system packages, snap packages, performs cleanup operations, and handles Docker maintenance.
-
System Updates & Upgrades:
- Updates package lists using
apt update - Performs a full system upgrade with
apt full-upgrade - Automatically installs required dependencies (e.g.,
curl)
- Updates package lists using
-
Snap Package Updates:
- Updates all installed snap packages using
snap refresh
- Updates all installed snap packages using
-
System Cleanup:
- Removes unused packages with
apt autoremove --purge - Cleans APT cache with
apt cleanandapt autoclean - Removes old kernel packages
- Removes unused packages with
-
Log Maintenance:
- Vacuums systemd journal to retain logs for a specified period (default: 7 days)
- Trims update script log file if it exceeds 20,000 lines
-
Docker Maintenance:
- If Docker is installed, the script will:
- Download and cache
dockcheck.shin/usr/local/lib/update-script/(persists between runs) - Run dockcheck to update Docker containers (if enabled)
- Prune unused Docker images, volumes, and networks
- Perform deep cleanup of all unused Docker resources
- Download and cache
- If Docker is installed, the script will:
-
Disk Space Check:
- Verifies that a minimum disk space threshold (1GB by default) is available before executing updates
-
Raspberry Pi Specific Tasks:
- Checks for Raspberry Pi hardware and, if detected, optionally runs
unifi-update.shscript if available
- Checks for Raspberry Pi hardware and, if detected, optionally runs
The script can be configured via environment variables:
LOG_DIR: Directory for log files (default:/var/log/update-script)LOG_FILE: Path to log file (default:$LOG_DIR/update.log)REQUIRED_DISK_KB: Minimum disk space required in KB (default:1048576= 1GB)JOURNAL_VACUUM_TIME: Systemd journal retention period (default:7d)RUN_DOCKCHECK: Enable/disable dockcheck (default:1= enabled)DOCKCHECK_REF: Branch/tag for dockcheck script (default:main)DOCKCHECK_OPTS: Options to pass to dockcheck (default:-apfs)
- Operating System: Debian-based systems (including Raspberry Pi OS)
- Bash: Version 4.x or higher
- Privileges: Must be run as root (or via
sudo) - Required Commands:
apt-get,dpkg,grep,awk,df,find(all checked automatically) - Optional Dependencies:
docker(if you want to perform Docker maintenance)snap(if you want to update snap packages)curl(automatically installed if needed for dockcheck)
sudo ./update.shThe script will:
- Check for root privileges and required dependencies
- Verify sufficient disk space
- Update package lists
- Install required dependencies
- Upgrade system packages
- Update snap packages
- Clean up unused packages and cache
- Remove old kernel packages
- Clean up system logs
- Perform Docker maintenance (if Docker is installed)
- Optionally run unifi-update.sh on Raspberry Pi systems
All output is logged to /var/log/update-script/update.log by default.
The script provides concise output with full sentences, showing progress for each section:
- Section headers indicate what operation is being performed
- Warnings and errors are clearly marked
- Most operations run silently unless there are issues
- Docker dockcheck output is shown when enabled
- The script uses
set -euo pipefailfor strict error handling - All apt operations use non-interactive mode
- Docker dockcheck script is cached in
/usr/local/lib/update-script/to avoid re-downloading - If a system reboot is required after updates, you'll be prompted at the end