startup script CentOS to run as different user

Discussion of the Web Interface for Transmission, formerly known as Clutch. This applies to all version of Transmission
Post Reply
Ortix
Posts: 28
Joined: Wed Nov 18, 2009 2:03 am

startup script CentOS to run as different user

Post by Ortix »

I'm trying to let transmission startup automatically when the server boots up.

I am trying to run this command but it says that there is an error loading the config file...

Code: Select all

sudo -u torrent transmission-daemon -g /home/torrent/.config/transmission-daemon/settings.json -f
any ideas? I'm running CentOS 5
Moe
Posts: 16
Joined: Fri Dec 17, 2010 4:38 am

Re: startup script CentOS to run as different user

Post by Moe »

What's the error message?
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: startup script CentOS to run as different user

Post by rb07 »

Is the subject a question? You don't show any script, just a problem which looks like a simple permissions problem.

A real script for Linux is something like shown here: Wiki The interesting part is how the script is parametrized, for instance to define which user should run the daemon, and also the process needed, apart from the script, to set things up "by hand" (meaning, if you install a package the package should take care of things automatically, you just optionally modify parameters).
Ortix
Posts: 28
Joined: Wed Nov 18, 2009 2:03 am

Re: startup script CentOS to run as different user

Post by Ortix »

@Moe:
exactly what i said, error loading config file.

rb07:

I'm basically asking on how to start the transmission-daemon at system startup as another user. Above i showed what i did and that didn't work. Now i am asking for help on how to do it. Nothing too complicated (i hope). Just want to start transmission-daemon as the user "torrent". I didn't install the package because, like i said, i'm running CentOS which isn't supported natively so I had to build everything from scratch. So i don't think the wiki will do anything since CentOS isn't a BSD derivative. (if i'm correct)
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: startup script CentOS to run as different user

Post by rb07 »

Ortix wrote:So i don't think the wiki will do anything since CentOS isn't a BSD derivative.
What makes you think the article on the Wiki is only for BSD derivatives? Oh, I see, the first line on the article is badly written, Debian and Ubuntu are not BSD derivatives, that line is wrong.

CentOS is a Red Hat RHEL clone, which is just one of the many of Debian derivatives.

The way to make certain (since I don't use CentOS) is to run the script with "#!/bin/sh -x" at the top, that way you'll see each command executing and any problems if any exists. Or you can test the existence of the commands used, for instance do "which start-stop-daemon", and that correct places are used (RHEL doesn't use /etc/init.d if I remember correctly, CentOS might have copied that, or just like everybody else, made a symbolic link to /etc/rc.d/init.d).
Ortix
Posts: 28
Joined: Wed Nov 18, 2009 2:03 am

Re: startup script CentOS to run as different user

Post by Ortix »

unfortunately start-stop-daemon doesn't exist on CentOS. I managed to build it from a debian source and got it to work, but there are still some commands missing... I don't think the init.d script thing is going to work in it's current incarnation.

this is the exact error:

Code: Select all

root@server1 [/home/torrent/tmp]# /etc/init.d/transmission-daemon start
/etc/init.d/transmission-daemon: line 9: client.: command not found
/etc/init.d/transmission-daemon: line 52: script.: command not found
Starting bittorrent client transmission-daemon...
start-stop-daemon: --start needs --exec or --startas
Try `start-stop-daemon --help' for more information.
/etc/init.d/transmission-daemon: line 89: --make-pidfile: command not found
start-stop-daemon: --start needs --exec or --startas
Try `start-stop-daemon --help' for more information.
/etc/init.d/transmission-daemon: line 94: --make-pidfile: command not found
   Starting bittorrent client transmission-daemon failed
rb07
Posts: 1400
Joined: Sun Aug 24, 2008 3:14 am

Re: startup script CentOS to run as different user

Post by rb07 »

What are you doing to the script?
Ortix wrote:/etc/init.d/transmission-daemon: line 9: client.: command not found
Line 8 of the original:

Code: Select all

# Short-Description: Start the transmission BitTorrent daemon client.
It is a comment, not a command that is executed.
Ortix wrote:/etc/init.d/transmission-daemon: line 52: script.: command not found
Line 50 in the original:

Code: Select all

# PATH should only include /usr/* if it runs after the mountnfs.sh script.
Again it was a comment, you seem to have truncated both lines and put the right-most word in a new line by itself.

Of course that is not going to work.

So first thing is copy the original verbatim to a file. Then edit the first line so that it ends with a space and -x. Run it by hand and see what is going on (the lines that start with + are the lines on the script as they are being executed, other lines are the output of the execution).
Ortix
Posts: 28
Joined: Wed Nov 18, 2009 2:03 am

Re: startup script CentOS to run as different user

Post by Ortix »

I see what happened. When i pasted in nano, some things were shifted to a new line because the window was too small... a real wtf situation :P lemme see if it works now

edit1:
ok it kinda works.. when i reboot the server, transmission doesn't start automagically :(

edit2:
got it to work. I just plugged the command in my rc.local file :)

edit3:
Ok so it loads up after a reboot, i can open up the page, but then it says that it can't connect to the server and the details give me a 400 error...
it seems as if though something has messed up my entire transmission installation because this happens even if i run transmission manually as root..

EDIT4:
reinstalled the whole jazz and now it works :)
Post Reply