From 63f0ac178809135848003819f6743547282a262d Mon Sep 17 00:00:00 2001
From: Pavlos Parissis <pavlos.parissis@gmail.com>
Date: Thu, 2 Oct 2014 16:46:22 +0200
Subject: [PATCH] bird.init: Run status, reload and stop only for enabled
 versions of IP

Puppet and other tools which are taking actions based on the exit code
were confused when only IPv4 was enabled because return code was coming from
running commands(status/reload/stop) on IPv6 daemon, which was never
started.
---
 misc/bird.init | 60 ++++++++++++++++++++++++++++++++++++++--------------------
 1 file changed, 40 insertions(+), 20 deletions(-)

diff --git a/misc/bird.init b/misc/bird.init
index 93aa83d..d47fbbd 100755
--- a/misc/bird.init
+++ b/misc/bird.init
@@ -58,22 +58,35 @@ case "$1" in
 	fi
 	;;
   stop)
-	echo -n "Stopping BIRD for IPv4: "
-	killproc bird
-	RETVAL=$?
-	echo
-	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/bird
+	if [ "$BIRD4" = "yes" ]
+	then
+		echo -n "Stopping BIRD for IPv4: "
+		killproc bird
+		RETVAL=$?
+		echo
+		[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/bird
+	fi

-	echo -n "Stopping BIRD for IPv6: "
-	killproc bird6
-	RETVAL=$?
-	echo
-	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/bird6
+	if [ "$BIRD6" = "yes" ]
+	then
+		echo -n "Stopping BIRD for IPv6: "
+		killproc bird6
+		RETVAL=$?
+		echo
+		[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/bird6
+	fi
 	;;
   status)
-	status bird
-	status bird6
-	RETVAL=$?
+	if [ "$BIRD4" = "yes" ]
+	then
+		status bird
+		RETVAL=$?
+        fi
+	if [ "$BIRD6" = "yes" ]
+	then
+		status bird6
+		RETVAL=$?
+        fi
 	;;
   restart)
   	$0 stop
@@ -81,13 +94,20 @@ case "$1" in
 	RETVAL=$?
 	;;
   reload)
-	killproc bird -HUP
- 	RETVAL=$?
-	echo
-	echo -n "Reloading BIRD for IPv6: "
-	killproc bird6 -HUP
-	RETVAL=$?
-	echo
+	if [ "$BIRD4" = "yes" ]
+	then
+		echo -n "Reloading BIRD for IPv4: "
+		killproc bird -HUP
+		RETVAL=$?
+		echo
+	fi
+	if [ "$BIRD6" = "yes" ]
+	then
+		echo -n "Reloading BIRD for IPv6: "
+		killproc bird6 -HUP
+		RETVAL=$?
+		echo
+	fi
 	;;
   *)
 	echo "Usage: bird.init {start|stop|status|restart|reload}"
--
2.1.0

