Skip to content
This repository has been archived by the owner on Nov 10, 2019. It is now read-only.

Commit

Permalink
1.4.0 commit #1
Browse files Browse the repository at this point in the history
• #92#96#101#103#105#106
  • Loading branch information
macmule committed Sep 13, 2017
1 parent 52c7fa1 commit fb2b33d
Show file tree
Hide file tree
Showing 4 changed files with 224 additions and 37 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,6 @@
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "AutoCasperNBI/AutoCasperNBIAppDelegate.applescript"
timestampString = "495154533.493349"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "4393"
endingLineNumber = "4393"
landmarkName = "on copyBootEfi_(sender)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
Expand Down
4 changes: 2 additions & 2 deletions AutoCasperNBI/AutoCasperNBI-Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.3.4</string>
<string>1.4.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand All @@ -27,7 +27,7 @@
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2016 macmule. All rights reserved.</string>
<string>Copyright © 2017 macmule. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>MainMenu</string>
<key>NSPrincipalClass</key>
Expand Down
241 changes: 222 additions & 19 deletions AutoCasperNBI/AutoCasperNBIAppDelegate.applescript
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ script AutoCasperNBIAppDelegate
property showBuildProcessWindow : ""
property selectedOSdmgPath : ""
property selectedOSdmgMountPath : ""
property selectedOSdmgKind : ""
property selectedOSdmgVersion : ""
property selectedOSBuilddmgVersion : ""
property selectedAppPath : ""
Expand Down Expand Up @@ -502,17 +503,35 @@ script AutoCasperNBIAppDelegate
-- There can be (and usually are) multiple entities. We're looking for the one that contains a "mount-point" key
-- Start with a default value of None
set selectedOSdmgMountPath to None
set selectedOSdmgKind to None
-- Loop through each entry, looking for the key's value
repeat with anItem in theEntities
set selectedOSdmgMountPath to anItem's objectForKey_("mount-point")
-- If we found a value, exit with it
if (selectedOSdmgMountPath is not equal to None) then exit repeat
set selectedOSdmgKind to (anItem's objectForKey:"volume-kind")
-- If we have a value, then check.. if APFS a few new mount-points appear that we need to discard
if (selectedOSdmgMountPath is not equal to missing value) then
set selectedOSdmgMountPath to (NSString's stringWithString:selectedOSdmgMountPath) as string
if (selectedOSdmgMountPath as string is not equal to "/Volumes/Preboot") and (selectedOSdmgMountPath as string is not equal to "/Volumes/Recovery") then
set selectedOSdmgMountPath to selectedOSdmgMountPath as text
exit repeat
end if
end if
-- Guess we didn't find one, let's check the next ...
end repeat
-- Set to text of variable
set selectedOSdmgMountPath to selectedOSdmgMountPath as text
-- If APFS source byt not 10.13
if ((NSString's stringWithString:selectedOSdmgKind) as string) is equal to "apfs" then
--Log Action
set logMe to "APFS source, not a 10.13 host"
logToFile_(me)
-- Error advising we cannot mount the DMG
set my selectedOSDMGTextField to "Cannot Mount DMG"
display dialog selectedOSdmgPath & " is an APFS Volume, & therefore needs 10.13 to create an NBI from." with icon 0 buttons {"OK"}
-- Reset OSDMG Icons & hide cog
doResetOSDMGIcons_(me)
-- If we have an value for the OS DMG's mount-point, try & get OS version
if selectedOSdmgMountPath is not equal to None then
else if selectedOSdmgMountPath is not equal to None then
set logMe to "Mounted to: " & selectedOSdmgMountPath
logToFile_(me)
-- Try & read /System/Library/CoreServices/SystemVersion.plist
Expand Down Expand Up @@ -1799,7 +1818,7 @@ script AutoCasperNBIAppDelegate
-- Calculate progressbar max length, depending on selection
on calcBuildProgressBarMax_(sender)
-- Reset
set my buildProcessProgressBarMax to 72
set my buildProcessProgressBarMax to 76
-- Update build Process ProgressBar
set my buildProcessProgressBar to 0
-- Check if reduce NetBoot Image is ticked
Expand Down Expand Up @@ -1842,6 +1861,10 @@ script AutoCasperNBIAppDelegate
if selectedOSdmgVersionMajor is 9 then
set my buildProcessProgressBarMax to buildProcessProgressBarMax + 1
end if
-- If we're creating on a 10.13.x netboot
if selectedOSdmgVersionMajor is 13 then
set my buildProcessProgressBarMax to buildProcessProgressBarMax + 2
end if
-- If we're creating a Restorable DMG
if createReadOnlyDMG is true
set my buildProcessProgressBarMax to buildProcessProgressBarMax + 2
Expand Down Expand Up @@ -2335,7 +2358,7 @@ script AutoCasperNBIAppDelegate
set my buildProcessProgressBar to buildProcessProgressBar + 1
delay 0.1
-- Delete all in the location except those that are given below
do shell script "find " & quoted form of netBootDmgMountPath & "/System/Library/PreferencePanes/* -maxdepth 0 -not -path \"*DateAndTime.prefPane*\" -not -path \"*Displays.prefPane*\" -not -path \"*Network.prefPane*\" -not -path \"*SharingPref.prefPane*\" -not -path \"*StartupDisk.prefPane*\" -exec rm -rf {} \\;" user name adminUserName password adminUsersPassword with administrator privileges
do shell script "find " & quoted form of netBootDmgMountPath & "/System/Library/PreferencePanes/* -maxdepth 0 -not -path \"*DateAndTime.prefPane*\" -not -path \"*Displays.prefPane*\" -not -path \"*Keyboard.prefPane*\" -not -path \"*Network.prefPane*\" -not -path \"*SharingPref.prefPane*\" -not -path \"*StartupDisk.prefPane*\" -exec rm -rf {} \\;" user name adminUserName password adminUsersPassword with administrator privileges
--Log Action
set logMe to "Deleted Preference Panes from: " & netBootDmgMountPath & "/System/Library/PreferencePanes/"
logToFile_(me)
Expand Down Expand Up @@ -2364,13 +2387,13 @@ script AutoCasperNBIAppDelegate
set logMe to "Emptied " & netBootDmgMountPath & "/Library/Audio/"
logToFile_(me)
-- Update Build Process Window's Text Field
set my buildProcessTextField to "Emptying /Library/Caches/"
delay 0.1
--set my buildProcessTextField to "Emptying /Library/Caches/"
--delay 0.1
-- Empty the below folder
do shell script "/bin/rm -rf " & quoted form of netBootDmgMountPath & "/Library/Caches/*" user name adminUserName password adminUsersPassword with administrator privileges
--do shell script "/bin/rm -rf " & quoted form of netBootDmgMountPath & "/Library/Caches/*" user name adminUserName password adminUsersPassword with administrator privileges
--Log Action
set logMe to "Emptied " & netBootDmgMountPath & "/Library/Caches/"
logToFile_(me)
--set logMe to "Emptied " & netBootDmgMountPath & "/Library/Caches/"
--logToFile_(me)
-- Update Build Process Window's Text Field
set my buildProcessTextField to "Emptying /Library/Desktop Pictures/"
delay 0.1
Expand Down Expand Up @@ -3042,8 +3065,8 @@ script AutoCasperNBIAppDelegate
set logMe to "Deleted " & netBootDmgMountPath & "/Library/Preferences/com.apple.dockfixup.plist"
logToFile_(me)
end if
-- Disable AppNap
disableAppNap_(me)
-- Deletes launchAgent that triggers "New to Mac?" notification
deleteTouristd_(sender)
on error
--Log Action
set logMe to "Error: Deleting /Library/Preferences/com.apple.dockfixup.plist"
Expand All @@ -3057,6 +3080,47 @@ script AutoCasperNBIAppDelegate
end try
end deleteDockFixUp_

-- Deletes launchAgent that triggers "New to Mac?" notification
on deleteTouristd_(sender)
-- Update Build Process Window's Text Field
set my buildProcessTextField to "Disabling touristd"
delay 0.1
-- Update build Process ProgressBar
set my buildProcessProgressBar to buildProcessProgressBar + 1
try
set variableVariable to netBootDmgMountPath & "/System/Library/LaunchAgents/com.apple.touristd.plist"
set file_path to current application's NSString's stringWithString:variableVariable
set fileManager to current application's NSFileManager's defaultManager()
if (item 1 of (fileManager's fileExistsAtPath:file_path isDirectory:(reference))) as boolean = true then
--Log Action
set logMe to "Found com.apple.touristd.plist: " & file_path
logToFile_(me)
-- Delete the below folder, silently error if doesn't exist
try
do shell script "/bin/rm " & quoted form of variableVariable user name adminUserName password adminUsersPassword with administrator privileges
end try
--Log Action
set logMe to "Deleted " & file_path
logToFile_(me)
-- Disable AppNap
disableAppNap_(me)
else
-- Disable AppNap
disableAppNap_(me)
end if
on error
--Log Action
set logMe to "Error: Disabling touristd"
logToFile_(me)
-- Set to false to display
set my userNotifyErrorHidden to false
-- Set Error message
set my userNotifyError to "Error: Disabling touristd"
-- Notify of errors or success
userNotify_(me)
end try
end deleteTouristd_

-- Disable AppNap
on disableAppNap_(sender)
try
Expand Down Expand Up @@ -4167,7 +4231,7 @@ script AutoCasperNBIAppDelegate
logToFile_(me)
-- Update dylyd cache, this can error on success.
try
do shell script "/usr/bin/update_dyld_shared_cache -root " & quoted form of netBootDmgMountPath & " -universal_boot -force" user name adminUserName password adminUsersPassword with administrator privileges
do shell script quoted form of netBootDmgMountPath & "/usr/bin/update_dyld_shared_cache -root " & quoted form of netBootDmgMountPath & " -universal_boot -force" user name adminUserName password adminUsersPassword with administrator privileges
end try
--Log Action
set logMe to "Successfully created dyld caches"
Expand Down Expand Up @@ -4236,8 +4300,8 @@ script AutoCasperNBIAppDelegate
--Log Action
set logMe to "Deleted " & netBootDmgMountPath & "/System/Library/Extensions/JMicronATA.kext"
logToFile_(me)
-- Generate the Kernel cache
generateKernelCache_(me)
-- Delete launchd rebuild caches
deleteLaunchdRebuildCaches_(me)
on error
--Log Action
set logMe to "Error: Deleting extensions"
Expand All @@ -4250,11 +4314,91 @@ script AutoCasperNBIAppDelegate
userNotify_(me)
end try
else
-- Generate the Kernel cache
generateKernelCache_(me)
-- Delete launchd rebuild caches
deleteLaunchdRebuildCaches_(me)
end if
end reduceKernelCache_

-- Delete launchd rebuild caches
on deleteLaunchdRebuildCaches_(sender)
try
set variableVariable to netBootDmgMountPath & "/var/db/.launchd_rebuild_caches"
set file_path to current application's NSString's stringWithString:variableVariable
set fileManager to current application's NSFileManager's defaultManager()
if (item 1 of (fileManager's fileExistsAtPath:file_path isDirectory:(reference))) as boolean = true then
-- Update Build Process Window's Text Field
set my buildProcessTextField to "Deleting /var/db/.launchd_rebuild_caches"
delay 0.1
-- Update build Process ProgressBar
set my buildProcessProgressBar to buildProcessProgressBar + 1
--Log Action
set logMe to "Found: " & file_path
logToFile_(me)
-- Delete the below file, silently error if doesn't exist
try
do shell script "/bin/rm " & quoted form of variableVariable user name adminUserName password adminUsersPassword with administrator privileges
end try
--Log Action
set logMe to "Deleted: " & file_path
logToFile_(me)
-- Create xpc extensions cache files
createXpcExtensionsCaches_(me)
else
-- Create xpc extensions cache files
createXpcExtensionsCaches_(me)
end if
on error
--Log Action
set logMe to "Error: Creating xpc extensions cache"
logToFile_(me)
-- Set to false to display
set my userNotifyErrorHidden to false
-- Set Error message
set my userNotifyError to "Error: xpc extensions cache"
-- Notify of errors or success
userNotify_(me)
end try
end deleteLaunchdRebuildCaches

-- Create xpc extensions cache files
on createXpcExtensionsCaches_(sender)
try
set variableVariable to netBootDmgMountPath & "/usr/libexec/xpccachectl"
set file_path to current application's NSString's stringWithString:variableVariable
set fileManager to current application's NSFileManager's defaultManager()
if (item 1 of (fileManager's fileExistsAtPath:file_path isDirectory:(reference))) as boolean = true then
-- Update Build Process Window's Text Field
set my buildProcessTextField to "Creating xpc extensions cache"
delay 0.1
-- Update build Process ProgressBar
set my buildProcessProgressBar to buildProcessProgressBar + 1
--Log Action
set logMe to "Creating xpc extensions cache on : " & netBootDmgMountPath
logToFile_(me)
-- Update xpc extension caches
do shell script quoted form of netBootDmgMountPath & "/usr/libexec/xpccachectl --base " & quoted form of netBootDmgMountPath user name adminUserName password adminUsersPassword with administrator privileges
--Log Action
set logMe to "Successfully xpc extensions cache"
logToFile_(me)
-- Generate the Kernel cache
generateKernelCache_(me)
else
-- Generate the Kernel cache
generateKernelCache_(me)
end if
on error
--Log Action
set logMe to "Error: Creating xpc extensions cache"
logToFile_(me)
-- Set to false to display
set my userNotifyErrorHidden to false
-- Set Error message
set my userNotifyError to "Error: xpc extensions cache"
-- Notify of errors or success
userNotify_(me)
end try
end createXpcExtensionsCaches

-- Generate the Kernel cache
on generateKernelCache_(sender)
try
Expand Down Expand Up @@ -4398,8 +4542,8 @@ script AutoCasperNBIAppDelegate
--Log Action
set logMe to "Set ownership to root:staff on " & netBootDirectory & "/i386/booter"
logToFile_(me)
-- Copy PlatformSupport.plist
copyPlatformSupportPlist_(me)
-- Copy Wifi Folder if exists
copyWifiFolder_(me)
on error
--Log Action
set logMe to "Error: Copying booter.efi"
Expand All @@ -4413,6 +4557,65 @@ script AutoCasperNBIAppDelegate
end try
end copyBootEfi_

-- Copy Wifi Folder if exists
on copyWifiFolder_(sender)
try
set variableVariable to netBootDmgMountPath & "/usr/share/firmware/wifi/"
set file_path to current application's NSString's stringWithString:variableVariable
set fileManager to current application's NSFileManager's defaultManager()
if (item 1 of (fileManager's fileExistsAtPath:file_path isDirectory:(reference))) as boolean = true then
--Log Action
set logMe to "Found wifi folder: " & file_path
logToFile_(me)
-- Update build Process ProgressBar
set my buildProcessProgressBar to buildProcessProgressBar + 1
--Log Action
set logMe to "Trying to create folder " & netBootDirectory & "/i386/wifi"
logToFile_(me)
-- Create the wifi folder
do shell script "/bin/mkdir -p " & quoted form of netBootDirectory & "/i386/wifi" user name adminUserName password adminUsersPassword with administrator privileges
--Log Action
set logMe to "Created folder " & netBootDirectory & "/i386/wifi"
logToFile_(me)
-- Update Build Process Window's Text Field
set my buildProcessTextField to "Copying wifi folder"
delay 0.1
-- Update build Process ProgressBar
set my buildProcessProgressBar to buildProcessProgressBar + 1
--Log Action
set logMe to "Trying to copy wifi folder from" & quoted form of variableVariable
logToFile_(me)
set logMe to "command: /bin/cp -R " & quoted form of variableVariable & space & quoted form of netBootDirectory & "/i386/wifi/"
logToFile_(me)
-- Create the wifi folder
do shell script "/bin/cp -R " & quoted form of variableVariable & space & quoted form of netBootDirectory & "/i386/wifi/" user name adminUserName password adminUsersPassword with administrator privileges
--Log Action
set logMe to "Successfully copied wifi folder"
logToFile_(me)
-- Correct ownership
do shell script "/usr/sbin/chown -R root:staff " & quoted form of netBootDirectory & "/i386/wifi" user name adminUserName password adminUsersPassword with administrator privileges
--Log Action
set logMe to "Set ownership to root:staff on " & netBootDirectory & "/i386/wifi"
logToFile_(me)
-- Copy PlatformSupport.plist
copyPlatformSupportPlist_(me)
else
-- Copy PlatformSupport.plist
copyPlatformSupportPlist_(me)
end if
on error
--Log Action
set logMe to "Error: Copying wifi folder"
logToFile_(me)
-- Set to false to display
set my userNotifyErrorHidden to false
-- Set Error message
set my userNotifyError to "Error: Copying wifi folder"
-- Notify of errors or success
userNotify_(me)
end try
end copyWifiFolder_

-- Copy PlatformSupport.plist
on copyPlatformSupportPlist_(sender)
try
Expand Down

0 comments on commit fb2b33d

Please sign in to comment.