Patchwork [14/21] portmap: /etc/init.d/portmap restart complains "command not found"

login
register
mail settings
Submitter Mark Hatle
Date May 29, 2013, 3:09 p.m.
Message ID <1369840203-21898-15-git-send-email-mark.hatle@windriver.com>
Download mbox | patch
Permalink /patch/50731/
State Accepted
Commit cfa813dfc8d8d4d45d9f995d20322a3226a4e20b
Headers show

Comments

Mark Hatle - May 29, 2013, 3:09 p.m.
From: Amy Fong <amy.fong@windriver.com>

portmap splits pmap_dump and pmap_set into a different package:
portmap_utils. Since this package might not be installed, I introduce
another init file that tests for the existance of these apps before trying
to run the pmap_* commands.

Signed-off-by: Amy Fong <amy.fong@windriver.com>
Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
 meta/recipes-connectivity/portmap/portmap/portmap.init | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

Patch

diff --git a/meta/recipes-connectivity/portmap/portmap/portmap.init b/meta/recipes-connectivity/portmap/portmap/portmap.init
index e46513e..e7031af 100755
--- a/meta/recipes-connectivity/portmap/portmap/portmap.init
+++ b/meta/recipes-connectivity/portmap/portmap/portmap.init
@@ -40,14 +40,22 @@  case "$1" in
         $0 restart
 	;;
     restart)
-	pmap_dump >/var/run/portmap.state
+	# pmap_dump and pmap_set may be in a different package and not installed...
+	if [ -f /sbin/pmap_dump -a -f /sbin/pmap_set ]; then
+		do_state=1
+	else
+		do_state=0
+	fi
+	[ $do_state -eq 1 ] && pmap_dump >/var/run/portmap.state
         $0 stop
         $0 start
-	if [ ! -f /var/run/portmap.upgrade-state ]; then
-          sleep 1
-	  pmap_set </var/run/portmap.state
+	if [ $do_state -eq 1 ]; then
+	  if [ ! -f /var/run/portmap.upgrade-state ]; then
+            sleep 1
+	    pmap_set </var/run/portmap.state
+	  fi
+	  rm -f /var/run/portmap.state
 	fi
-	rm -f /var/run/portmap.state
 	;;
     *)
 	echo "Usage: /etc/init.d/portmap {start|stop|reload|restart}"