Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@elijahpaul
Created July 27, 2014 02:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elijahpaul/b98f39011bce48c0750d to your computer and use it in GitHub Desktop.
Save elijahpaul/b98f39011bce48c0750d to your computer and use it in GitHub Desktop.
Start up transmission-daemon
#!/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=/home/transmission
DAEMON_USER="transmission"
DAEMON_ARGS="-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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment