nfd: Add ndn-autoconfig-server package
diff --git a/nfd/debian/control b/nfd/debian/control
index 15a07d4..ec0a261 100644
--- a/nfd/debian/control
+++ b/nfd/debian/control
@@ -30,3 +30,8 @@
 Architecture: i386 amd64
 Depends: nfd (= ${binary:Version}), ${misc:Depends}
 Description: NFD autoreg server
+
+Package: ndn-autoconfig-server
+Architecture: i386 amd64
+Depends: nfd (= ${binary:Version}), ${misc:Depends}
+Description: NDN autoconfig server
diff --git a/nfd/debian/control.precise b/nfd/debian/control.precise
index d4f2b0a..016fda5 100644
--- a/nfd/debian/control.precise
+++ b/nfd/debian/control.precise
@@ -30,3 +30,8 @@
 Architecture: i386 amd64
 Depends: nfd (= ${binary:Version}), ${misc:Depends}
 Description: NFD autoreg server
+
+Package: ndn-autoconfig-server
+Architecture: i386 amd64
+Depends: nfd (= ${binary:Version}), ${misc:Depends}
+Description: NDN autoconfig server
diff --git a/nfd/debian/ndn-autoconfig-server.default b/nfd/debian/ndn-autoconfig-server.default
new file mode 100644
index 0000000..ccad435
--- /dev/null
+++ b/nfd/debian/ndn-autoconfig-server.default
@@ -0,0 +1,10 @@
+# ndn-autoconfig-server defaults
+
+# FaceURI of NDN hub announced to hosts
+FACE_URI=""
+
+# Examples:
+# FACE_URI="udp://spurs.cs.ucla.edu"
+# FACE_URI="udp4://spurs.cs.ucla.edu"
+# FACE_URI="udp6://spurs.cs.ucla.edu"
+# FACE_URI="tcp://spurs.cs.ucla.edu"
diff --git a/nfd/debian/ndn-autoconfig-server.postinst b/nfd/debian/ndn-autoconfig-server.postinst
new file mode 100644
index 0000000..76d79e4
--- /dev/null
+++ b/nfd/debian/ndn-autoconfig-server.postinst
@@ -0,0 +1,19 @@
+#!/bin/sh -e
+
+if [ "$1" != "configure" ]; then
+        exit 0
+fi
+
+APP=ndn-autoconfig-server
+
+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/ndn-autoconfig-server.upstart b/nfd/debian/ndn-autoconfig-server.upstart
new file mode 100644
index 0000000..8ea81c2
--- /dev/null
+++ b/nfd/debian/ndn-autoconfig-server.upstart
@@ -0,0 +1,23 @@
+description "NDN Autoconfig 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
+  FACE_URI=""
+  if [ -f /etc/default/ndn-autoconfig-server ]; then
+      . /etc/default/ndn-autoconfig-server
+  fi
+
+  if [ "$FACE_URI != "" ]; then
+    export HOME=/var/lib/ndn/ndn-autoconfig-server
+    exec /usr/bin/ndn-autoconfig-server $FACE_URI
+  fi
+end script