Ubuntu Pastebin

Paste from ubuntu at Fri, 6 Nov 2015 19:56:48 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
--- /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
 
Download as text