[Midnightbsd-cvs] mports [21122] trunk/www/varnish4: fix some warnings.

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Sat Mar 12 16:56:12 EST 2016


Revision: 21122
          http://svnweb.midnightbsd.org/mports/?rev=21122
Author:   laffer1
Date:     2016-03-12 16:56:11 -0500 (Sat, 12 Mar 2016)
Log Message:
-----------
fix some warnings.

Modified Paths:
--------------
    trunk/www/varnish4/Makefile
    trunk/www/varnish4/files/varnishd.in
    trunk/www/varnish4/files/varnishlog.in
    trunk/www/varnish4/files/varnishncsa.in

Added Paths:
-----------
    trunk/www/varnish4/files/patch-bin_varnishstat_varnishstat__curses.c

Modified: trunk/www/varnish4/Makefile
===================================================================
--- trunk/www/varnish4/Makefile	2016-03-12 16:41:39 UTC (rev 21121)
+++ trunk/www/varnish4/Makefile	2016-03-12 21:56:11 UTC (rev 21122)
@@ -2,6 +2,7 @@
 
 PORTNAME=	varnish
 PORTVERSION=	4.1.1
+PORTREVISION=	1
 CATEGORIES=	www
 MASTER_SITES=	http://repo.varnish-cache.org/source/
 PKGNAMESUFFIX=	4
@@ -27,6 +28,9 @@
 USE_LDCONFIG=	yes
 INSTALL_TARGET=	install-strip
 
+USERS=		varnish varnishlog
+GROUPS=		varnish
+
 USE_RC_SUBR=	varnishd varnishlog varnishncsa
 SUB_FILES=	pkg-message
 .if defined(NO_INET6) || defined(WITHOUT_INET6)

Added: trunk/www/varnish4/files/patch-bin_varnishstat_varnishstat__curses.c
===================================================================
--- trunk/www/varnish4/files/patch-bin_varnishstat_varnishstat__curses.c	                        (rev 0)
+++ trunk/www/varnish4/files/patch-bin_varnishstat_varnishstat__curses.c	2016-03-12 21:56:11 UTC (rev 21122)
@@ -0,0 +1,14 @@
+--- bin/varnishstat/varnishstat_curses.c.orig	2016-01-28 10:30:41 UTC
++++ bin/varnishstat/varnishstat_curses.c
+@@ -540,8 +540,9 @@ static void
+ print_duration(WINDOW *w, time_t t)
+ {
+ 
+-	wprintw(w, "%4lu+%02lu:%02lu:%02lu",
+-	    t / 86400, (t % 86400) / 3600, (t % 3600) / 60, t % 60);
++	wprintw(w, "%4jd+%02jd:%02jd:%02jd",
++	    (intmax_t)t / 86400, (intmax_t)(t % 86400) / 3600,
++	    (intmax_t)(t % 3600) / 60, (intmax_t)t % 60);
+ }
+ 
+ static void


Property changes on: trunk/www/varnish4/files/patch-bin_varnishstat_varnishstat__curses.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/www/varnish4/files/varnishd.in
===================================================================
--- trunk/www/varnish4/files/varnishd.in	2016-03-12 16:41:39 UTC (rev 21121)
+++ trunk/www/varnish4/files/varnishd.in	2016-03-12 21:56:11 UTC (rev 21122)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: head/www/varnish4/files/varnishd.in 387610 2015-05-27 14:34:42Z feld $
+# $FreeBSD: head/www/varnish4/files/varnishd.in 400701 2015-11-03 15:08:46Z feld $
 #
 
 # PROVIDE: varnishd
@@ -37,15 +37,12 @@
 # varnishd_storage - storage method and parameters.
 #	default: "file,/tmp,100M"
 #
-# varnishd_user - unprivileged user for the child process.
-#	default: "www"
+# varnishd_jailuser - unprivileged user for the child process.
+#	default: "varnish"
 #
-# varnishd_group - unprivileged group for the child process.
-#	default: "www"
-#
 # varnishd_flags - complete command line arguments.
-#	default if varnishd_config is unset: "-P ${varnishd_pidfile} -a ${varnishd_listen} -T ${varnishd_admin} -b ${varnishd_backend} -s ${varnishd_storage} -h ${varnishd_hash} -u ${varnishd_user} -g ${varnishd_group}"
-#	default if varnishd_config is set: "-P ${varnishd_pidfile} -a ${varnishd_listen} -T ${varnishd_admin} -f ${varnishd_config} -s ${varnishd_storage} -h ${varnishd_hash} -u ${varnishd_user} -g ${varnishd_group}"
+#	default if varnishd_config is unset: "-j unix,user=${varnishd_jailuser} -P ${varnishd_pidfile} -a ${varnishd_listen} -T ${varnishd_admin} -b ${varnishd_backend} -s ${varnishd_storage} -h ${varnishd_hash} ${varnishd_extra_flags}"
+#	default if varnishd_config is set: "-j unix,user=${varnishd_jailuser} -P ${varnishd_pidfile} -a ${varnishd_listen} -T ${varnishd_admin} -f ${varnishd_config} -s ${varnishd_storage} -h ${varnishd_hash} ${varnishd_extra_flags}"
 #
 # See varnishd(1) for a detailed overview of command-line options.
 #
@@ -64,21 +61,68 @@
 : ${varnishd_backend=localhost:8080}
 : ${varnishd_storage=file,/tmp,100M}
 : ${varnishd_hash=classic,16383}
-: ${varnishd_user=www}
-: ${varnishd_group=www}
+: ${varnishd_jailuser=varnish}
 
 command="%%PREFIX%%/sbin/${name}"
 pidfile="${varnishd_pidfile}"
+configtest_cmd="varnishd_checkconfig"
+reload_cmd="varnishd_reload"
+restart_precmd="varnishd_checkconfig"
+start_precmd="varnishd_precmd"
+extra_commands="status reload configtest"
 
 if [ -n "${varnishd_config}" ] ; then
-	: ${varnishd_flags:="-P ${varnishd_pidfile} -a ${varnishd_listen} -T ${varnishd_admin} -f ${varnishd_config} -s ${varnishd_storage} -h ${varnishd_hash} -u ${varnishd_user} -g ${varnishd_group} ${varnishd_extra_flags}"}
+	: ${varnishd_flags:="-j unix,user=${varnishd_jailuser} -P ${varnishd_pidfile} -a ${varnishd_listen} -T ${varnishd_admin} -f ${varnishd_config} -s ${varnishd_storage} -h ${varnishd_hash} ${varnishd_extra_flags}"}
 else
-	: ${varnishd_flags:="-P ${varnishd_pidfile} -a ${varnishd_listen} -T ${varnishd_admin} -b ${varnishd_backend} -s ${varnishd_storage} -h ${varnishd_hash} -u ${varnishd_user} -g ${varnishd_group} ${varnishd_extra_flags}"}
+	: ${varnishd_flags:="-j unix,user=${varnishd_jailuser} -P ${varnishd_pidfile} -a ${varnishd_listen} -T ${varnishd_admin} -b ${varnishd_backend} -s ${varnishd_storage} -h ${varnishd_hash} ${varnishd_extra_flags}"}
 fi
 
-# If we leave these set, rc.subr will su to them before starting
-# varnishd, which is not what we want.
-unset varnishd_user
-unset varnishd_group
+varnishd_checkconfig()
+{
+	if [ -z "${varnishd_config}" ]; then
+		echo "${name}: nothing to check, no configuration file defined, builtin VCL used"
+	else
+		echo "Performing sanity check on ${name} configuration:"
+		if eval ${command} -C -f "${varnishd_config}" 2> /dev/null ; then
+			echo "${name}: the configuration file ${varnishd_config} syntax is ok"
+		else
+			err 1 "${name}: the configuration file ${varnishd_config} syntax is NOT ok"
+		fi
+	fi
+}
 
+# Adapted from work done by Ingvar Hagelund <ingvar at redpill-linpro.com> (see redhat/varnish_reload_vcl)
+varnishd_reload()
+{
+	local _current_config_name _new_config_name _varnishadm_cmd
+
+	if [ -z "${varnishd_config}" ]; then
+		echo "${name}: nothing to reload, no configuration file defined, builtin VCL used"
+	else
+		_new_config_name="rc.d_reloaded@$(date +%Y%m%d%H%M%S)"
+		_varnishadm_cmd="%%PREFIX%%/bin/varnishadm ${varnish_cli_flags}"
+		if ! eval ${_varnishadm_cmd} vcl.list > /dev/null; then
+			err 1 "${name}: can't connect to varnishadm"
+		fi
+		_current_config_name=$(${_varnishadm_cmd} vcl.list | awk ' /^active/ { print $3 } ')
+		if ! eval ${_varnishadm_cmd} vcl.load ${_new_config_name} ${varnishd_config} > /dev/null; then
+			err 1 "${name}: vcl.load failed, you're still using previous rules (${_current_config_name})"
+		fi
+		if eval ${_varnishadm_cmd} vcl.use ${_new_config_name} > /dev/null; then
+			echo "VCL file \"${varnishd_config}\" has been successfully loaded as \"${_new_config_name}\""
+			echo "To remove previous loaded configurations, you should run \"${_varnishadm_cmd} vcl.discard <configname>\" by yourself"
+		else
+			err 1 "${name}: vcl.use failed, you're still using previous rules (${_current_config_name})"
+		fi
+	fi
+
+	return 0
+}
+
+varnishd_precmd()
+{
+	# Check config before starting
+	varnishd_checkconfig
+}
+
 run_rc_command "$1"

Modified: trunk/www/varnish4/files/varnishlog.in
===================================================================
--- trunk/www/varnish4/files/varnishlog.in	2016-03-12 16:41:39 UTC (rev 21121)
+++ trunk/www/varnish4/files/varnishlog.in	2016-03-12 21:56:11 UTC (rev 21122)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: head/www/varnish4/files/varnishlog.in 392997 2015-07-27 17:53:18Z feld $
+# $FreeBSD: head/www/varnish4/files/varnishlog.in 400701 2015-11-03 15:08:46Z feld $
 #
 
 # PROVIDE: varnishlog
@@ -21,12 +21,12 @@
 #	default: "/var/log/varnish.log"
 #
 # varnishlog_flags - command line arguments.
-#	default: "-D -P ${varnishlog_pidfile} -a -w ${varnishlog_file}"
+#	default: "-t off -P ${varnishlog_pidfile} -D -a -A -w ${varnishlog_file}"
 #
 # Add the following line to /etc/newsyslog.conf to rotate the log file
 # once a day:
 #
-# /var/log/varnish.log 640 7 * @T00 JB /var/run/varnishlog.pid
+# /var/log/varnish.log varnishlog:varnish 640 7 * @T00 JB /var/run/varnishlog.pid
 #
 # See varnishlog(1) for a detailed overview of command-line options.
 #
@@ -40,34 +40,26 @@
 : ${varnishlog_enable:=NO}
 : ${varnishlog_pidfile=/var/run/${name}.pid}
 : ${varnishlog_file=/var/log/varnish.log}
-: ${varnishlog_flags="-P ${varnishlog_pidfile} -D -a -w ${varnishlog_file}"}
+: ${varnishlog_flags="-t off -P ${varnishlog_pidfile} -D -a -A -w ${varnishlog_file}"}
 
-command="%%PREFIX%%/bin/${name}"
+procname="%%PREFIX%%/bin/${name}"
+command="/usr/sbin/daemon"
+command_args="-f -u varnishlog ${procname} ${varnishlog_flags}"
 pidfile=${varnishlog_pidfile}
 start_precmd=precmd
 
 precmd()
 {
-	waitcount=0
-	vsm=%%PREFIX%%/varnish/$(hostname)/_.vsm
-	
-        # wait no longer than 5s for  _.vsm file to arrive from varnishd
-	while :
-	do
-		if [ -f ${vsm} ] ; then
-			break
-		else
-			case "${waitcount}" in
-				5)	echo "${name}: Failed to start. Missing ${vsm} ?"
-					break
-					;;
-				*)	echo "${name}: waiting for ${vsm}"
-					waitcount=$((waitcount+1))
-					sleep 1
-					;;
-			esac
-		fi
-	done
+        # varnishlog_flags gets applied too early if we don't do this.
+        rc_flags=""
+
+	if [ ! -e ${pidfile} ]; then
+		install -o varnishlog -g varnish -m 644 /dev/null ${pidfile};
+	fi
+
+	if [ ! -e ${varnishlog_file} ]; then
+		install -o varnishlog -g varnish -m 640 /dev/null ${varnishlog_file};
+	fi
 }
 
 run_rc_command "$1"

Modified: trunk/www/varnish4/files/varnishncsa.in
===================================================================
--- trunk/www/varnish4/files/varnishncsa.in	2016-03-12 16:41:39 UTC (rev 21121)
+++ trunk/www/varnish4/files/varnishncsa.in	2016-03-12 21:56:11 UTC (rev 21122)
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $FreeBSD: head/www/varnish4/files/varnishncsa.in 392997 2015-07-27 17:53:18Z feld $
+# $FreeBSD: head/www/varnish4/files/varnishncsa.in 400701 2015-11-03 15:08:46Z feld $
 #
 
 # PROVIDE: varnishncsa
@@ -21,7 +21,7 @@
 #	default: "/var/log/varnishncsa.log"
 #
 # varnishncsa_flags - command line arguments.
-#	default: "-D -P ${varnishncsa_pidfile} -a -w ${varnishncsa_file}${varnishncsa_logformat:+ -P \"$varnishncsa_logformat\""
+#	default: "-t off -P ${varnishncsa_pidfile} -D -a -w ${varnishncsa_file}${varnishncsa_logformat:+ -F \"$varnishncsa_logformat\"}"
 #
 # varnishncsa_logformat - log file format.
 #       default: "" (uses varnishncsa's default format)
@@ -30,7 +30,7 @@
 # Add the following line to /etc/newsyslog.conf to rotate the log file
 # once a day:
 #
-# /var/log/varnishncsa.log 640 7 * @T00 JB /var/run/varnishncsa.pid
+# /var/log/varnishncsa.log varnishlog:varnish 640 7 * @T00 JB /var/run/varnishncsa.pid
 #
 # See varnishncsa(1) for a detailed overview of command-line options.
 #
@@ -45,34 +45,26 @@
 : ${varnishncsa_enable:=NO}
 : ${varnishncsa_pidfile=/var/run/${name}.pid}
 : ${varnishncsa_file=/var/log/${name}.log}
-: ${varnishncsa_flags="-P ${varnishncsa_pidfile} -D -a -w ${varnishncsa_file}${varnishncsa_logformat:+ -F \"$varnishncsa_logformat\"}"}
+: ${varnishncsa_flags="-t off -P ${varnishncsa_pidfile} -D -a -w ${varnishncsa_file} ${varnishncsa_logformat:+-F \"$varnishncsa_logformat\"}"}
 
-command="%%PREFIX%%/bin/${name}"
+procname="%%PREFIX%%/bin/${name}"
+command="/usr/sbin/daemon"
+command_args="-f -u varnishlog ${procname} ${varnishncsa_flags}"
 pidfile=${varnishncsa_pidfile}
 start_precmd=precmd
 
 precmd()
 {
-	waitcount=0
-	vsm=%%PREFIX%%/varnish/$(hostname)/_.vsm
-	
-        # wait no longer than 5s for  _.vsm file to arrive from varnishd
-	while :
-	do
-		if [ -f ${vsm} ] ; then
-			break
-		else
-			case "${waitcount}" in
-				5)	echo "${name}: Failed to start. Missing ${vsm} ?"
-					break
-					;;
-				*)	echo "${name}: waiting for ${vsm}"
-					waitcount=$((waitcount+1))
-					sleep 1
-					;;
-			esac
-		fi
-	done
+        # $varnishncsa_flags gets applied too early if we don't do this.
+        rc_flags=""
+
+	if [ ! -e ${pidfile} ]; then
+		install -o varnishlog -g varnish -m 644 /dev/null ${pidfile};
+	fi
+
+	if [ ! -e ${varnishncsa_file} ]; then
+		install -o varnishlog -g varnish -m 640 /dev/null ${varnishncsa_file};
+	fi
 }
 
 run_rc_command "$1"



More information about the Midnightbsd-cvs mailing list