rendered paste body# cat /usr/bin/deluge-daemon2
#!/bin/sh
# created by mambang
# script utk memulakan deluged daemon dan deluge webui (deluge webserver) waktu boot.
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DELUGE="/usr/bin/deluge"
DELUGE_OPTIONS="-u web"
DELUGE_OPTIONS2="-u gtk"
DELUGE_OPTIONS3="-u null"
#USER="" #please add user that will run deluge
DELUGEDAEMON="/usr/bin/deluged"
DESC1="Deluge Daemon"
DESC2="WebUi"
DESC3="Gtk"
DESC4="Null"
NAME1="deluged"
NAME2="Deluge webserver"
NAME3="Deluge UI"
set -e
case "$1" in
deluged)
echo -n "Starting $DESC1 : "
start-stop-daemon --start --background --quiet --exec $DELUGEDAEMON
echo "$NAME1"
;;
web)
echo -n "Starting $DESC1 : "
start-stop-daemon --start --background --quiet --exec $DELUGEDAEMON
echo "$NAME1"
sleep 2
echo -n "Starting $DESC2 : "
start-stop-daemon --start --background --quiet --exec $DELUGE -- ${DELUGE_OPTIONS}
echo "$NAME2"
;;
gtk)
echo -n "Starting $DESC1 : "
start-stop-daemon --start --background --quiet --exec $DELUGEDAEMON
echo "$NAME1"
sleep 2
echo -n "Starting $DESC3 : "
start-stop-daemon --start --quiet --exec $DELUGE -- ${DELUGE_OPTIONS2}
echo "$NAME3"
;;
null)
echo -n "Starting $DESC1 : "
start-stop-daemon --start --background --quiet --exec $DELUGEDAEMON
echo "$NAME1"
sleep 2
echo -n "Starting $DESC4 : "
start-stop-daemon --start --quiet --exec $DELUGE -- ${DELUGE_OPTIONS3}
echo "$NAME4"
;;
stop)
echo -n "Stopping $DESC1 : "
#killall -9 $NAME1
PIDDELUGE=`ps ax |grep deluged |sed -n 1p |awk '{print $1}'`
kill $PIDDELUGE
echo "$NAME1."
echo -n "Stopping $NAME3 : "
PIDWEB=`ps ax |grep deluge |sed -n 2p |awk '{print $1}'`
kill $PIDWEB
echo "Ok."
;;
*)
N=deluge-daemon
echo "Usage: $N <option>"
echo "option : "
echo "deluged - hanya memulakan deluged daemon"
echo "web - memulakan deluged daemon dan webui"
echo "gtk - memulakan deluged daemon dan gtk ui"
echo "null - memulakan deluged daemon dan deluge shell"
echo "stop - menghentikan deluged daemon dan option lain"
exit 1
;;
esac
exit 0