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." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
How to Run
Basic Execution
To manually run the script:
Adding Execution Permissions
Ensure the script has executable permissions:
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
:To make this permanent, append the export command to
.zshrc
:Running as Root (if needed)
Certain commands within the script may require elevated privileges:
Example Output