Changeset View
Changeset View
Standalone View
Standalone View
head/www/fcgiwrap/files/fcgiwrap.in
Show All 13 Lines | |||||
# | # | ||||
# You can fine tune others variables too: | # You can fine tune others variables too: | ||||
# fcgiwrap_socket="unix:/var/run/fcgiwrap.sock" | # fcgiwrap_socket="unix:/var/run/fcgiwrap.sock" | ||||
# this could also be: | # this could also be: | ||||
# - tcp:[ipv4_addr]:port (for ipv4) | # - tcp:[ipv4_addr]:port (for ipv4) | ||||
# - tcp6:[ipv6_addr]:port (for ipv6) | # - tcp6:[ipv6_addr]:port (for ipv6) | ||||
# fcgiwrap_flags= | # fcgiwrap_flags= | ||||
# Use fcgiwrap_user to run fcgiwrap as user | # Use fcgiwrap_user to run fcgiwrap as user | ||||
# Use fcgiwrap_group to run fcgiwrap as group | |||||
# Use fcgiwrap_socket_mode to change the mode of the socket | # Use fcgiwrap_socket_mode to change the mode of the socket | ||||
# Use fcgiwrap_socket_owner to change the owner of the socket | # Use fcgiwrap_socket_owner to change the owner of the socket | ||||
# Use fcgiwrap_socket_group to change the group of the socket | # Use fcgiwrap_socket_group to change the group of the socket | ||||
# fcgiwrap rc.d script supports multiple profiles (a-la rc.d/nginx) | # fcgiwrap rc.d script supports multiple profiles (a-la rc.d/nginx) | ||||
# When profiles are specified, the non-profile specific parameters become defaults. | # When profiles are specified, the non-profile specific parameters become defaults. | ||||
# You need to make sure that no two profiles have the same socket parameter. | # You need to make sure that no two profiles have the same socket parameter. | ||||
# | # | ||||
# Example: | # Example: | ||||
# | # | ||||
# fcgiwrap_enable="YES" | # fcgiwrap_enable="YES" | ||||
# fcgiwrap_profiles="myserver myotherserver" | # fcgiwrap_profiles="myserver myotherserver" | ||||
# fcgiwrap_flags="-c 4" | # fcgiwrap_flags="-c 4" | ||||
# fcgiwrap_socket_owner="www" | # fcgiwrap_socket_owner="www" | ||||
# fcgiwrap_myserver_socket="unix:/var/run/fcgiwrap.myserver.socket" | # fcgiwrap_myserver_socket="unix:/var/run/fcgiwrap.myserver.socket" | ||||
# fcgiwrap_myserver_user="myuser" | # fcgiwrap_myserver_user="myuser" | ||||
# fcgiwrap_myserver_group="mygroup" | |||||
# fcgiwrap_myotherserver_socket="unix:/var/run/fcgiwrap.myotherserver.socket" | # fcgiwrap_myotherserver_socket="unix:/var/run/fcgiwrap.myotherserver.socket" | ||||
# fcgiwrap_myotherserver_user="myotheruser" | # fcgiwrap_myotherserver_user="myotheruser" | ||||
# fcgiwrap_myotherserver_grup="myothergroup" | |||||
# fcgiwrap_myserver_socket_mode="0775" | # fcgiwrap_myserver_socket_mode="0775" | ||||
# fcgiwrap_myotherserver_flags="" # No flags for this profile. | # fcgiwrap_myotherserver_flags="" # No flags for this profile. | ||||
. /etc/rc.subr | . /etc/rc.subr | ||||
name="fcgiwrap" | name="fcgiwrap" | ||||
rcvar=fcgiwrap_enable | rcvar=fcgiwrap_enable | ||||
Show All 12 Lines | *) | ||||
command="setfib -F ${fcgiwrap_fib} ${command}" | command="setfib -F ${fcgiwrap_fib} ${command}" | ||||
;; | ;; | ||||
esac | esac | ||||
} | } | ||||
fcgiwrap_precmd() { | fcgiwrap_precmd() { | ||||
fcgiwrap_setfib | fcgiwrap_setfib | ||||
install -d -o root -g wheel -m 1777 /var/run/fcgiwrap | install -d -o root -g wheel -m 1777 /var/run/fcgiwrap | ||||
umask $(printf 0%o $(echo $((0777 - $(echo 0${fcgiwrap_socket_mode}))))) | |||||
} | } | ||||
fcgiwrap_postcmd() { | fcgiwrap_postcmd() { | ||||
# This is only for unix sockets | # This is only for unix sockets | ||||
case "${fcgiwrap_socket}" in | case "${fcgiwrap_socket}" in | ||||
unix:*) | unix:*) | ||||
;; | ;; | ||||
*) | *) | ||||
return | return | ||||
;; | ;; | ||||
esac | esac | ||||
if [ -n "${fcgiwrap_socket_mode}" ]; then | if [ "${fcgiwrap_socket_owner}" != "${fcgiwrap_user}" ]; then | ||||
chmod ${fcgiwrap_socket_mode} ${fcgiwrap_socket#unix:} | |||||
fi | |||||
if [ -n "${fcgiwrap_socket_owner}" ]; then | |||||
chown ${fcgiwrap_socket_owner} ${fcgiwrap_socket#unix:} | chown ${fcgiwrap_socket_owner} ${fcgiwrap_socket#unix:} | ||||
fi | fi | ||||
if [ -n "${fcgiwrap_socket_group}" ]; then | if [ "${fcgiwrap_socket_group}" != "${fcgiwrap_group}" ]; then | ||||
chgrp ${fcgiwrap_socket_group} ${fcgiwrap_socket#unix:} | chgrp ${fcgiwrap_socket_group} ${fcgiwrap_socket#unix:} | ||||
fi | fi | ||||
umask ${fcgiwrap_saved_umask} | |||||
} | } | ||||
fcgiwrap_stop() { | fcgiwrap_stop() { | ||||
if [ -s ${pidfile} ]; then | if [ -s ${pidfile} ]; then | ||||
fcgiwrap_pgrp=$(/bin/ps -o ppid= $(cat ${pidfile})) | fcgiwrap_pgrp=$(/bin/ps -o ppid= $(cat ${pidfile})) | ||||
fi | fi | ||||
if [ -z "$fcgiwrap_pgrp" -o "${fcgiwrap_pgrp:-0}" -le 1 ] || ! kill -0 $fcgiwrap_pgrp; then | if [ -z "$fcgiwrap_pgrp" -o "${fcgiwrap_pgrp:-0}" -le 1 ] || ! kill -0 $fcgiwrap_pgrp; then | ||||
[ -n "$rc_fast" ] && return 0 | [ -n "$rc_fast" ] && return 0 | ||||
Show All 22 Lines | |||||
start_precmd="fcgiwrap_precmd" | start_precmd="fcgiwrap_precmd" | ||||
start_postcmd="fcgiwrap_postcmd" | start_postcmd="fcgiwrap_postcmd" | ||||
stop_cmd="fcgiwrap_stop" | stop_cmd="fcgiwrap_stop" | ||||
load_rc_config $name | load_rc_config $name | ||||
# These are just the defaults, they might get overriden for a specific profile. | # These are just the defaults, they might get overriden for a specific profile. | ||||
fcgiwrap_enable=${fcgiwrap_enable:-"NO"} | fcgiwrap_enable=${fcgiwrap_enable:-"NO"} | ||||
fcgiwrap_user=${fcgiwrap_user:-"root"} | fcgiwrap_user=${fcgiwrap_user:-"nobody"} | ||||
fcgiwrap_group=${fcgiwrap_group:-"nogroup"} | |||||
fcgiwrap_socket=${fcgiwrap_socket:-"unix:/var/run/fcgiwrap/fcgiwrap.sock"} | fcgiwrap_socket=${fcgiwrap_socket:-"unix:/var/run/fcgiwrap/fcgiwrap.sock"} | ||||
fcgiwrap_socket_mode=${fcgiwrap_socket_mode:-"0755"} | fcgiwrap_socket_mode=${fcgiwrap_socket_mode:-"0775"} | ||||
fcgiwrap_socket_owner=${fcgiwrap_socket_owner:-"root"} | fcgiwrap_socket_owner=${fcgiwrap_socket_owner:-"nobody"} | ||||
fcgiwrap_socket_group=${fcgiwrap_socket_group:-"wheel"} | fcgiwrap_socket_group=${fcgiwrap_socket_group:-"nogroup"} | ||||
# This handles profile specific vars. | # This handles profile specific vars. | ||||
if [ -n "$2" ]; then | if [ -n "$2" ]; then | ||||
profile="$2" | profile="$2" | ||||
if [ -n "${fcgiwrap_profiles}" ]; then | if [ -n "${fcgiwrap_profiles}" ]; then | ||||
pidfile="${pidprefix}.${profile}.pid" | pidfile="${pidprefix}.${profile}.pid" | ||||
eval fcgiwrap_enable="\${fcgiwrap_${profile}_enable:-${fcgiwrap_enable}}" | eval fcgiwrap_enable="\${fcgiwrap_${profile}_enable:-${fcgiwrap_enable}}" | ||||
eval fcgiwrap_fib="\${fcgiwrap_${profile}_fib:-${fcgiwrap_fib}}" | eval fcgiwrap_fib="\${fcgiwrap_${profile}_fib:-${fcgiwrap_fib}}" | ||||
eval fcgiwrap_user="\${fcgiwrap_${profile}_user:-${fcgiwrap_user}}" | eval fcgiwrap_user="\${fcgiwrap_${profile}_user:-${fcgiwrap_user}}" | ||||
eval fcgiwrap_group="\${fcgiwrap_${profile}_user:-${fcgiwrap_group}}" | |||||
eval fcgiwrap_socket="\${fcgiwrap_${profile}_socket:?}" | eval fcgiwrap_socket="\${fcgiwrap_${profile}_socket:?}" | ||||
eval fcgiwrap_socket_mode="\${fcgiwrap_${profile}_socket_mode:-${fcgiwrap_socket_mode}}" | eval fcgiwrap_socket_mode="\${fcgiwrap_${profile}_socket_mode:-${fcgiwrap_socket_mode}}" | ||||
eval fcgiwrap_socket_owner="\${fcgiwrap_${profile}_socket_owner:-${fcgiwrap_socket_owner}}" | eval fcgiwrap_socket_owner="\${fcgiwrap_${profile}_socket_owner:-${fcgiwrap_socket_owner}}" | ||||
eval fcgiwrap_socket_group="\${fcgiwrap_${profile}_socket_group:-${fcgiwrap_socket_group}}" | eval fcgiwrap_socket_group="\${fcgiwrap_${profile}_socket_group:-${fcgiwrap_socket_group}}" | ||||
eval fcgiwrap_flags="\${fcgiwrap_${profile}_flags:-${fcgiwrap_flags}}" | eval fcgiwrap_flags="\${fcgiwrap_${profile}_flags:-${fcgiwrap_flags}}" | ||||
else | else | ||||
echo "$0: extra argument ignored" | echo "$0: extra argument ignored" | ||||
fi | fi | ||||
Show All 14 Lines | else | ||||
fi | fi | ||||
fi | fi | ||||
# run_rc_command would send ${name}_flags as parameters to $command (daemon) | # run_rc_command would send ${name}_flags as parameters to $command (daemon) | ||||
# This ensures they are actually passed to fcgiwrap instead. | # This ensures they are actually passed to fcgiwrap instead. | ||||
actual_fcgiwrap_flags="${fcgiwrap_flags}" | actual_fcgiwrap_flags="${fcgiwrap_flags}" | ||||
fcgiwrap_flags="" | fcgiwrap_flags="" | ||||
command_args="-f -p ${pidfile} ${procname} -s ${fcgiwrap_socket} ${actual_fcgiwrap_flags}" | command_args="-f -p ${pidfile} ${procname} -s ${fcgiwrap_socket} ${actual_fcgiwrap_flags}" | ||||
fcgiwrap_saved_umask=$(umask) | |||||
run_rc_command "$1" | run_rc_command "$1" |