#!/bin/sh # $FreeBSD$ # # fcgiwrap startup script # # PROVIDE: fcgiwrap # REQUIRE: LOGIN # KEYWORD: shutdown # # Add the following to /etc/rc.conf[.local] to enable this service # # fcgiwrap_enable="YES" # # You can fine tune others variables too: # fcgiwrap_fib="NONE" # fcgiwrap_socket="unix:/var/run/fcgiwrap.sock" # this could also be: # - tcp:[ipv4_addr]:port (for ipv4) # - tcp6:[ipv6_addr]:port (for ipv6) # fcgiwrap_flags= # Use fcgiwrap_user to run fcgiwrap as user fcgiwrap_setfib() { sysctl net.fibs >/dev/null 2>&1 || return 0 case "$fcgiwrap_fib" in [Nn][Oo][Nn][Ee]) ;; *) command="setfib -F ${fcgiwrap_fib} ${command}" ;; esac } fcgiwrap_precmd() { fcgiwrap_setfib install -d -o $fcgiwrap_user -m 755 /var/run/fcgiwrap } fcgiwrap_cleansocket() { # Workaround the fact that fcgiwrap doesn't cleanup his socket at stopping case ${fcgiwrap_socket} in unix*) test -S ${fcgiwrap_socket#unix:} && rm -f ${fcgiwrap_socket#unix:} ;; esac rm -f $pidfile } . /etc/rc.subr pidfile="/var/run/fcgiwrap/fcgiwrap.pid" name="fcgiwrap" rcvar=`set_rcvar` procname="%%PREFIX%%/sbin/${name}" command="/usr/sbin/daemon" start_precmd="fcgiwrap_precmd" stop_postcmd="fcgiwrap_cleansocket" load_rc_config $name fcgiwrap_enable=${fcgiwrap_enable:-"NO"} fcgiwrap_fib=${fcgiwrap_fib:-"NONE"} fcgiwrap_user=${fcgiwrap_user:-"root"} fcgiwrap_socket=${fcgiwrap_socket:-"unix:/var/run/fcgiwrap/fcgiwrap.sock"} command_args="-f -p ${pidfile} ${procname} -s ${fcgiwrap_socket}" run_rc_command "$1"