--- /etc/init.d/haproxy.dist 2015-11-06 19:35:57.368000000 +0000
+++ /etc/init.d/haproxy 2015-11-06 19:56:10.152000000 +0000
@@ -61,10 +61,25 @@
fi
ret=0
+ local has_pidflag=false pidflags="" tmpf=""
+ if start-stop-daemon --help 2>&1 | grep -q -- --pid; then
+ has_pidflag=true
+ fi
+
+ tmpf=$(mktemp) || return 1
for pid in $(cat $PIDFILE); do
+ # in cases where start-stop-daemon does not have --pid
+ # we use --pidfile and provide it with a temporary pidfile
+ if $has_pidflag; then
+ pidflags="--pid $pid"
+ else
+ echo "$pid" > "$tmpf"
+ pidflags="--pidfile $tmpf"
+ fi
start-stop-daemon --quiet --oknodo --stop \
- --retry 5 --pid $pid --exec $HAPROXY || ret=$?
+ --retry 5 $pidflags --exec $HAPROXY || ret=$?
done
+ rm -f "$tmpf"
[ $ret -eq 0 ] && rm -f $PIDFILE