Changes between Initial Version and Version 1 of UserGuide/Service/FreeBSD


Ignore:
Timestamp:
04/07/2010 04:01:58 PM (14 years ago)
Author:
Cas
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • UserGuide/Service/FreeBSD

    v1 v1  
     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  
     30name="deluged" 
     31rcvar=`set_rcvar` 
     32  
     33load_rc_config $name 
     34deluged_enable=${deluged_enable:=NO} 
     35 
     36log="/home/deluge/${name}.log" 
     37pidfile="/home/deluge/${name}.pid" 
     38cfg_dir="/home/deluge/config/" 
     39deluged_user="nobody" 
     40 
     41required_dirs=${cfg_dir} 
     42 
     43command_interpreter="/usr/local/bin/python" 
     44command="/usr/local/bin/${name}" 
     45start_cmd="${name}_start" 
     46 
     47deluged_start() 
     48{ 
     49if [ ! -f "${pidfile}" ]; then 
     50    su -m ${deluged_user} -c "/usr/local/bin/${name} -c ${cfg_dir} -l ${log} -P ${pidfile}" 
     51    echo "Starting ${name}." 
     52else 
     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 
     63fi 
     64} 
     65  
     66  
     67run_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  
     97name="delugew" 
     98rcvar=`set_rcvar` 
     99  
     100load_rc_config $name 
     101delugew_enable=${delugew_enable:=NO} 
     102 
     103log="/home/deluge/${name}.log" 
     104pidfile="/home/deluge/${name}.pid" 
     105cfg_dir="/home/deluge/config/" 
     106delugew_user="nobody" 
     107 
     108required_dirs=${cfg_dir} 
     109 
     110command_interpreter="/usr/local/bin/python" 
     111command="/usr/local/bin/deluge-web" 
     112start_cmd="${name}_start" 
     113start_postcmd="${name}_poststart" 
     114 
     115delugew_start() 
     116{ 
     117if [ ! -f "${pidfile}" ]; then 
     118    su -m ${delugew_user} -c "/usr/local/bin/deluge-web -f -c ${cfg_dir} -l ${log}" 
     119    echo "Starting ${name}." 
     120else 
     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 
     131fi 
     132} 
     133  
     134delugew_poststart() 
     135{ 
     136echo `/bin/ps -auxw | /usr/bin/awk '/deluge-web/ && !/awk/ {print $2}'` > $pidfile 
     137} 
     138  
     139run_rc_command "$1" 
     140}}}