How to I install bamboo agent as a daemon under Linux?
Asked by Sorin Sbarnea (Citrix):

While I was able to find documentation on how to install the agent as a service for Windows, I wasn't able to find information on how to do the same for Linux.I want to be sure that if the worked/agent computer is restarted, it will restart the agent.


Answers:
author: ArmenA
body: Hi Sorin,

If the only requirement is to start the agent when the remote agent machine gets restarted, you can configure the start remote agent command in the rc.local file the same way as it's [discussed here](http://www.linuxquestions.org/questions/linux-general-1/how-do-i-automatically-start-a-program-at-start-up-102154/).

Also, use the [remote agent](https://confluence.atlassian.com/display/BAMBOO/Bamboo+remote+agent+installation+guide) installer jar file that comes with the supervisor (wrapper). It's the big Download button on Administration -\> Agents -\> Install remote agent page. The wrapper will start the remote agent service if for some reason the remote agent process gets terminated.

Armen

comments: author: Sorin Sbarnea (Citrix)
body: Ok, that's a workaround but I don't like having to work to implement things that are supposed to be part of the core product. Installing and agent as a service should be the default behaviour. Also, I am impressed that Bamboo cannot start agents via SSH, like Jenkins. Yes, the user interface of Bamboo is much nicer than Jenkins, but it seems that Bamboo is not robust enough and it may require more maintenance work than Jenkins, just because it is not able to deal with workers that could come-and-go.

Anyway, thanks for the good answer, even if it's not what I was looking for it it may be the best alternative for the moment.


author: Kevin Ross
body: For systemd on ubuntu

```
vi /etc/systemd/system/bamboo-agent.service
```

Contents (be sure to adjust paths and user/group):

```
[Unit]Description=Atlassian Bamboo AgentAfter=syslog.target network.target   [Service]Type=forkingUser=appsGroup=appsExecStart=/apps/bamboo-agent/bin/bamboo-agent.sh startExecStop=/apps/bamboo-agent/bin/bamboo-agent.sh stop   [Install]WantedBy=multi-user.target
```

Then reload and start it (as root or using sudo)

```
systemctl daemon-reloadsystemctl start bamboo-agent
```

comments: author: Sergey Obozhin
body: how import .bash_profile bamboo user?


author: Mehmet Aydogdu
body: For my Amazon Linux 2 and bamboo agent 6.10.4 below worked. It installs bamboo-agent as a service and starts it.  

```
sudo /home/bamboo/bamboo-agent-home/bin/bamboo-agent.sh installstart
```

comments: author: kriegalex
body: this worked perfectly


author: Brad Riching
body: It did for me too. Frustrating to have gone through all the online docs only to realize that they haven't updated them to match the existing functionality of bamboo-agent.sh and that magical undocumented "installstart" argument. I wasted about 2 hours trying to adapt their documentation for bamboo server (as officially instructed by their docs) to manually configure a systemd service, inspecting and troubleshooting systemd logs. Kudos to you for finding it, [@Mehmet Aydogdu](/t5/user/viewprofilepage/user-id/206940) .


author: johnnyRhino
body: Found this on the <https://github.com/alienfast/bamboozled-ruby-plugin/wiki/Remote-Agents#overview> site.

For my Amazon Linux instance, all I ended up needing to do was after the standard installation and running it from the command line I then symlinked the shell script like below.

```
sudo ln -s /apps/bamboo-agent/bin/bamboo-agent.sh /etc/init.d/bamboo-agent
```

and then added the bamboo-agent to chkconfig like so

```
sudo chkconfig -add bamboo-agent.
```


author: Eric Fossum
body: Like @Kevin Ross's post I created an upstart task, which is what Ubuntu is now using (I guess). Tested on my own Ubuntu (14.04 LTS) server.

Create an Upstart config file like \`/etc/init/bamboo-agent.conf\` with the following text (changing the **author** and **/home/bamboo/bin/bamboo-agent.sh**path to suit your needs.

```
description "A Bamboo remote agent daemon job file for Upstart"author "Your name"start on runlevel [2345]stop on shutdownpre-start script    echo "[`date`] Bamboo remote agent starting" &gt;&gt; /var/log/bamboo-agent.log    setuid bamboo    exec /home/bamboo/bin/bamboo-agent.sh startend scriptpre-stop script   exec /home/bamboo/bin/bamboo-agent.sh stop   echo "[`date`] Bamboo remote agent stopping" &gt;&gt; /var/log/bamboo-agent.logend script
```

comments: author: Martin Goldhahn
body: Your script almost worked on Trusty. The setgid and setuid have to be set outside the scripts, once the scripts are running as the user you cannot redirect the output to /var/log (unless you give the user access to /var/log/bamboo-agent.log. Why not use upstart's logging facility?

```
description "A Bamboo remote agent daemon job file for Upstart"author "Your name"start on runlevel [2345]stop on shutdownsetuid bamboosetgid bamboopre-start script  logger "[`date`] Bamboo remote agent starting"  exec /opt/bamboo-agent-home/bin/bamboo-agent.sh startend scriptpre-stop script  exec /opt/bamboo-agent-home/bin/bamboo-agent.sh stop  logger "[`date`] Bamboo remote agent stopping"end script
```

<br />

<br />


author: Kevin Ross
body: Also see:

<https://github.com/alienfast/bamboozled-ruby-plugin/wiki/Remote-Agents#overview>


author: Kevin Ross
body: See:

<https://confluence.atlassian.com/display/BAMBOO/Bamboo+installation+guide+for+Linux?focusedCommentId=376838427#comment-376838427>

comments: author: vlada
body: that is bamboo server, not agent