Wednesday 3 October 2018

linux - Needing to open OS X bash script as via launchd IN a terminal window

I've got a lengthy and complex bash script which works OK, but I'm trying to automate my deployment process and I'm flummoxed at this point.


I can get the script to run as a LaunchAgent no problem, but of course it happens in the background on boot. So I have a pause at the start of the script where I can press any button if I need to interrupt the script.


The problem with that is I need the script to open in a Terminal window so I can press the button to cancel or continue it. This is where my trouble starts.


The script has many sudo commands. I've created the below .plist and I can load it manually just fine. It works and loads the script and everything works. However, it does nothing at boot and just exits with error code 1 in Console.


I've tried putting it in /Library/LaunchAgents and /Library/LaunchDaemons. It basically needs to open the terminal window as root so that all the commands within the script will run as root without the need for me to manually enter the password.






Label
com.deecies.first
ProcessType
Interactive
ProgramArguments

open
-a
terminal
/Users/admin/first-boot.command

RunAtLoad




I tried specifying /usr/bin/open and the full path to Terminal.app too, but to no avail. I've tried adding sudo string first and /usr/bin/sudo but nothing either.


I did manage it to get a Terminal window to open when it was placed in /Library/LaunchAgents, however it doesn't appear to be opening either Terminal, or the script, as root, as I get "permission denied" for all the commands in the script that would require sudo.

No comments:

Post a Comment

Where does Skype save my contact's avatars in Linux?

I'm using Skype on Linux. Where can I find images cached by skype of my contact's avatars? Answer I wanted to get those Skype avat...