If you need to compile your varnish VCL file with custom options, maybe because of libraries like GeoIP, and you're running Debian, you can not use the init script that's shipped by default.
It will not work because of how shell expansion works in the start-stop-daemon
command contained in the init script. I wrote my explanation and a proposed fix in much more detail in this stack overflow question:
http://stackoverflow.com/questions/5906603/varnish-daemon-opts-options-errors/8333333#8333333
TL;DR: (+ quick & dirty fix) patch your init script like this:
start_varnishd() { log_daemon_msg "Starting $DESC" "$NAME" output=$(/bin/tempfile -s.varnish) - if start-stop-daemon - --start --quiet --pidfile ${PIDFILE} --exec ${DAEMON} -- - -P ${PIDFILE} ${DAEMON_OPTS} > ${output} 2>&1; then + if bash -c "start-stop-daemon + --start --quiet --pidfile ${PIDFILE} --exec ${DAEMON} -- + -P ${PIDFILE} ${DAEMON_OPTS} > ${output} 2>&1"; then log_end_msg 0 else log_end_msg 1 cat $output exit 1 fi rm $output }
Let me know if it works for you!
EDIT (7/Mar/2012): bug was filed in Debian as #659005. Nothing happened so far. We'll see.