KeepAlive Casper Imaging on NetBoot

cstout
Contributor III
Contributor III

I've been trying to solve this myself for hours and I've been receiving the same error no matter what I try.

I'm trying to write a launchagent plist with keepalive to ensure that in my stripped down NetBoot environment. If someone accidentally closes Casper Imaging it will re-open it. Simple, right?

I used LaunchControl to run a simple "open" command on the application and on my personal laptop it worked wonderfully. I'd close the app, it'd re-open. Perfect. It's just not the same level of simplicity when trying to implement this on the root user account. Something isn't translating and I don't know what it is.

Setting up LaunchControl the same way I did in my test, but this time logged in as root, only produces this error:

LSOpenURLsWithRole() failed with error -10810 for the file /Applications/Casper Imaging.app.

I even tried changing my NetBoot image to use a local admin account instead of root and configuring LaunchControl to run the process as root. That's the closest I got to accomplishing my goal, but the strange thing is that Casper Imaging would open, load, and quit itself right before the JSS authentication prompt. The launchagent would then re-open the app, and it would quit again, and so on.

Has anybody accomplished this already so I don't have to re-invent the wheel? Any ideas? Tips?

I'm not positive why this is failing. If I paste the same command that is specified in LaunchControl into Terminal, then Casper Imaging opens without an issue.

1 ACCEPTED SOLUTION

calum_rmit
New Contributor III

Hmm also i just noticed. dont use the open -a, the keep alive needs to know the binary it needs to keep open, not the command reqiuired to open it.

try using this

<key>KeepAlive</key> <true/> <key>Label</key> <string>local.job</string> <key>ProgramArguments</key> <array> <string>/Applications/Casper Imaging.app/Contents/MacOS/Casper Imaging</string> </array> <key>RunAtLoad</key> <true/>

View solution in original post

9 REPLIES 9

calum_rmit
New Contributor III

can you post your launchd item?

calum_rmit
New Contributor III

can you post your launchd item?

cstout
Contributor III
Contributor III

Example copy/paste of one of the variations I've been working with. The command "open -a '/Applications/Casper Imaging.app'" works when launched from Terminal.

<?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>KeepAlive</key>
    <true/>
    <key>Label</key>
    <string>local.job</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/open</string>
        <string>-a</string>
        <string>/Applications/Casper Imaging.app</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

calum_rmit
New Contributor III

and is this in /Library/LaunchDaemons or /System/Library/LaunchDaemons?

calum_rmit
New Contributor III

Hmm also i just noticed. dont use the open -a, the keep alive needs to know the binary it needs to keep open, not the command reqiuired to open it.

try using this

<key>KeepAlive</key> <true/> <key>Label</key> <string>local.job</string> <key>ProgramArguments</key> <array> <string>/Applications/Casper Imaging.app/Contents/MacOS/Casper Imaging</string> </array> <key>RunAtLoad</key> <true/>

calum_rmit
New Contributor III

i also highly recommend Lingon (http://www.peterborgapps.com/lingon/) for creating launchd items

cstout
Contributor III
Contributor III

The plist I posted above has been tried in both /Library/ and /System/Library/ locations. I will try what you posted as soon as I get back to the office. Thank you!

mm2270
Legendary Contributor III

LaunchControl is just as good as Lingon for creating launchd items I've found. In fact, LaunchControl seems a little better in some respects, although it has its own quirks.

I would agree with @calum_rmit though that you should try the full path to the executable in the command and not just the application bundle. I have a feeling that will work better.
You could also try using the open -b syntax which would use the Bundle Identifier to open the application, although on a NetBoot OS it may not work as well. In case you want to try it the syntax would be something like this-

open -b com.jamfsoftware.CasperImaging

cstout
Contributor III
Contributor III

Calum, that worked perfectly. I created a new plist and pasted in what you had there and loaded up the daemon and it works without issue. Thank you very much for your assistance. It's so good to have this working now.