You are not logged in.

#1 2008-08-08 01:05:13

Roberth
Member
From: Norway
Registered: 2007-01-12
Posts: 873

Good init script for Transmission?

#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions
. /etc/conf.d/transmissiond

if [ "$(id -u)" != 0 ]
then
    echo "You must be root to start Transmission as daemon."
    exit 2
fi

if [ -z $TRANS_USER ]
then
    echo "Unable to run Transmission. You must set the user in /etc/conf.d/transmissiond"
    exit 2
fi

confdir=$(su -l $TRANS_USER -c "echo ~")/.transmission
if [ ! -d $confdir ]; then 
    su -l $TRANS_USER  -c "mkdir -p $confdir"
fi

PID=`pidof -o %PPID /usr/bin/transmission-daemon`
case "$1" in
  start)
    stat_busy "Starting Transmission Daemon"

    if [ -z "$PID" ]; then 
       su -l $TRANS_USER -c "/usr/bin/transmission-daemon"
    fi

    if [ ! -z "$PID" -o $? -gt 0 ]; then
      stat_fail
    else
      add_daemon transmissiond
      stat_done
    fi
    ;;
  stop)
    stat_busy "Stopping Transmission Daemon"

    [ ! -z "$PID" ]  && su -l $TRANS_USER -c "/usr/bin/transmission-remote -q"
    if [ $? -gt 0 ]; then
      stat_fail
    else
      rm_daemon transmissiond
      stat_done
    fi
    ;;
  restart)
    $0 stop
    sleep 1
    $0 start
    ;;
  *)
    echo "usage: $0 {start|stop|restart}"
esac
exit 0

Is this script good for starting transmission as a daemon?

Last edited by Roberth (2008-08-08 01:05:30)


Use the Source, Luke!

Offline

Board footer

Powered by FluxBB