Created
May 27, 2025 11:55
-
-
Save VetAran/fed26d1dce737c65536a8445092e8927 to your computer and use it in GitHub Desktop.
sysupd8.sh – A Unix-Based System Update Script A lightweight, automated maintenance tool for macOS, streamlining system updates, Homebrew, and Python package management while maintaining structured diagnostic logs. Designed for efficiency, with future plans to evolve into a modular, function-driven workflow. Released under the MIT License for fr…
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# ---Name the update script--- | |
# sysupd8.sh - Optimized system update and maintenance script for macOS | |
# Script automates key update and logging processes, | |
# including self-updating the script itself. | |
# It manages system diagnostic logs (keeping up to 19 total), | |
# updates the macOS software, then Homebrew packages, | |
# then Python packages via pip3. | |
# ---Script Mechanism to Self-Update--- | |
# Defines path for script to run | |
SCRIPT_PATH="$HOME/sysupd8.sh" | |
# Defines path for newer version of script and where to save it if applicable--- | |
UPDATED_SCRIPT_PATH="$HOME/sysupd8_latest.sh" | |
# Checks for newer version of script; if it exists in designated path | |
if [ -f "$UPDATED_SCRIPT_PATH" ]; then | |
echo "Updating sysupd8.sh..." | |
# Moves new version to old one | |
mv "$UPDATED_SCRIPT_PATH" "$SCRIPT_PATH" | |
# Makes updated script executable | |
chmod +x "$SCRIPT_PATH" | |
fi | |
# ---macOS Specific System Diagnostic and Log Management | |
# Creates a unique directory name for logs using current date format | |
# sysdiagnose command pulls filtered, detailed system diagnostics | |
# | |
LOG_DIR="$HOME/syslogs_beta_$(date +"%Y-%m-%d")" | |
# | |
# sysdiagnose command saves output to newly created directory | |
# macOS-specific command to gather targeted system information | |
# | |
sysdiagnose -f "$LOG_DIR" | |
# Cleans old sysdiagnose logs | |
# | |
# call: ls-td $HOME/syslogs_beta_*: Lists matching pattern directory | |
# then sorts by newest first | |
# | |
# tail -n +19: Skips first 18 then keeps newest 18 | |
# (selects logs older than 19, purges anything 19+) | |
# | |
# xargs rm -rf: Takes tail output (old directory paths) | |
# forcibly removing them [recursively] retaining latest 1-18 logs | |
ls -td $HOME/syslogs_beta_* | tail -n +19 | xargs rm -rf | |
# | |
# ---Updates macOS Software--- | |
# Runs standard macOS update command | |
# sudo: elevated sudo requiring superuser privileges & password | |
# -ia [--install --all] installs all available updates | |
# --verbose: outputs detailed progress during update process | |
sudo softwareupdate -ia --verbose | |
# ---Homebrew Package Updates--- | |
# Checks for Homebrew [brew command] is installed and executable | |
# command -v brew &> /dev/null: Suppress all output from check | |
# &&: If brew is found, proceed with Homebrew commands | |
# sudo: elevated sudo requiring superuser privileges & password | |
# brew update: Fetch latest Homebrew definitions and formulae | |
# brew upgrade: Upgrades all Homebrew packages installed on system if new version exists | |
command -v brew &> /dev/null && brew update && brew upgrade | |
# ---Python3 Package (pip3) Updates--- | |
# Checks if pip3 (Python 3's package installer) is installed and executable | |
# &&: If pip3 is found, proceeds with pip3 command | |
# pip3 list --outdated: Lists installed Python3 packages that have newer versions available | |
# awk '{print $1}': Extracts ONLY first column from pip3 list output [package name] | |
# xargs pip3 install --upgrade: Takes list of outdated package names | |
# then upgrades them one by one | |
command -v pip3 &> /dev/null && pip3 list --outdated | awk '{print $1}' | xargs pip3 install --upgrade | |
# ---Completion Message--- | |
echo "System update completed. Logs & outdated packages managed successfully." |
sysupd8 - System Update & Maintenance Script
Overview
sysupd8
is a streamlined system update script designed to automate the process of checking for updates, managing outdated packages, and maintaining system logs.
Features
- ✅ Runs system updates (macOS Software Update, Homebrew updates)
- ✅ Generates system logs for troubleshooting
- ✅ Cleans up outdated packages for efficiency
- ✅ Ensures system stability with minimal manual intervention
How to Run
Basic Execution
To manually run the script:
./sysupd8.sh
Adding Execution Permissions
Ensure the script has executable permissions:
chmod +x sysupd8.sh
Handling Missing Directories
If necessary, create the required directories for logs:
mkdir -p ~/syslogs_beta_
Ensuring the Script Is in $PATH
To allow running sysupd8
globally, add its location to $PATH
:
export PATH=$PATH:~/your-script-location
To make this permanent, append the export command to .zshrc
:
echo 'export PATH=$PATH:~/your-script-location' >> ~/.zshrc
source ~/.zshrc
Running as Root (if needed)
Certain commands within the script may require elevated privileges:
sudo sysupd8
Example Output
sysdiagnose must be run as root
ls: /Users/vet/syslogs_beta_*: No such file or directory
Password:
Software Update Tool
Finding available software
No updates are available.
==> Updating Homebrew...
Already up-to-date.
System update completed. Logs & outdated packages managed successfully.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
sysupd8.sh – A Unix-Based System Update & Maintenance Script
Sysupd8.sh is a lightweight, automated update script designed for macOS users who need a clean, efficient way to manage system updates, Homebrew packages, and Python dependencies—all while maintaining structured diagnostic logs.
Why I Built This
I wanted a single script that eliminates the hassle of manual updates, keeps my system optimized, and streamlines the workflow for troubleshooting, performance monitoring, and software maintenance.
Core Features
Future Evolution
Currently structured as a sequential script, sysupd8.sh will eventually evolve into a modular, function-driven workflow, improving reusability, flexibility, and efficiency. I'm still learning, so as my skills evolve, the script will.
License & Usage
Sysupd8.sh is released under the MIT License, meaning anyone can use, modify, and redistribute it freely.