2

Ive been reading everywhere on how to do this, and I understand how to do it, but for some reason I cannot get it to work correctly.

I simply want to run a jar file on restart or boot, the jar file is a server bot for teamspeak3, and its basically needs to run after teamspeak has started.

The code I want to run on boot is

screen -d -m -S ts3bot java -jar JTS3ServerMod.jar

file name and location for the .conf:

$ cat /etc/init/serverbot.conf
description "serverbot"  
author "Peter"  

start on runlevel [3]  
stop on shutdown  

expect fork  

script  
   cd /home/teamspeak/sbot
   screen -d -m -S ts3bot java -jar JTS3ServerMod.jar >/var/log/sbot.log 2>&1  
   emit serverbot_running  
end script 

when I run the code as root this is what i get

$ start serverbot
start: Job failed to start

I then go into logs @ /var/log/upstart I see this

/proc/self/fd/9: 2: cd: can't cd to /home/teamspeak/sbot

If i change cd to chdir I still get the same results. the folder /home/teamspeak/sbot does exist

Anyone know what could be causing this? Ownership issues? When upstart runs the .conf, under what user is it run? I don't understand whats going on here.

root@fister4:/# namei -mo /home/teamspeak/sbot
f: /home/teamspeak/sbot
 drwxr-xr-x root      root      /
 drwxr-xr-x root      root      home
 drwxr-xr-x teamspeak teamspeak teamspeak
 drwxr-xr-- teamspeak teamspeak sbot
Zanna
  • 69,223
  • 56
  • 216
  • 327
  • Add the output of the command `namei -mo /home/teamspeak/sbot` as well, please. – muru Feb 20 '15 at 05:19
  • @muru I added it to the orginal post – Peter Keogan Feb 20 '15 at 05:32
  • At first I thought it could be permissions issue. But if you don't use the setuid or setgid stanzas, then the script is run as root, for whom permissions don't matter. (You could try giving others execute permissions on that directory though: `chmod +x /home/teamspeak/sbot`). – muru Feb 20 '15 at 05:38
  • @muru ya its pretty weird. I almost feel as if it is a bug. Ive tried moving the folder and renaming files but that doesnt work. – Peter Keogan Feb 20 '15 at 06:08

1 Answers1

2

I changed

cd /home/teamspeak/sbot

To

cd /home/teamspeak/sbot/

And it loaded into the directory correctly without an error