Hi there,
I'm working on a policy that should be able to deploy a launchdaemon plist to all machines. The below script I found
here https://communithttps://community.jamf.com/t5/jamf-pro/remote-management-active-extension-attempt/m-p/119717y.jamf.com/t5/jamf-pro/remote-management-active-extension-attempt/m-p/119717
#!/bin/bash
cat << 'EOF' > /Library/Scripts/jamf-Restart.sh
#!/bin/bash
sudo killall jamf
sleep 10
sudo jamf policy
EOF
chmod 644 /Library/Scripts/jamf-Restart.sh
chown root:wheel /Library/Scripts/jamf-Restart.sh
cat << EOF > /Library/LaunchDaemons/jamf-Restart.plist
<?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>jamf.restart</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>/Library/Scripts/jamf-Restart.sh</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>StartInterval</key>
<integer>86400</integer>
</dict>
</plist>
EOF
chmod 644 /Library/LaunchDaemons/jamf-Restart.plist
chown root:wheel /Library/LaunchDaemons/jamf-Restart.plist
launchctl load -w /Library/LaunchDaemons/jamf-Restart.plist
And I have an extension attribute setup that should check if the 'jamf-Restart.plist' is loaded correctly.
#!/bin/sh
agentloaded=$(sudo launchctl list | grep "jamf.restart")
if [ -n "${agentloaded}" ]; then
echo "<result>Loaded</result>"
else
echo "<result>Not Loaded</result>"
fi
Couple of issues though. When I use "launchctl start jamf.restart" the "jamf-Restart.sh" script doesn't actually run. The other issue I'm having is that the extension attribute reports back 'Loaded' on some devices that don't have the 'jamf.restart' plist loaded up in launchdaemon.