tools: NFD startup script

`nfd-start` starts NFD and RIB daemon.
`nfd-stop` stops NFD and RIB daemon.
They are intended for source installation only.
Binary packages should prefer to use system service mechanism if available.

refs #1488

Change-Id: I09f2168619a47fdc0faa78079b7994f30f41ff75
diff --git a/tools/nfd-start.sh b/tools/nfd-start.sh
new file mode 100755
index 0000000..ed16690
--- /dev/null
+++ b/tools/nfd-start.sh
@@ -0,0 +1,24 @@
+#!@BASH@
+
+hasProcess() {
+  local processName=$1
+
+  if pgrep -x $processName >/dev/null
+  then
+    echo $processName
+  fi
+}
+
+hasNFD=$(hasProcess nfd)
+hasNRD=$(hasProcess nrd)
+
+if [[ -n $hasNFD$hasNRD ]]
+then
+  echo 'NFD or NRD is already running...'
+  exit 1
+fi
+
+sudo nfd &
+sleep 2
+nrd &
+sleep 2
diff --git a/tools/nfd-stop.sh b/tools/nfd-stop.sh
new file mode 100755
index 0000000..c0b46bd
--- /dev/null
+++ b/tools/nfd-stop.sh
@@ -0,0 +1,4 @@
+#!@BASH@
+
+sudo killall nrd
+sudo killall nfd
diff --git a/wscript b/wscript
index 440b04d..a32f734 100644
--- a/wscript
+++ b/wscript
@@ -97,6 +97,8 @@
 
     conf.load('coverage')
 
+    conf.find_program('bash', var='BASH')
+
     conf.define('DEFAULT_CONFIG_FILE', '%s/ndn/nfd.conf' % conf.env['SYSCONFDIR'])
 
     conf.write_config_header('config.hpp')
@@ -182,6 +184,13 @@
             source=bld.path.ant_glob('docs/manpages/**/*.rst'),
             install_path="${MANDIR}/")
 
+    for script in bld.path.ant_glob('tools/*.sh'):
+        bld(features='subst',
+            source='tools/%s' % (str(script)),
+            target='bin/%s' % (str(script.change_ext(''))),
+            install_path="${BINDIR}",
+            chmod=0755)
+
 def docs(bld):
     from waflib import Options
     Options.commands = ['doxygen', 'sphinx'] + Options.commands