EDIT: Thanks to a helpful comment below, I've modified the script around the TRANSMISSION_HOME variable to fix config options being dropped on a restart.
Also, you can edit the settings.json file in the config dir to further customise your install. See the wiki for help editing config files.
#!/bin/bash
#
# chkconfig: - 16 84
# description: Start up transmission-daemon
#
# processname: transmission-daemon
# config: /etc/sysconfig/transmission
# source function library
. /etc/rc.d/init.d/functions
# Get network config
. /etc/sysconfig/network
[ "${NETWORKING}" = "no" ] && exit 0
# Defaults
TRANSMISSION_HOME=/var/lib/transmission
DAEMON_USER="transmission"
DAEMON_ARGS="-T --blocklist -g $TRANSMISSION_HOME/.config/transmission"
# Daemon
NAME=transmission-daemon
DAEMON=$(which $NAME)
DAEMON_PIDFILE=/var/run/$NAME.pid
DAEMON_LOCKFILE=/var/lock/subsys/$NAME
DAEMON_SCRIPTNAME=/etc/init.d/$NAME
DAEMON_LOGFILE=/var/log/$NAME.log
[ -x "$DAEMON" ] || exit 0
start() {
echo -n $"Starting ${NAME}: "
if [ -n "$TRANSMISSION_HOME" ]; then
export TRANSMISSION_HOME
fi
su - $DAEMON_USER -c "$DAEMON $DAEMON_ARGS"
sleep 2
status $NAME &> /dev/null && echo_success || echo_failure
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
touch $DAEMON_LOCKFILE
pidof -o %PPID -x $NAME > $DAEMON_PIDFILE
fi
echo
}
stop() {
echo -n $"Shutting down ${NAME}: "
killproc $NAME
RETVAL=$?
[ $RETVAL -eq 0 ] && /bin/rm -f $DAEMON_LOCKFILE $DAEMON_PIDFILE
echo
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
status)
status $NAME
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|status}" >&2
exit 3
;;
esac
THanks a lot!
ReplyDeleteHi
ReplyDeleteI tried it on CentOS 5.2. Daemon starts just fine but it does not pick up settings (and does not write changes I make through WebGUI). Should it?
I changed
# config: /root/.config/transmission
TRANSMISSION_HOME=${TRANSMISSION_HOME:"/root/.config/transmission/"}
DAEMON_ARGS=""
Hi Art
ReplyDeleteThanks for that - yes, the settings seem to be dropped with the current init script. I'll make some mods following some testing.
Thanks!
Jason
Script updated.
ReplyDeleteinstallation instructions (Fedora 11):
ReplyDeleteyum install transmission
vi /etc/init.d/transmission-daemon
# copy&paste Jason's script from above
chmod 755 /etc/init.d/transmission-daemon
mkdir -p /var/lib/transmission
chown -R transmission.transmission /var/lib/transmission/
chkconfig --list transmission-daemon
chkconfig --add transmission-daemon
chkconfig --level 345 transmission-daemon on
chkconfig --list transmission-daemon
service transmission-daemon start
Jason,
ReplyDeleteI am the Fedora maintainer of Transmission now and one of the users filed a RFE with a link to this blog post at
https://bugzilla.redhat.com/show_bug.cgi?id=556228
I have included a modified version of your init script in the latest Rawhide (development branch of Fedora). Once 1.80 final release of Transmission is available, this update will be pushed for Fedora 12 and Fedora 11 as well.
If you have any future improvements, please file them in bugzilla. Thank you for your contribution.
Thanks for you comment mether, I certainly will.
ReplyDeleteRHEL/CentOS users see: http://fusionswift.com/2010/07/install-transmission-on-centos/
ReplyDelete**** CENTOS ****
ReplyDeleteAfter install, save the above script to /etc/init.d/transmission-daemon and change "DAEMON=$(which $NAME)" to "DAEMON=/usr/local/bin/transmission-daemon"
Then do....
groupadd transmission
useradd -d /var/lib/transmission -s /bin/bash -g transmission transmission
mkdir /var/lib/transmission/.config
mkdir /var/lib/transmission/.config/transmission
chown -R transmission.transmission /var/lib/transmission/
chmod -R 755 /var/lib/transmission
service transmission-daemon start
Thanks for the comments Chris.
ReplyDeleteAnother option that should work is to download the Transmission SRC RPM package from Fedora Rawhide (version 2.03 at time of writing) and rebuild it on your CentOS machine.
hello all -
ReplyDeleteI'm having a small issue with trying to get the transmission-daemon setup to run as a service and was hoping someone might be able to help.
I'm trying to run it on an SME 8b6/CentOS server and had no issues compiling the code and even getting the daemon to run manually.
I copied the start/stop script from here and dropped it in /etc/init.d/
Then I followed Chris' post by doing:
groupadd transmission
useradd -d /var/lib/transmission -s /bin/bash -g transmission transmission
mkdir /var/lib/transmission/.config
mkdir /var/lib/transmission/.config/transmission
chown -R transmission.transmission /var/lib/transmission/
chmod -R 755 /var/lib/transmission
Finally I tried adding the script as a service with:
chkconfig --add transmission-daemon
chkconfig transmission-daemon on
chkconfig --list transmission-daemon
Which does indeed show it listed. But when I try and type:
service transmission-daemon start
I get:
'transmission-daemon' is not a valid service name
Which is obviously a bummer.
If on the other hand I try and kick of the script manually with:
/etc/init.d/transmission-daemon start
the daemon seemingly starts right up without issue and a ps aux shows:
5001 27561 0.0 0.2 37028 2080 ? Ssl 08:54 0:00 /usr/local/bin/transmission-daemon -T --blocklist -g /var/lib/transmission/.config/transmission
Which seems fine to me.
So, any idea what step I missed to get the script properly registered as a service on CentOS?
Many thanks in advance!
A lot of Thanks for the posting an important article! This campaigns is really good and I would also like to note that the Engine blog carefully.
ReplyDeleteThanks
Nancy
"Engine and Transmission World"
I love the look of your website. I recently built mine and I was looking for some design ideas and you gave me a few. May I ask you whether you developed the website by youself?
ReplyDeleteEngine and Transmission World
This was a great article that really was really helpful to me and I really cant wait to learn more from your valuable experience. This was really very interesting to me. Thanks.
ReplyDeleteEngine and Transmission World
Trying to stop x server on Ubuntu using (/etc/init.d/gdm stop) but doesn't work?
ReplyDeleteFirst it gives me: Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service gdm stop
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) utility, e.g. stop gdm
stop: Rejected send message, 1 matched rules; type="method_call", sender=":1.55" (uid=1000 pid=1999 comm="stop) interface="com.ubuntu.Upstart0_6.Job" member="Stop" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init"))
Than I do service gdm stop then gives me :stop: Rejected send message, 1 matched rules; type="method_call", sender=":1.56" (uid=1000 pid=2000 comm="stop) interface="com.ubuntu.Upstart0_6.Job" member="Stop" error name="(unset)" requested_reply=0 destination="com.ubuntu.Upstart" (uid=0 pid=1 comm="/sbin/init"))
So how do I stop x service? Nothing seems to work. I even tried control+alt+backspace doesn't work. Safemode won't work. What can I do?
Regards,
Atty. Kevin, Miami injury lawyer