Files
bsdports/net/fcgiwrap/files/fcgiwrap.in
2019-12-26 07:26:06 +00:00

88 lines
2.1 KiB
Bash

#!/bin/sh
# $FreeBSD: head/www/fcgiwrap/files/fcgiwrap.in 361688 2014-07-13 15:30:08Z pi $
#
# 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_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 rc.d script supports multiple profiles (a-la rc.d/nginx)
# 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.
#
# Example:
#
# fcgiwrap_enable="YES"
# fcgiwrap_flags="-c 4"
# fcgiwrap_socket="unix:/var/run/fcgiwrap.myserver.socket"
. /etc/rc.subr
name="fcgiwrap"
rcvar=fcgiwrap_enable
pidprefix="/var/run/fcgiwrap/fcgiwrap"
pidfile="/var/run/fcgiwrap/fcgiwrap.pid" # May be a different path if profiles are in use
procname="/usr/local/sbin/${name}"
command="/usr/sbin/daemon"
fcgiwrap_precmd() {
install -d -o root -g wheel -m 1777 /var/run/fcgiwrap
}
fcgiwrap_stop() {
if [ -s ${pidfile} ]; then
fcgiwrap_pgrp=$(/bin/ps -o ppid= $(cat ${pidfile}))
fi
if [ -z "$fcgiwrap_pgrp" -o "${fcgiwrap_pgrp:-0}" -le 1 ] || ! kill -0 $fcgiwrap_pgrp; then
[ -n "$rc_fast" ] && return 0
_run_rc_notrunning
return 1
fi
fcgiwrap_pgrp_pids=$(/bin/pgrep -d ' ' -g ${fcgiwrap_pgrp})
echo "Stopping ${name}."
kill -TERM -- -${fcgiwrap_pgrp}
wait_for_pids ${fcgiwrap_pgrp_pids}
case ${fcgiwrap_socket} in
unix*)
test -S ${fcgiwrap_socket#unix:} && rm -f ${fcgiwrap_socket#unix:}
;;
esac
rm -f $pidfile
}
start_precmd="fcgiwrap_precmd"
stop_cmd="fcgiwrap_stop"
load_rc_config $name
fcgiwrap_enable=${fcgiwrap_enable:-"NO"}
fcgiwrap_user=${fcgiwrap_user:-"root"}
fcgiwrap_socket=${fcgiwrap_socket:-"unix:/var/run/fcgiwrap/fcgiwrap.sock"}
actual_fcgiwrap_flags="${fcgiwrap_flags}"
fcgiwrap_flags=""
command_args="-f -p ${pidfile} ${procname} -s ${fcgiwrap_socket} ${actual_fcgiwrap_flags}"
run_rc_command "$1"
#EOF