pkgsrc/net/publicfile-run/files/pubhttpd.sh
jperkin b5a3ccfbce Remove mk/find-prefix.mk usage from the net category.
The find-prefix infrastructure was required in a pkgviews world where
packages installed from pkgsrc could have different installation
prefixes, and this was a way for a dependency prefix to be determined.

Now that pkgviews has been removed there is no longer any need for the
overhead of this infrastructure.  Instead we use BUILDLINK_PREFIX.pkg
for dependencies pulled in via buildlink, or LOCALBASE/PREFIX where the
dependency is coming from pkgsrc.

Provides a reasonable performance win due to the reduction of `pkg_info
-qp` calls, some of which were redundant anyway as they were duplicating
the same information provided by BUILDLINK_PREFIX.pkg.
2015-11-25 12:52:11 +00:00

57 lines
1.7 KiB
Bash

#!@RCD_SCRIPTS_SHELL@
#
# $NetBSD: pubhttpd.sh,v 1.2 2015/11/25 12:52:12 jperkin Exp $
#
# @PKGNAME@ script to control publicfile httpd (HTTP server)
#
# PROVIDE: pubhttpd
# REQUIRE: NETWORKING mountcritremote syslogd
# BEFORE: DAEMON
name="pubhttpd"
# User-settable rc.conf variables and their default values:
: ${pubhttpd_root:="@VARBASE@/public"}
: ${pubhttpd_postenv:=""}
: ${pubhttpd_datalimit:="50000"}
: ${pubhttpd_localname:="0"}
: ${pubhttpd_backlog:="50"}
: ${pubhttpd_conlimit:="100"}
: ${pubhttpd_host:="0"}
: ${pubhttpd_port:="80"}
: ${pubhttpd_log:="YES"}
: ${pubhttpd_logcmd:="logger -t nb${name} -p ftp.info"}
: ${pubhttpd_nologcmd:="@PREFIX@/bin/multilog -*"}
if [ -f /etc/rc.subr ]; then
. /etc/rc.subr
fi
rcvar=${name}
required_dirs="${pubhttpd_root}"
command="@PREFIX@/bin/tcpserver"
procname=${name}
start_precmd="pubhttpd_precmd"
pubhttpd_precmd()
{
# tcpserver(1) is akin to inetd(8), but runs one service per process.
# We want to signal only the tcpserver process responsible for the HTTP
# service. Use argv0(1) to set the process name to "pubhttpd".
if [ -f /etc/rc.subr ]; then
checkyesno pubhttpd_log || pubhttpd_logcmd=${pubhttpd_nologcmd}
fi
command="@SETENV@ - ${pubhttpd_postenv} @PREFIX@/bin/envuidgid pubhttp @PREFIX@/bin/softlimit -o20 -d${pubhttpd_datalimit} @PREFIX@/bin/argv0 @PREFIX@/bin/tcpserver ${name} -vDRH -l${pubhttpd_localname} -b${pubhttpd_backlog} -c${pubhttpd_conlimit} ${pubhttpd_host} ${pubhttpd_port} @PREFIX@/publicfile/bin/httpd ${pubhttpd_root} 2>&1 | @PREFIX@/bin/setuidgid publog ${pubhttpd_logcmd}"
command_args="&"
rc_flags=""
}
if [ -f /etc/rc.subr ]; then
load_rc_config $name
run_rc_command "$1"
else
@ECHO_N@ " ${name}"
pubhttpd_precmd
eval ${command} ${pubhttpd_flags} ${command_args}
fi