Bamboo on Linux. Wont start with su bamboo
Asked by paulwade:

its been a pretty frustrating few days trying to get this working. I want to deploy to heroku via a git push. This works fine if I push the code logged into the linux server with my account but not via bamboo I suspect this is because bamboo is running as root. Also if I run bamboo with ./start-bamboo.sh logged in as that user my deploy works as expected. The problem is trying to get the linux service to run as the bamboo user. I have followed atlassians guide on running bamboo as a linux service. The init.d script they provide doesn't seem to work at all. Bamboo never starts up. Then I tried copying how JIRA does it. So basically copy the JIRA init.d script that the JIRA installer created (the installers for JIRA and stash are a life saver) this is a very simple script, obviously I update it to point to my bamboo install and not JIRA but it works great. Unfortunately that still runs as root. So I also made some minor changes to the start-bamboo.sh script in the /opt/bamboo/bin install dir. as such

```
JIRA_USER="bamboo"
echo executing using dedicated user: $JIRA_USER
if [ -x "/sbin/runuser" ]; then
    sucmd="/sbin/runuser"
else
    sucmd="su"
fi

if [ "$PRGRUNMODE" == "true" ] ; then
    $sucmd -m $JIRA_USER -c "$PRGDIR/catalina.sh run $@"
else
    $sucmd -m $JIRA_USER -c "$PRGDIR/startup.sh $@"
fi
```

This SEEMS to work tomcat starts according to the output. However when I do this bamboo NEVER responds and I get no log details.

Has someone successfully configured their bamboo service to run under a different user?


Answers:
author: Reinhard Moser
body: Hi Paul,

i start bamboo as user bamboo5 on a Debian linux host with this script:

```
#!/bin/sh### BEGIN INIT INFO# Provides:          bamboo5# Required-Start:    $local_fs $remote_fs $network $syslog nginx# Required-Stop:     $local_fs $remote_fs $network $syslog# Default-Start:     2 3 4 5# Default-Stop:      0 1 6# Short-Description: starts bamboo5 ci server# Description:       starts bamboo5 using start-stop-daemon### END INIT INFOPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binBAMBOO_PATH=/opt/atlassian/bambooBAMBOO_HOME=/var/lib/bambooDAEMON_DIR=$BAMBOO_PATH/binSTART_BIN=$DAEMON_DIR/start-bamboo.shSTOP_BIN=$DAEMON_DIR/stop-bamboo.shNAME=bamboo5DESC="Atlassian Bamboo 5 CI Server"RUN_AS=bamboo5PIDFILE=/var/run/bamboo/bamboo5.pidexport BAMBOO_PID=$BAMBOO_HOME/bamboo.pidtest -x $DAEMON || exit 0set -e. /lib/lsb/init-functionscase "$1" in    start)        echo -n "Starting $DESC: "        start-stop-daemon --start --chuid $RUN_AS --quiet --pidfile $PIDFILE \            --exec $START_BIN -- start || true        echo "$NAME."        ;;    stop)        echo -n "Stopping $DESC: "        start-stop-daemon --stop --chuid $RUN_AS --quiet --pidfile $PIDFILE \            --exec $STOP_BIN -- stop || true        echo "$NAME."        ;;    *)         echo "Usage: $NAME {start|stop}" &gt;&amp;2        exit 1        ;;esacexit 0
```

This works without problems. Have you changed the ownership of all bamboo files to the bamboo user? When you run the server as root than lot's of files are created as root and only the root user can write to these files.

Maybe another problem is your bamboo user has the shell **/bin/false** - try to change this to another shell.

Cheers

Reinhard


Tags: bamboo-administration