Casper Imaging launching twice

endor-moon
Contributor II

For imaging individual machines I'm using a USB stick. Whether I use JAMF Casper Netinstall Image Creator or Macmule's AUTOCASPERNBI, I'm often seeing the Casper Imaging application launch twice. This can be from a USB stick or even from NetBoot.

If I don't cancel one of the instances things can get hairy very quickly as the first instance will start block copying the operating system to the target drive and at some point the second instance will try the same thing. Or, when quitting from either instance, the distribution point gets unmounted causing the remaining instance to lose its connection.

I saw this is a bug on GitHub for Macmule but haven't seen anything about this for JAMF's own tool. Looking at how each app gets called I am wondering if this is Apple's own bug. I believe the applications are being called by shell scripts that themselves are called because they have a plist in /Library/LaunchDaemons that has the RunAtLoad parameter set to true along with the LaunchOnlyOnce parameter set to true.

Perhaps JAMF could update the Casper Imaging application. It should have some defensive code in it to cause it to quit -- without unmounting the distribution point -- if it finds another instance of itself is already running. That would solve the problem. I am very big on defensive code. Programmers should always ask themselves what can go wrong and if it does, how would my program handle it. ;)

Of course the ideal solution is to find and fix the original bug, but often that takes too much time.

Any thoughts on this?

Cheers...

6 REPLIES 6

RogerH
Contributor II

@endor-moon I am also having the same issue. I was unaware of the github bug report though. I think it has to do with the OS trying to reopen any program that was running at last reboot. I don't think Casper imaging exits before the system reboots.

bentoms
Release Candidate Programs Tester

@RogerUL it's here.

I should really put that fix into ACNBI that's mentioned.

endor-moon
Contributor II

I agree, it may be that awful feature of opening all windows that were open. I feel that should not be the default behaviour, but no one asked my opinion. I wonder if there is a way to globally turn that off. I noticed even my Casper imaging stick remembered I had Console open last time I booted it. ;)

I should also say, @bentoms I am eternally grateful for the work you did on AUTOCASPERNBI and on these forums, as I'm sure are others here in the community.

RogerH
Contributor II

@endor-moon @bentoms I have a workaround for this. Once you create a boot stick make the changes using the terminal commands then just capture another image of it using disk utility make sure to select read only and run scan for restore on it. Then use that to create your boot sticks.

endor-moon
Contributor II

@RogerUL Sounds great, I will try it.

jacopo_pulici
Contributor

@RogerUL @bentoms I used a different approach to fix this issue.
Basically I modified the file /Applications/AutoCasperNBI.app/Contents/Resources/com.AutoCasperNBI.CasperImaging.plist as follow:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.AutoCasperNBI.CasperImaging</string>
    <key>ProgramArguments</key>
        <array>
            <string>sh</string>
            <string>/Users/Shared/loginUSB.sh</string>
        </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

and then I packaged the script "loginUSB.sh" and added it to the NBI image using the built in function of AutoCasperNBI (Options>Additionals>Install additionals packages) and eventually built the image.

Below the very simple script I'm using:

#!/bin/sh
defaults write -g ApplePersistence -bool no
open /Applications/Casper Imaging.app

Tested once and seems to work. At least you don't have to capture the image twice.

J