Skip to content

Commit

Permalink
2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
grahampugh committed May 12, 2021
1 parent f755d95 commit a2b12d9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 7 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@

No date

## [2.0.2]

12.05.2021

- Runs `jamfHelper` as the current user (this may not be necessary - was introduced to try and fix a problem where the tool was not showing though was running).
- Changed default defer count (back) to 10.

## [2.0.1]

30.04.2021
Expand Down
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
identifier="com.github.grahampugh.nice_updater"

# Default version of the build, you can leave this alone and specify as an argument like so: ./build.sh 1.7
version="2.0.1"
version="2.0.2"

# The title of the message that is displayed when software updates are in progress and a user is logged in
updateRequiredTitle="macOS Software Updates Required"
Expand All @@ -25,7 +25,7 @@ afterFullUpdateDelayDayCount="14"
afterEmptyUpdateDelayDayCount="3"

# The number of times to alert a single user prior to forcibly installing updates
maxNotificationCount="3"
maxNotificationCount="10"

# Calendar based start interval - hours and minutes.
startIntervalHour="13" # valid is 0-23. If left blank, daemon will launch every hour instead of once per day.
Expand Down
4 changes: 3 additions & 1 deletion com.github.grahampugh.nice_updater.prefs.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
<integer>14</integer>
<key>AlertTimeout</key>
<integer>3540</integer>
<key>IconCustomPath</key>
<string>/Library/Scripts/nice_updater_custom_icon.png</string>
<key>Log</key>
<string>/Library/Logs/Nice_Updater.log</string>
<key>MaxNotificationCount</key>
<integer>3</integer>
<integer>10</integer>
<key>UpdateInProgressTitle</key>
<string>Software Update In Progress</string>
<key>UpdateRequiredMessage</key>
Expand Down
14 changes: 10 additions & 4 deletions nice_updater.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/bin/bash

# Nice Updater 2
version="2.0.2"

# These variables will be automagically updated if you run build.sh, no need to modify them
preferenceFileFullPath="/Library/Preferences/com.github.grahampugh.nice_updater.prefs.plist"

Expand All @@ -15,6 +18,7 @@ iconCustomPath=$(defaults read "$preferenceFileFullPath" IconCustomPath)

scriptName=$(basename "$0")
JAMFHELPER="/Library/Application Support/JAMF/bin/jamfHelper.app/Contents/MacOS/jamfHelper"
current_user=$(/usr/sbin/scutil <<< "show State:/Users/ConsoleUser" | /usr/bin/awk -F': ' '/[[:space:]]+Name[[:space:]]:/ { if ( $2 != "loginwindow" ) { print $2 }}')

# set default icon if not included in build
system_build=$( /usr/bin/sw_vers -buildVersion )
Expand Down Expand Up @@ -64,7 +68,7 @@ trigger_nonrestart_updates() {
open_software_update() {
/usr/bin/open -W /System/Library/PreferencePanes/SoftwareUpdate.prefPane &
suPID=$!
writelog "Software Update PID $suPID"
writelog "Software Update PID: $suPID"
# While Software Update is open...
while kill -0 $suPID 2> /dev/null; do
sleep 1
Expand Down Expand Up @@ -95,10 +99,11 @@ alert_user() {

writelog "Notifying $loggedInUser of available updates..."
if [[ "$notificationsLeft" == "0" ]]; then
helperExitCode=$( "$JAMFHELPER" -windowType utility -lockHUD -title "$helperTitle" -heading "$subtitle" -description "$helperDesc" -button1 "Install Now" -defaultButton 1 -icon "$icon" -iconSize 100 )
helperExitCode=$( sudo -u "$current_user" "$JAMFHELPER" -windowType utility -lockHUD -title "$helperTitle" -heading "$subtitle" -description "$helperDesc" -button1 "Install Now" -defaultButton 1 -icon "$icon" -iconSize 100 )
else
"$JAMFHELPER" -windowType utility -title "$helperTitle" -heading "$subtitle" -description "$helperDesc" -button1 "Install Now" -button2 "Cancel" -defaultButton 2 -cancelButton 2 -icon "$icon" -iconSize 100 &
sudo -u "$current_user" "$JAMFHELPER" -windowType utility -title "$helperTitle" -heading "$subtitle" -description "$helperDesc" -button1 "Install Now" -button2 "Cancel" -defaultButton 2 -cancelButton 2 -icon "$icon" -iconSize 100 &
jamfHelperPID=$!
writelog "jamfHelper PID: $jamfHelperPID"
# since the "cancel" exit code is the same as the timeout exit code, we
# need to distinguish between the two. We use a while loop that checks
# that the process exists every second. If so, count down 1 and check
Expand Down Expand Up @@ -144,6 +149,7 @@ alert_user() {
}

alert_logic() {
was_closed=0
notificationCount=$(/usr/libexec/PlistBuddy -c "Print :users:$loggedInUser:alert_count" $preferenceFileFullPath 2> /dev/null | xargs)
if [[ "$notificationCount" -ge "$maxNotificationCount" ]]; then
writelog "$loggedInUser has been notified $notificationCount times; not waiting any longer."
Expand Down Expand Up @@ -213,7 +219,7 @@ main() {
# This function is intended to be run from a LaunchDaemon at intervals

writelog " "
writelog "======== Starting $scriptName ========"
writelog "======== Starting $scriptName v$version ========"

# See if we are blocking updates, if so exit
updatesBlocked=$(/usr/libexec/PlistBuddy -c "Print :updates_blocked" $preferenceFileFullPath 2> /dev/null | xargs 2> /dev/null)
Expand Down

0 comments on commit a2b12d9

Please sign in to comment.