From 5ddacb31ffcc891e597b0d87d4bd55543766b495 Mon Sep 17 00:00:00 2001 From: Greg Neagle Date: Mon, 28 Sep 2009 17:24:32 +0000 Subject: [PATCH] Revised the logic when running managedsoftwareupdate --manual to get "better" behavior when checking for updates manually. git-svn-id: http://munki.googlecode.com/svn/trunk@232 a4e17f2e-e282-11dd-95e1-755cbddbdd66 --- .../English.lproj/MainMenu.xib | 19 +++++- code/ManagedSoftwareUpdate/Info.plist | 4 +- .../ManagedSoftwareUpdate.applescript | 60 ++++++++++++++----- 3 files changed, 63 insertions(+), 20 deletions(-) diff --git a/code/ManagedSoftwareUpdate/English.lproj/MainMenu.xib b/code/ManagedSoftwareUpdate/English.lproj/MainMenu.xib index 21229cc5..6e4b97f6 100644 --- a/code/ManagedSoftwareUpdate/English.lproj/MainMenu.xib +++ b/code/ManagedSoftwareUpdate/English.lproj/MainMenu.xib @@ -2,14 +2,14 @@ 1050 - 9J61 + 9L31a 677 - 949.46 + 949.54 353.00 YES - + YES @@ -1505,6 +1505,7 @@ ZHkgdG8gdXBkYXRlIG5vdywgeW91IGNhbiBjaG9vc2UgdG8gdXBkYXRlIGxhdGVyLg -1.IBPluginDependency -2.IBAttributePlaceholdersKey -2.IBPluginDependency + -3.IBAttributePlaceholdersKey -3.IBPluginDependency 2.IBPluginDependency 2.ImportedFromIB2 @@ -1662,6 +1663,18 @@ ZHkgdG8gdXBkYXRlIG5vdywgeW91IGNhbiBjaG9vc2UgdG8gdXBkYXRlIGxhdGVyLg com.apple.InterfaceBuilder.CocoaPlugin + + IBAppleScriptAttributeName + + IBAppleScriptAttributeName + + 0 + 0 + + ManagedSoftwareUpdate.applescript + theApplication + + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin diff --git a/code/ManagedSoftwareUpdate/Info.plist b/code/ManagedSoftwareUpdate/Info.plist index 83b18298..ed14a61c 100644 --- a/code/ManagedSoftwareUpdate/Info.plist +++ b/code/ManagedSoftwareUpdate/Info.plist @@ -17,11 +17,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.0 + 1.1 CFBundleSignature mMSU CFBundleVersion - 1.0 + 1.1 NSAppleScriptEnabled YES NSMainNibFile diff --git a/code/ManagedSoftwareUpdate/ManagedSoftwareUpdate.applescript b/code/ManagedSoftwareUpdate/ManagedSoftwareUpdate.applescript index c40c3256..45cbc3fd 100755 --- a/code/ManagedSoftwareUpdate/ManagedSoftwareUpdate.applescript +++ b/code/ManagedSoftwareUpdate/ManagedSoftwareUpdate.applescript @@ -251,35 +251,65 @@ on alert ended theObject with reply withReply -- trigger managedinstaller via launchd WatchPath -- we touch a file that launchd is is watching -- launchd, in turn, launches managedsoftwareupdate --installonly as root - set triggerpath to quoted form of (managedInstallDir & "/.managedinstall.launchd") - do shell script "/usr/bin/touch " & triggerpath - quit + try + set triggerpath to quoted form of (managedInstallDir & "/.managedinstall.launchd") + do shell script "/usr/bin/touch " & triggerpath + quit + on error + show window "mainWindow" + display alert "Cannot start installation session" message ¬ + "There is a configuration problem with the managed software installer. Contact your systems administrator." default button "Quit" as informational attached to window 1 + end try end if if button returned of withReply is "Quit" then -- acknowleged no new software available, or installing later quit end if - end alert ended on activated theObject - set activationCount to activationCount + 1 set installitems to my itemstoinstall() if (count of installitems) > 0 then + my initTable() + my updateTable() show window "mainWindow" set enabled of (menu item "installAllMenuItem" of menu "updateMenu" of menu 1) to true else - if activationCount is 1 then - -- trigger manual update check, but only on launch - -- we touch a file that launchd is is watching - -- launchd, in turn, launches managedsoftwareupdate --manualcheck as root - set triggerpath to quoted form of (managedInstallDir & "/.updatecheck.launchd") - do shell script "/usr/bin/touch " & triggerpath - -- when it's done, it sends an activate message to us again - else + -- did managedsoftwareupdate --manual just finish? + set now to current date + tell application "System Events" + try + set ManagedInstallPrefsFile to "/Library/Preferences/ManagedInstalls.plist" + set ManagedInstallPrefs to value of property list file ManagedInstallPrefsFile + + set lastNotifiedDate to |LastNotifiedDate| of ManagedInstallPrefs + on error + set lastNotifiedDate to date "Thursday, January 1, 1970 12:00:00 AM" + end try + end tell + if now - lastNotifiedDate < 10 then + -- managedsoftwareupdate --manual just ran, but there are no updates show window "mainWindow" display alert "Your software is up to date." message ¬ "There is no new software for your computer at this time." default button "Quit" as informational attached to window 1 + else + tell application "System Events" + set processList to name of every process + end tell + if processList contains "MunkiStatus" then + tell application "MunkiStatus" to activate + else + try + -- touch a file to get launchd to run managedsoftwareupdate --manual as root + set triggerpath to quoted form of (managedInstallDir & "/.updatecheck.launchd") + do shell script "/usr/bin/touch " & triggerpath + -- when it's done, it sends an activate message or launches us again + on error + show window "mainWindow" + display alert "Cannot check for updates." message ¬ + "There is a configuration problem with the managed software installer. Contact your systems administrator." default button "Quit" as informational attached to window 1 + end try + end if end if end if end activated @@ -287,8 +317,8 @@ end activated on opened theObject if the name of theObject is "mainWindow" then - my initTable() - my updateTable() + --my initTable() + --my updateTable() end if end opened