nfd: Don't install upstart script for nrd and make sure default certificates are correct

Change-Id: I665dc568e0f5f5cc92e461977175a7f40d6d2e0d
Refs: #10, #9, #5
diff --git a/nfd/Makefile b/nfd/Makefile
index c3e0d2c..e3afaa0 100644
--- a/nfd/Makefile
+++ b/nfd/Makefile
@@ -11,6 +11,6 @@
 VERSION=0.3.1
 
 # PPA version
-PPA_VERSION=2
+PPA_VERSION=3
 
 include ../packaging.mk
diff --git a/nfd/debian/copyright b/nfd/debian/copyright
index c6fe8f5..42e00bd 100644
--- a/nfd/debian/copyright
+++ b/nfd/debian/copyright
@@ -3,13 +3,13 @@
 Source: http://github.com/named-data/NFD
 
 Files: *
-Copyright: Copyright (c) 2014, Regents of the University of California,
-                               Arizona Board of Regents,
-                               Colorado State University,
-                               University Pierre & Marie Curie, Sorbonne University,
-                               Washington University in St. Louis,
-                               Beijing Institute of Technology,
-                               The University of Memphis
+Copyright: Copyright (c) 2014-2015, Regents of the University of California,
+                                    Arizona Board of Regents,
+                                    Colorado State University,
+                                    University Pierre & Marie Curie, Sorbonne University,
+                                    Washington University in St. Louis,
+                                    Beijing Institute of Technology,
+                                    The University of Memphis.
 License: GPL-3+
  NFD is free software: you can redistribute it and/or modify it under the terms
  of the GNU General Public License as published by the Free Software Foundation,
@@ -24,7 +24,7 @@
 
 
 Files: debian/*
-Copyright: Copyright (c) 2013-2014, Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+Copyright: Copyright (c) 2013-2015, Alexander Afanasyev <alexander.afanasyev@ucla.edu>
 License: BSD
  Redistribution and use in source and binary forms, with or without
  modification, are permitted provided that the following conditions are met:
diff --git a/nfd/debian/nfd.conf b/nfd/debian/nfd.conf
index 1119c9a..bc93199 100644
--- a/nfd/debian/nfd.conf
+++ b/nfd/debian/nfd.conf
@@ -96,7 +96,7 @@
 {
   authorize
   {
-    certfile certs/localhost_daemons_nrd.ndncert
+    certfile certs/localhost_daemons_nfd.ndncert
     privileges
     {
         faces
diff --git a/nfd/debian/nfd.nfd-restart.upstart b/nfd/debian/nfd.nfd-restart.upstart
deleted file mode 100644
index ebeba18..0000000
--- a/nfd/debian/nfd.nfd-restart.upstart
+++ /dev/null
@@ -1,11 +0,0 @@
-# nfd-restart.conf
-#
-# Restarting NDN Forwarding Daemon on network connectivity changes
-
-start on net-device-up
-task
-
-script
-        status nfd | grep -q start/ || stop
-        restart nfd
-end script
diff --git a/nfd/debian/nfd.nrd.upstart b/nfd/debian/nfd.nrd.upstart
deleted file mode 100644
index 69d5913..0000000
--- a/nfd/debian/nfd.nrd.upstart
+++ /dev/null
@@ -1,29 +0,0 @@
-# nrd.conf
-#
-# NDN RIB Manager Daemon
-
-description "NDN RIB Manager Daemon"
-author      "Tai-Lin Chu <tailinchu@gmail.com>"
-
-start on started  nfd
-stop  on stopping nfd
-
-respawn
-respawn limit unlimited
-
-setuid ndn
-setgid ndn
-
-pre-start exec sleep 2
-script
-  export HOME=/var/lib/ndn/nrd
-  /usr/bin/nrd --config /etc/ndn/nfd.conf 2>> /var/log/ndn/nrd.log
-end script
-
-post-stop exec sleep 2
-
-# post-start script
-#     sleep 3
-#     # Apply initial configuration
-#     [ -r /etc/ndn/nfd.init ] && sh /etc/ndn/nfd.init
-# end script
diff --git a/nfd/debian/nfd.postinst b/nfd/debian/nfd.postinst
index e4c4ff8..23e3794 100644
--- a/nfd/debian/nfd.postinst
+++ b/nfd/debian/nfd.postinst
@@ -1,37 +1,27 @@
 #!/bin/sh -e
 
 if [ "$1" != "configure" ]; then
-        exit 0
+    exit 0
 fi
 
+# Create log folder
+mkdir -p "/var/log/ndn"
 
-if [ ! -d /var/log/ndn ]; then
-    mkdir -p /var/log/ndn
-    chown -R ndn:ndn /var/log/ndn
-fi
+# Create HOME and generate self-signed NDN certificate
+mkdir -p "/var/lib/ndn/nfd/.ndn"
 
-if [ ! -f /etc/ndn/certs/localhost_daemons_nrd.ndncert ]; then
-    # Create HOME and generate self-signed NDN certificate for nfd
-    mkdir -p /var/lib/ndn/nfd/.ndn
-    (
-        export HOME=/var/lib/ndn/nfd
-        ndnsec-keygen /localhost/daemons/nfd | ndnsec-install-cert -
-    )
+(
+    export HOME="/var/lib/ndn/nfd"
+    if [ -z "$(ndnsec-get-default)" ]; then
+        ndnsec-keygen "/localhost/daemons/nfd" | ndnsec-install-cert -
+    fi
 
-    # Create HOME and generate self-signed NDN certificate for nrd
-    # Dump RIB Management daemon's certificate
-    mkdir -p /var/lib/ndn/nrd/.ndn
-    (
-         export HOME=/var/lib/ndn/nrd
-         ndnsec-keygen /localhost/daemons/nrd | ndnsec-install-cert -
+    mkdir -p "/etc/ndn/certs"
+    ndnsec-dump-certificate -i "$(ndnsec-get-default)" > \
+        "/etc/ndn/certs/localhost_daemons_nfd.ndncert"
+)
 
-         mkdir /etc/ndn/certs
-         ndnsec-dump-certificate -i /localhost/daemons/nrd > \
-           /etc/ndn/certs/localhost_daemons_nrd.ndncert
-    )
-fi
-
-chown -R ndn:ndn /var/lib/ndn
+chown -R ndn:ndn "/var/lib/ndn/nfd"
 
 #DEBHELPER#