]> git.pld-linux.org Git - packages/varnish.git/blobdiff - varnish.init
- HTTP_HDR_MAX_VAL 128 instead of 32
[packages/varnish.git] / varnish.init
index 8c9c6f3899a22d98c5df5625932b15fc52382274..741cdcb70e6fde5831c18fdcfc42167330414e40 100644 (file)
@@ -29,24 +29,33 @@ fi
 
 PIDFILE=/var/run/varnishd.pid
 
+# import some env from parent process
+if [ -f /proc/$PPID/environ ]; then
+       eval $(tr '\0' '\n' < /proc/$PPID/environ | grep -E '^(USER|SUDO_USER|LOGNAME)=')
+       LOGNAME=${SUDO_USER:-${LOGNAME:-$USER}}
+fi
+
 # Generate a label, prefixed with the caller's username, from the
 # kernel random uuid generator, fallback to timestamp
 if [ -f /proc/sys/kernel/random/uuid ]; then
        read uuid < /proc/sys/kernel/random/uuid
-       vcl_label="${LOGNAME}${LOGNAME:+:}${uuid}"
+       vcl_label="$(date +${LOGNAME}${LOGNAME:+:}%Y-%m-%d:%H.%M:${uuid})"
 else
-       vcl_label="$($date +${LOGNAME}${LOGNAME:+:}%s.%N)"
+       vcl_label="$(date +${LOGNAME}${LOGNAME:+:}%s.%N)"
 fi
 
+varnishadm() {
+       /usr/bin/varnishadm -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} "$@"
+}
 # for simplier code
 vcl_load() {
-       /usr/bin/varnishadm -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} vcl.load "$@"
+       varnishadm vcl.load "$@"
 }
 vcl_use() {
-       /usr/bin/varnishadm -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} vcl.use "$@"
+       varnishadm vcl.use "$@"
 }
 vcl_discard() {
-       /usr/bin/varnishadm -T ${VARNISH_ADMIN_LISTEN_ADDRESS}:${VARNISH_ADMIN_LISTEN_PORT} vcl.discard "$@"
+       varnishadm vcl.discard "$@"
 }
 
 # configtest itself
@@ -109,7 +118,7 @@ start() {
        # default limits
        SERVICE_LIMITS="${SERVICE_LIMIS:--n $NFILES -l $MEMLOCK}"
 
-       # DAEMON_OPTS is used by the init script.  If you add or remove options, make
+       # DAEMON_OPTS is used by the init script. If you add or remove options, make
        # sure you update this section, too.
        DAEMON_OPTS="
                -a ${VARNISH_LISTEN_ADDRESS}:${VARNISH_LISTEN_PORT}
@@ -161,7 +170,7 @@ restart() {
                # checkconfig needs running varnish
                checkconfig
        fi
-       stop
+       stop
        start
 }
 
@@ -205,12 +214,16 @@ case "$1" in
   checkconfig|configtest)
        checkconfig 1
        ;;
+  varnishadm)
+       shift
+       varnishadm "$@"
+       ;;
   status)
        status --pidfile $PIDFILE varnishd
        RETVAL=$?
        ;;
   *)
-       msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|checkconfig|status}"
+       msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|checkconfig|varnishadm|status}"
        exit 3
 esac
 
This page took 0.077717 seconds and 4 git commands to generate.