daemon+rib: Merge nrd and nfd into a single process (separate threads)

Change-Id: I41952d5b8ee29f109130c570e0d13ccad6970d2f
Refs: #2489
diff --git a/tools/nfd-start.sh b/tools/nfd-start.sh
index 4df12d7..4c14e07 100755
--- a/tools/nfd-start.sh
+++ b/tools/nfd-start.sh
@@ -6,7 +6,7 @@
   -h)
     echo Usage
     echo $0
-    echo "  Start NFD and RIB Management daemon"
+    echo "  Start NFD"
     exit 0
     ;;
   -V)
@@ -30,11 +30,10 @@
 }
 
 hasNFD=$(hasProcess nfd)
-hasNRD=$(hasProcess nrd)
 
-if [[ -n $hasNFD$hasNRD ]]
+if [[ -n $hasNFD ]]
 then
-  echo 'NFD or NRD is already running...'
+  echo 'NFD is already running...'
   exit 1
 fi
 
@@ -49,7 +48,10 @@
   exit 2
 fi
 
-sudo nfd &
-sleep 2
-nrd &
-sleep 2
+sudo @BINDIR@/nfd &
+
+if [ -f @SYSCONFDIR@/ndn/nfd-init.sh ]; then
+    sleep 2 # post-start is executed just after nfd process starts, but there is no guarantee
+    # that all initialization has been finished
+    . @SYSCONFDIR@/ndn/nfd-init.sh
+fi
diff --git a/tools/nfd-stop.sh b/tools/nfd-stop.sh
index ed55929..bdbcf12 100755
--- a/tools/nfd-stop.sh
+++ b/tools/nfd-stop.sh
@@ -6,7 +6,7 @@
   -h)
     echo Usage
     echo $0
-    echo "  Stop NFD and RIB Management daemon"
+    echo "  Stop NFD"
     exit 0
     ;;
   -V)
@@ -20,5 +20,4 @@
     ;;
 esac
 
-sudo killall nrd
 sudo killall nfd
diff --git a/tools/nrd.sh b/tools/nrd.sh
new file mode 100644
index 0000000..52e7112
--- /dev/null
+++ b/tools/nrd.sh
@@ -0,0 +1,5 @@
+#!@BASH@
+
+echo "NDN RIB Management Daemon does not need to be started separately anymore"
+sleep 10
+exit 0