Posted on 02-13-2019 04:34 AM
Hello, we have a situation where we want to stop and start smb on a 10.13.6 server each night. I created a policy to run the script on a daily basis. The script is very simple:
serveradmin stop smb
sleep 10
serveradmin start smb
When the script is run via JAMF Remote it runs fine but when it runs via the policy I get the error posted below. Any help would be greatly appreciated.
Posted on 02-13-2019 04:58 AM
So first, did you copy your script into this? If so, it's missing it's shebang
#!/bin/sh
Secondly, the error it's replying with indicates the problem in that it can't actually find any binary "serveradmin" so I would go to the target and run a
$ which serveradmin
and confirm it's actually got that as a binary.
Posted on 02-13-2019 04:59 AM
.... Or is serveradmin your user? That would make more sense. JAMF policies run as root, that could be your problem.
[more coffee needed this morning]
Posted on 02-13-2019 06:05 AM
Forum formatting ate the pound sign on the shebang line.
Possibly you need the full path to serveradmin?
Posted on 02-13-2019 06:56 AM
@jrweber2016 See if this makes a difference.
#!/bin/bash
/Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin stop smb
sleep 10
/Applications/Server.app/Contents/ServerRoot/usr/sbin/serveradmin start smb
exit 0
Posted on 02-13-2019 07:28 AM
Like @ryan.ball suggested, try using the full path to serveradmin
. The most likely problem is that when the policy runs at check-in, it's being called by the Jamf LaunchDaemon and sometimes launchd jobs don't have the same PATH environment settings that the Terminal might have. When it runs, it probably doesn't know how to resolve serveradmin
into the full path to the binary, which it of course needs to be able to do to use it at all.
General rule of thumb when writing scripts is that, unless it's something very commonly used in bash, it's best to put in the full path to executables and commands, just to cover yourself.