1

I have a shell script that copies a plist into /Library/LaunchDaemons with sudo cp com.example.plist /Library/LaunchDaemons then launches it with chown root com.example.plist and launchctl load com.example.plist

This works perfectly when run from the command line but I need to create a way to distribute this shell script to non-technical Mac users, so that they can just download the script, double click it, (probably enter their username/password into a dialog box) and hit OK. Something like a .pkg or .dmg would be ideal.

I have tried Platypus and appify but neither works with sudo because sudo causes it to hang while waiting for input that never comes. Is there a way to create an installer for this daemon or do I need to make an app?

Bob
  • 13
  • 2

1 Answers1

0

Maybe you could save a script like this as an application in AppleScript Editor:

do shell script "echo '<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<plist version=\"1.0\">
<dict>
  <key>Label</key>
  <string>com.example</string>
  <key>ProgramArguments</key>
  <array>
    <string>touch</string>
    <string>/aa</string>
  </array>
  <key>StartInterval</key>
  <integer>5</integer>
</dict>
</plist>' > /Library/LaunchDaemons/com.example.plist
launchctl load /Library/LaunchDaemons/com.example.plist" with administrator privileges
Lri
  • 26,768
  • 8
  • 84
  • 82
  • Thanks, this works! As a note: Applescript applications have to be distributed in a zip folder in order for other users to be able to install them. – Bob Nov 21 '13 at 23:31