nfd+ndn-tlv-ping: New upstart scripts for ndnpingserver, nfd-autoreg, and nfd-status-http-server

nfd-autoreg and nfd-status-http-server are separate package to install,
if the function needs to be enabled
diff --git a/nfd/Makefile b/nfd/Makefile
index a4b03de..c357554 100644
--- a/nfd/Makefile
+++ b/nfd/Makefile
@@ -11,6 +11,6 @@
 VERSION=0.1.0
 
 # PPA version
-PPA_VERSION=2
+PPA_VERSION=3
 
 include ../packaging.mk
diff --git a/nfd/debian/control b/nfd/debian/control
index dc10b30..59b4559 100644
--- a/nfd/debian/control
+++ b/nfd/debian/control
@@ -20,3 +20,13 @@
 Description: NFD - Named Data Networking Forwarding Daemon
  NFD is a network forwarder that implements and evolves together with the Named Data
  Networking (NDN) protocol.
+
+Package: nfd-status-http-server
+Architecture: i386 amd64
+Depends: nfd (= ${binary:Version}), ${misc:Depends}
+Description: NFD HTTP status server
+
+Package: nfd-autoreg
+Architecture: i386 amd64
+Depends: nfd (= ${binary:Version}), ${misc:Depends}
+Description: NFD autoreg server
diff --git a/nfd/debian/nfd-autoreg.default b/nfd/debian/nfd-autoreg.default
new file mode 100644
index 0000000..b3aa706
--- /dev/null
+++ b/nfd/debian/nfd-autoreg.default
@@ -0,0 +1,13 @@
+# nfd-autoreg defaults
+
+# Blacklisted networks
+BLACKLIST="10.0.0.0/8"
+
+# Whitelisted networks
+WHITELIST=""
+
+# Prefixes to register
+PREFIXES="/ndn/guest /ndn/broadcast"
+
+# Flags
+FLAGS=""
diff --git a/nfd/debian/nfd-autoreg.postinst b/nfd/debian/nfd-autoreg.postinst
new file mode 100644
index 0000000..3d20fcf
--- /dev/null
+++ b/nfd/debian/nfd-autoreg.postinst
@@ -0,0 +1,19 @@
+#!/bin/sh -e
+
+if [ "$1" != "configure" ]; then
+        exit 0
+fi
+
+APP=nfd-autoreg
+
+if [ ! -f /var/lib/ndn/$APP/.ndn/ndnsec-public-info.db ]; then
+    # Create HOME and generate self-signed NDN certificate
+    sudo mkdir -p /var/lib/ndn/$APP/.ndn
+    sudo chown -R ndn:ndn /var/lib/ndn/$APP
+    sudo -u ndn -g ndn HOME=/var/lib/ndn/$APP ndnsec-keygen /localhost/daemons/$APP | \
+      sudo -u ndn -g ndn HOME=/var/lib/ndn/$APP ndnsec-install-cert -
+fi
+
+#DEBHELPER#
+
+exit 0
diff --git a/nfd/debian/nfd-autoreg.upstart b/nfd/debian/nfd-autoreg.upstart
new file mode 100644
index 0000000..8c22c43
--- /dev/null
+++ b/nfd/debian/nfd-autoreg.upstart
@@ -0,0 +1,39 @@
+description "NFD Autoreg Server"
+author      "Alexander Afanasyev <alexander.afanasyev@ucla.edu>"
+
+start on started  nrd
+stop  on stopping nrd
+
+respawn
+respawn limit unlimited
+
+setuid ndn
+setgid ndn
+
+script
+  BLACKLIST=""
+  WHITELIST=""
+  PREFIXES=""
+  FLAGS=""
+  if [ -f /etc/default/nfd-autoreg ]; then
+      . /etc/default/nfd-autoreg
+  fi
+
+  blacklist=""
+  if [ "$BLACKLIST" != "" ]; then
+    blacklist=`for i in $BLACKLIST; do echo -n "-b $i "; done`
+  fi
+
+  whitelist=""
+  if [ "$WHITELIST" != "" ]; then
+    whitelist=`for i in $WHITELIST; do echo -n "-w $i "; done`
+  fi
+
+  prefixes=""
+  if [ "$PREFIXES" != "" ]; then
+    prefixes=`for i in $PREFIXES; do echo -n "--prefix $i "; done`
+  fi
+
+  export HOME=/var/lib/ndn/nfd-autoreg
+  exec /usr/bin/nfd-autoreg $blacklist $whitelist $prefixes $FLAGS
+end script
diff --git a/nfd/debian/nfd-status-http-server.default b/nfd/debian/nfd-status-http-server.default
new file mode 100644
index 0000000..6e7825a
--- /dev/null
+++ b/nfd/debian/nfd-status-http-server.default
@@ -0,0 +1,2 @@
+# nfd-status-http-server flags
+FLAGS="-a 0.0.0.0 -p 80"
diff --git a/nfd/debian/nfd-status-http-server.upstart b/nfd/debian/nfd-status-http-server.upstart
new file mode 100644
index 0000000..21740ea
--- /dev/null
+++ b/nfd/debian/nfd-status-http-server.upstart
@@ -0,0 +1,17 @@
+description "NDN HTTP Status Server"
+author      "Alexander Afanasyev <alexander.afanasyev@ucla.edu>"
+
+start on started  nfd
+stop  on stopping nfd
+
+respawn
+respawn limit unlimited
+
+script
+  FLAGS=""
+  if [ -f /etc/default/nfd-status-http-server ]; then
+      . /etc/default/nfd-status-http-server
+  fi
+  export HOME=/tmp/nfd-status-http-server
+  exec /usr/bin/nfd-status-http-server $FLAGS
+end script