| 1 | = FreeBSD Init Script = |
| 2 | == Deluged == |
| 3 | |
| 4 | {{{ |
| 5 | #!sh |
| 6 | #!/bin/sh |
| 7 | # |
| 8 | # deluged RCng startup script |
| 9 | # created by: R.S.A. aka .faust |
| 10 | # mail: rsa dot aka dot f at gmail dot com |
| 11 | # |
| 12 | |
| 13 | # PROVIDE: deluged |
| 14 | # REQUIRE: NETWORKING SERVERS DAEMON ldconfig resolv |
| 15 | # BEFORE: LOGIN |
| 16 | # KEYWORD: shutdown |
| 17 | |
| 18 | # Add the following line to /etc/rc.conf.local or /etc/rc.conf to enable deluged at startup |
| 19 | # deluged_enable="YES" |
| 20 | # |
| 21 | # pidfile (str): Specify the full path to the PID file |
| 22 | # log (str): Specify the full path to the LOG file |
| 23 | # delugew_user (str): Set to user running deluge-web |
| 24 | # cfg_dir (str): Specify the full path to directory with deluge config files |
| 25 | # |
| 26 | # Warning! Rights to folders and files must be "rwx" for the user under which the run deluge |
| 27 | |
| 28 | . /etc/rc.subr |
| 29 | |
| 30 | name="deluged" |
| 31 | rcvar=`set_rcvar` |
| 32 | |
| 33 | load_rc_config $name |
| 34 | deluged_enable=${deluged_enable:=NO} |
| 35 | |
| 36 | log="/home/deluge/${name}.log" |
| 37 | pidfile="/home/deluge/${name}.pid" |
| 38 | cfg_dir="/home/deluge/config/" |
| 39 | deluged_user="nobody" |
| 40 | |
| 41 | required_dirs=${cfg_dir} |
| 42 | |
| 43 | command_interpreter="/usr/local/bin/python" |
| 44 | command="/usr/local/bin/${name}" |
| 45 | start_cmd="${name}_start" |
| 46 | |
| 47 | deluged_start() |
| 48 | { |
| 49 | if [ ! -f "${pidfile}" ]; then |
| 50 | su -m ${deluged_user} -c "/usr/local/bin/${name} -c ${cfg_dir} -l ${log} -P ${pidfile}" |
| 51 | echo "Starting ${name}." |
| 52 | else |
| 53 | GETPROCESSPID=`/bin/ps -auxw | /usr/bin/awk '/deluged/ && !/awk/ && !/sh/ {print $2}'` |
| 54 | PIDFROMFILE=`cat ${pidfile}` |
| 55 | if [ "$GETPROCESSPID" = "$PIDFROMFILE" ]; then |
| 56 | echo "${name} already running with PID: ${PIDFROMFILE} ?" |
| 57 | echo "Remove ${pidfile} manually if needed." |
| 58 | else |
| 59 | rm -f ${pidfile} |
| 60 | su -m ${deluged_user} -c "/usr/local/bin/${name} -c ${cfg_dir} -l ${log} -P ${pidfile}" |
| 61 | echo "Starting ${name}." |
| 62 | fi |
| 63 | fi |
| 64 | } |
| 65 | |
| 66 | |
| 67 | run_rc_command "$1" |
| 68 | }}} |
| 69 | |
| 70 | == Web UI == |
| 71 | |
| 72 | {{{ |
| 73 | #!sh |
| 74 | #!/bin/sh |
| 75 | # |
| 76 | # deluge-web RCng startup script |
| 77 | # created by: R.S.A. aka .faust |
| 78 | # mail: rsa dot aka dot f at gmail dot com |
| 79 | # |
| 80 | |
| 81 | # PROVIDE: delugew |
| 82 | # REQUIRE: NETWORKING SERVERS DAEMON ldconfig resolv |
| 83 | # BEFORE: LOGIN |
| 84 | # KEYWORD: shutdown |
| 85 | |
| 86 | # Add the following line to /etc/rc.conf.local or /etc/rc.conf to enable deluge-web at startup |
| 87 | # delugew_enable="YES" |
| 88 | # |
| 89 | # pidfile (str): Specify the full path to the PID file |
| 90 | # log (str): Specify the full path to the LOG file |
| 91 | # delugew_user (str): Set to user running deluge-web |
| 92 | # cfg_dir (str): Specify the full path to directory with deluge config files |
| 93 | # |
| 94 | # Warning! Rights to folders and files must be "rwx" for the user under which the run deluge |
| 95 | . /etc/rc.subr |
| 96 | |
| 97 | name="delugew" |
| 98 | rcvar=`set_rcvar` |
| 99 | |
| 100 | load_rc_config $name |
| 101 | delugew_enable=${delugew_enable:=NO} |
| 102 | |
| 103 | log="/home/deluge/${name}.log" |
| 104 | pidfile="/home/deluge/${name}.pid" |
| 105 | cfg_dir="/home/deluge/config/" |
| 106 | delugew_user="nobody" |
| 107 | |
| 108 | required_dirs=${cfg_dir} |
| 109 | |
| 110 | command_interpreter="/usr/local/bin/python" |
| 111 | command="/usr/local/bin/deluge-web" |
| 112 | start_cmd="${name}_start" |
| 113 | start_postcmd="${name}_poststart" |
| 114 | |
| 115 | delugew_start() |
| 116 | { |
| 117 | if [ ! -f "${pidfile}" ]; then |
| 118 | su -m ${delugew_user} -c "/usr/local/bin/deluge-web -f -c ${cfg_dir} -l ${log}" |
| 119 | echo "Starting ${name}." |
| 120 | else |
| 121 | GETPROCESSPID=`/bin/ps -auxw | /usr/bin/awk '/deluge-web/ && !/awk/ && !/sh/ {print $2}'` |
| 122 | PIDFROMFILE=`cat ${pidfile}` |
| 123 | if [ "$GETPROCESSPID" = "$PIDFROMFILE" ]; then |
| 124 | echo "${name} already running with PID: ${PIDFROMFILE} ?" |
| 125 | echo "Remove ${pidfile} manually if needed." |
| 126 | else |
| 127 | rm -f ${pidfile} |
| 128 | su -m ${delugew_user} -c "/usr/local/bin/deluge-web -f -c ${cfg_dir} -l ${log}" |
| 129 | echo "Starting ${name}." |
| 130 | fi |
| 131 | fi |
| 132 | } |
| 133 | |
| 134 | delugew_poststart() |
| 135 | { |
| 136 | echo `/bin/ps -auxw | /usr/bin/awk '/deluge-web/ && !/awk/ {print $2}'` > $pidfile |
| 137 | } |
| 138 | |
| 139 | run_rc_command "$1" |
| 140 | }}} |