Created
March 21, 2017 16:35
-
-
Save rustymyers/5ccc7faeb34b8ea1616d335d2f2c9d8f to your computer and use it in GitHub Desktop.
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 | |
#-------------------------------------------------------------------------------------------------- | |
#-- SoftwareUpdate.sh | |
#-------------------------------------------------------------------------------------------------- | |
# Program : SoftwareUpdate.sh | |
# To Complie : n/a | |
# | |
# Purpose : | |
# | |
# Called By : | |
# Calls : | |
# | |
# Author : | |
# Based Upon : | |
# | |
# Note : | |
# | |
# Revisions : | |
# 2016-09-28 <> Initial Version | |
# | |
# Version : 1.0 | |
#-------------------------------------------------------------------------------------------------- | |
#-------------------------------------------------------------------------------------------------- | |
#-- Log - Echo messages with date and timestamp | |
#-------------------------------------------------------------------------------------------------- | |
Log () | |
{ | |
logText=$1 | |
# indent lines except for program entry and exit | |
if [[ "${logText}" == "-->"* ]];then | |
logText="${logText}`basename $0`: launched..." | |
else | |
if [[ "${logText}" == "<--"* ]];then | |
logText="${logText}`basename $0`: ...terminated" | |
else | |
logText=" ${logText}" | |
fi | |
fi | |
date=$(/bin/date) | |
echo "${date/E[DS]T /} ${logText}" | |
} | |
Log "-->" | |
Log "Sleeping for 30 Seconds" | |
sleep 30 | |
forceMainFile="/Library/TEMP/force.run.maint" | |
# Get SUStatus | |
SUStatus=$(softwareupdate -l) | |
Log "Running updates" | |
Log "### Checking For Updates ###" | |
echo "$SUStatus" | |
Log "############################" | |
# If any updates require restart, touch force file | |
if [[ "$SUStatus" =~ "restart" ]]; then | |
Log "Touching force maintenance file to run SoftwareUpdate after reboot" | |
touch "$forceMainFile" | |
else | |
Log "No Updates or Updates do not require reboot" | |
if [[ -e "$forceMainFile" ]]; then | |
Log "Found force maint file, deleteing" | |
rm "$forceMainFile" | |
fi | |
fi | |
# we should run all software updates | |
softwareupdate --install --all | |
Log "<--" | |
exit 0 | |
# $ softwareupdate -l | |
# Software Update Tool | |
# Copyright 2002-2015 Apple Inc. | |
# | |
# Finding available software | |
# No new software available. | |
# Software Update Tool | |
# Copyright 2002-2015 Apple Inc. | |
# | |
# Finding available software | |
# Software Update found the following new or updated software: | |
# * Security Update 2016-001-10.11.6 | |
# Security Update 2016-001 (10.11.6), 404374K [recommended] [restart] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment