Posted on 07-08-2015 08:35 AM
Here on campus we us an emergency notification product called NetSupport Notify http://www.netsupportnotify.com. It works fine on 10.9.5, however on 10.10.x it will not run. I let the company know, but they have no plans to fix it anytime soon. Before I entirely gave up I toyed around with the components of the app. If I open the GUI notifier (that sits in the menu bar) and open the notifier daemon as root in that order the app works just fine.
So I scripted the launch to run at start up as such:
#!/bin/sh
#opens the nsn-message.app
open /Library/NSNotifyAgent/gui/message/message.app
#pause to have the .app open and ready for daemon
sleep 5
#runs the notifydaemon
/Library/NSNotifyAgent/daemon/notifydaemon
This works if I run it via ARD after a fresh boot. However, if I make it a JSS policy that is no go because opening the notifydaemon never "completes" (screen shot of terminal command line attached to illustrate).
Fine; not a big deal. However, this ties up the JSS distribution point so the user could not use Self Service later. I thought about writing a timeout into the shell script before the "sudo /Library/NSNotifyAgent/daemon/notifydaemon" line, however the Mac does not have a timeout command like I have used on Ubuntu in the past.
Any ideas about how to launch the notifydaemon without a stalled policy would be welcome. launchctl or a launchd maybe?
I apologize in advance for my lack of scripting and command line skill. Thanks for your time.
Posted on 07-08-2015 08:47 AM
try an ampersand after the notifydaemon line in your script @bryce.carlson
Posted on 07-08-2015 08:48 AM
To me, this sounds like a perfect opportunity to use launchd.
Take a look at http://launchd.info/ and see what you can come up with. You'd want to make a package/dmg that is deployed via policy then is loaded after the policy completes (look at the Files and Processes > Execute Command option in a policy).
Depending on if you want the program and commands to run as the user or as root, you'll want to make it a LaunchAgent or LaunchDaemon. If you want it to run as the currently logged in user, make it a Global LaunchAgent. If you want it run as root make it a Global LaunchDaemon.
Posted on 07-08-2015 08:51 AM
I have no experience with this particular app, but you could try adding an ampersand to the end of the notifydaemon line and then exit after, like:
/Library/NSNotifyAgent/daemon/notifydaemon &
exit 0
The ampersands puts the command into the background, so it releases the script to move on, and you can exit. I'm not certain that will work. It kind of depends on how that notifydaemon actually works. If the exit in the script also causes the daemon to exit, then that would be a no-go, but I have a feeling it won't work that way.
Posted on 07-08-2015 08:58 AM
Here is a link to a post I made about how I get around forking threads with the JSS (since the jamf binary insists on waiting even with &):
https://jamfnation.jamfsoftware.com/discussion.html?id=14940
It's pretty easy (but non-obvious) to script the creation of a launchdaemon to fork something from a policy without requiring that policy to wait for it to complete. Echo out the launchdaemon to a plist and load it with launchctl. You can even echo out a script for that launchdaemon to run. Putting the files in /tmp makes them go away on reboot.
Posted on 07-08-2015 09:00 AM
I am a fan of LaunchDaemons for things like that, @alexjdale and @brandonusher are right on, and you probably need the & as mentioned as well.
Posted on 07-08-2015 09:19 AM
@nessts The ampersand did not work. As @alexjdale said JSS still was waiting around for the command to finish up. Even so it was still a good idea. I will keep that in for later so the log in tasks can run at the same time.
@mm2270 Also gave this a try. Same results JSS continued to wait for command:
/Library/NSNotifyAgent/daemon/notifydaemon &
Thanks for the suggestion. I will bake that in later as well.
@alexjdale and @brandonusher I will look at the LaunchDaemons info today and see if I can get that set up and report back. Thanks for the info!
Posted on 07-09-2015 12:03 PM
Part of the app/client launches on each boot now (this is with out JSS; want to make sure it runs before I look at packaging it for deployment). After toying with the info on http://launchd.info. The .app file that sits in the menu bar will launch with each startup, but the notifydaemon that listens will not load.
Here is what I have so far:
The /Library/LaunchDaemons/local.start.nsn.plist
<plist version="1.0">
<dict>
<key>Label</key>
<string>local.start.nsn.plist</string>
<key>ProgramArguments</key>
<array>
<string>/Library/uwgb-cit/nsn-start.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
The /Library/uwgb-cit/nsn-start.sh that the LaunchAgent calls
#!/bin/sh
#opens the nsn-message.app
open /Library/NSNotifyAgent/gui/message/message.app
#pause to have the .app open and ready for daemon
sleep 5
#runs the notifydaemon
sudo /Library/NSNotifyAgent/daemon/notifydaemon &
exit 0
Close but no cigar. Any other thoughts? Thanks all for your time!
Edit: I changed to just one LaunchAgent since that only threw the error:
7/9/15 4:09:21.194 PM com.apple.xpc.launchd[1]: (com.apple.imfoundation.IMRemoteURLConnectionAgent) The _DirtyJetsamMemoryLimit key is not available on this platform.