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
This commit is contained in:
Greg Neagle
2009-09-28 17:24:32 +00:00
parent 5b438a55b7
commit 5ddacb31ff
3 changed files with 63 additions and 20 deletions
@@ -2,14 +2,14 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.03">
<data>
<int key="IBDocument.SystemTarget">1050</int>
<string key="IBDocument.SystemVersion">9J61</string>
<string key="IBDocument.SystemVersion">9L31a</string>
<string key="IBDocument.InterfaceBuilderVersion">677</string>
<string key="IBDocument.AppKitVersion">949.46</string>
<string key="IBDocument.AppKitVersion">949.54</string>
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="284"/>
<integer value="2"/>
<integer value="21"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1505,6 +1505,7 @@ ZHkgdG8gdXBkYXRlIG5vdywgeW91IGNhbiBjaG9vc2UgdG8gdXBkYXRlIGxhdGVyLg</string>
<string>-1.IBPluginDependency</string>
<string>-2.IBAttributePlaceholdersKey</string>
<string>-2.IBPluginDependency</string>
<string>-3.IBAttributePlaceholdersKey</string>
<string>-3.IBPluginDependency</string>
<string>2.IBPluginDependency</string>
<string>2.ImportedFromIB2</string>
@@ -1662,6 +1663,18 @@ ZHkgdG8gdXBkYXRlIG5vdywgeW91IGNhbiBjaG9vc2UgdG8gdXBkYXRlIGxhdGVyLg</string>
</object>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<object class="NSMutableDictionary">
<string key="NS.key.0">IBAppleScriptAttributeName</string>
<object class="IBAppleScriptInfoAttribute" key="NS.object.0">
<string key="name">IBAppleScriptAttributeName</string>
<reference key="object" ref="324411882"/>
<int key="appleScriptObjectID">0</int>
<int key="appleScriptScriptScope">0</int>
<nil key="appleScriptEventHandlerNames"/>
<string key="appleScriptScriptName">ManagedSoftwareUpdate.applescript</string>
<string key="appleScriptObjectName">theApplication</string>
</object>
</object>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<reference ref="9"/>
+2 -2
View File
@@ -17,11 +17,11 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.1</string>
<key>CFBundleSignature</key>
<string>mMSU</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<string>1.1</string>
<key>NSAppleScriptEnabled</key>
<string>YES</string>
<key>NSMainNibFile</key>
@@ -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