The documentation is too general for this. I have two simple requirements:
- run the agent as user, not as root
- it should start automatically if the osx host reboots, or after an agent upgrade
Currently I tried to use /Library/LaunchDaemons/jetbrains...plist file and set the user name in that plist. However, the upgrade process puts files/folders as root under my user dir (where the agen home dir is living). And it cannot kill/restart itself during an upgrade. Just nothing happens.
I am lost in permissions
So what is the best way to have it what I want?
first I edit both jetbrains.teamcity.BuildAgent.plist and jetbrains.teamcity.BuildAgentUpgrade.plist.dist to have <key>UserName</key> <string>mynonrootuser</string>.
following the docs, and running the following as non-root I get permission denied:
bash-3.2$ sh ./mac.launchd.sh load
Could not open job overrides database at: /private/var/db/launchd.db/com.apple.launchd.peruser.501/overrides.plist: 13: Permission denied
launch_msg(): Socket is not connected
and if I add the user to the sudoers, then I get:
ash-3.2$ sudo sh ./mac.launchd.sh load
launchctl: Dubious ownership on file (skipping): jetbrains.teamcity.BuildAgent.plist
nothing found to load
However, at least, the .sh script writes the workingDir into the plist file. Now if If I do
sudo cp jetbrains.teamcity.BuildAgent.plist /Library/LaunchDaemons
sudo launchctl load jetbrains.teamcity.BuildAgent.plist
then it loads and runs.