r5511 - trunk/varnish-cache/redhat

ingvar at varnish-cache.org ingvar at varnish-cache.org
Thu Nov 4 13:37:31 CET 2010


Author: ingvar
Date: 2010-11-04 13:37:30 +0100 (Thu, 04 Nov 2010)
New Revision: 5511

Modified:
   trunk/varnish-cache/redhat/varnish_reload_vcl
Log:
make secret file optional in varnish_reload_vcl

Modified: trunk/varnish-cache/redhat/varnish_reload_vcl
===================================================================
--- trunk/varnish-cache/redhat/varnish_reload_vcl	2010-11-04 11:48:45 UTC (rev 5510)
+++ trunk/varnish-cache/redhat/varnish_reload_vcl	2010-11-04 12:37:30 UTC (rev 5511)
@@ -8,8 +8,9 @@
 # see the LICENSE file in the Varnish documentation directory
 #
 # The following environment variables have to be set:
-# RELOAD_VCL, VARNISH_VCL_CONF, VARNISH_ADMIN_LISTEN_ADDRESS,
-# VARNISH_ADMIN_LISTEN_PORT, VARNISH_SECRET_FILE
+# RELOAD_VCL, VARNISH_VCL_CONF, VARNISH_ADMIN_LISTEN_PORT
+# The following are optional:
+# VARNISH_SECRET_FILE, VARNISH_ADMIN_LISTEN_ADDRESS
 #
 # Requires GNU bash and GNU date
 #
@@ -60,20 +61,30 @@
 	exit 2
 
 elif [ -z "$VARNISH_SECRET_FILE" ]; then
-	echo "Error: VARNISH_SECRET_FILE is not set"
-	exit 2
+	echo "Warning: VARNISH_SECRET_FILE is not set"
+	secret=""
 
 elif [ ! -s "$VARNISH_SECRET_FILE" ]; then
 	echo "Error: varnish secret file $VARNISH_SECRET_FILE is unreadable or empty"
 	exit 2
+else
+	secret="-S $VARNISH_SECRET_FILE"
 fi
 
 # Done parsing, set up command
-VARNISHADM="varnishadm -S $VARNISH_SECRET_FILE -T $VARNISH_ADMIN_LISTEN_ADDRESS:$VARNISH_ADMIN_LISTEN_PORT"
+VARNISHADM="varnishadm $secret -T $VARNISH_ADMIN_LISTEN_ADDRESS:$VARNISH_ADMIN_LISTEN_PORT"
 
 # Now do the real work
 new_config="reload_$(date +%FT%H:%M:%S)"
 
+# Check if we are able to connect at all
+if $VARNISHADM vcl.list > /dev/null; then
+	$debug && echo vcl.list succeeded
+else
+	echo "Unable to run $VARNISHADM vcl.list"
+	exit 2
+fi
+
 if $VARNISHADM vcl.list | awk ' { print $3 } ' | grep -q $new_config; then
 	echo Trying to use new config $new_config, but that is already in use
 	exit 2




More information about the varnish-commit mailing list