script that creates a launchd not working

jwojda
Valued Contributor II

I have a script that creates a launchD when run with various parameters. the file IS getting created in /Library/LaunchDeamons, but when I go to view it the data appears to be encrypted so I can't really tell if it's working properly. None of the other launchDs appear to be encrypted. Any thoughts on what I'm doing wrong?

# Construct Launchd plist in-place
defaults write "$LAUNCHD_PLIST" Label -string "$LAUNCHD_LABEL"
defaults write "$LAUNCHD_PLIST" RunAtLoad -bool YES
defaults write "$LAUNCHD_PLIST" ProgramArguments -array /usr/local/bin/jamf policy -trigger adminremove
defaults write "$LAUNCHD_PLIST" StartInterval -integer $ADMIN_DURATION
defaults write "$LAUNCHD_PLIST" LaunchOnlyOnce -bool YES
chmod 644 "$LAUNCHD_PLIST"
chown root:wheel "$LAUNCHD_PLIST"
2 REPLIES 2

mm2270
Legendary Contributor III

Are you able to cat the file to see its contents? If you aren't able to do something simple like a QuickLook on the plist file, then something likely went wrong in creating it. You should be able to see its contents easily in the Finder. But cat should work to show what's in it, and you might be able to see where it got messed up.

Also, since it's a plist and should be a standard xml format, you can try xmllint --format /Library/LaunchDaemons/com.somelaunchd.plist to see what xmllint has to say about it. Might show you what sections aren't formatted correctly.

ChrisCox
New Contributor III

You might need to convert the file from binary1 to xml1 to read it:
/usr/bin/plutil -convert xml1 "$LAUNCHD_PLIST"