nfd: Add systemd startup scripts
refs #2810
Change-Id: Ib710edddcd94d78104247d8ed70d536263a5c40a
diff --git a/nfd/debian/control b/nfd/debian/control
index ababa42..3e59b84 100644
--- a/nfd/debian/control
+++ b/nfd/debian/control
@@ -2,6 +2,7 @@
Priority: extra
Maintainer: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
Build-Depends: debhelper (>= 8.0.0),
+ dh-systemd (>= 1.5),
python (>= 2.7.0),
pkg-config (>= 0.26),
ndn-cxx-dev (>= 0.3.0~rc0.2),
diff --git a/nfd/debian/control.trusty b/nfd/debian/control.trusty
new file mode 100644
index 0000000..ababa42
--- /dev/null
+++ b/nfd/debian/control.trusty
@@ -0,0 +1,42 @@
+Source: nfd
+Priority: extra
+Maintainer: Alexander Afanasyev <alexander.afanasyev@ucla.edu>
+Build-Depends: debhelper (>= 8.0.0),
+ python (>= 2.7.0),
+ pkg-config (>= 0.26),
+ ndn-cxx-dev (>= 0.3.0~rc0.2),
+ python-sphinx,
+ libpcap-dev,
+ libboost-all-dev (>= 1.48.0)
+Standards-Version: 3.9.2
+Section: net
+Homepage: http://named-data.net/doc/NFD/
+Vcs-Git: git://github.com/named-data/NFD.git
+Vcs-Browser: http://github.com/named-data/NFD
+
+Package: nfd
+Architecture: i386 amd64
+Depends: ${shlibs:Depends}, ${misc:Depends}, ndn-cxx, sudo, procps
+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}, python2.7-minimal
+Description: NFD HTTP status server
+
+Package: nfd-autoreg
+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
+
+Package: nfd-all
+Architecture: any
+Depends: ${misc:Depends}, nfd, nfd-status-http-server, nfd-autoreg, ndn-autoconfig-server
+Description: NFD and all related daemons
diff --git a/nfd/debian/ndn-autoconfig-server.service b/nfd/debian/ndn-autoconfig-server.service
new file mode 100644
index 0000000..53e2de4
--- /dev/null
+++ b/nfd/debian/ndn-autoconfig-server.service
@@ -0,0 +1,44 @@
+# Copyright (c) 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.
+#
+# This file is part of NFD (Named Data Networking Forwarding Daemon).
+# See AUTHORS.md for complete list of NFD authors and contributors.
+#
+# 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,
+# either version 3 of the License, or (at your option) any later version.
+#
+# NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Eric Newberry <enewberry@email.arizona.edu>
+
+[Unit]
+Description=NDN Autoconfig Server
+Documentation=man:nfd-autoreg
+Requires=nfd.service
+After=nfd.service
+
+[Service]
+Environment=HOME=/var/lib/ndn/ndn-autoconfig-server
+EnvironmentFile=-/etc/default/ndn-autoconfig-server
+User=ndn
+Group=ndn
+ExecStart=/bin/sh -ec 'if [ "$FACE_URI" != "" ]; then exec /usr/bin/ndn-autoconfig-server $ROUTABLE_PREFIXES $FACE_URI; fi'
+Restart=on-failure
+ProtectSystem=full
+PrivateTmp=yes
+PrivateDevices=yes
+ProtectHome=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/nfd/debian/nfd-autoreg.default b/nfd/debian/nfd-autoreg.default
index 218e2d3..8666a95 100644
--- a/nfd/debian/nfd-autoreg.default
+++ b/nfd/debian/nfd-autoreg.default
@@ -1,15 +1,19 @@
# nfd-autoreg defaults
# Blacklisted networks
-BLACKLIST="10.0.0.0/8"
+# Format: "-b NET1 -b NET2 ..."
+BLACKLIST="-b 10.0.0.0/8"
# Whitelisted networks
+# Format: "-w NET1 -w NET2 ..."
WHITELIST=""
# Prefixes to register on All faces:
-ALL_FACES_PREFIXES="/ndn/broadcast"
+# Format: "--all-faces-prefix /prefix/1 --all-faces-prefix /prefix/2 ..."
+ALL_FACES_PREFIXES="--all-faces-prefix /ndn/broadcast"
# Prefixes to register just on on-demand faces:
+# Format: "--prefix /prefix/1 --prefix /prefix/2 ..."
ON_DEMAND_FACES_PREFIXES=""
# Flags
diff --git a/nfd/debian/nfd-autoreg.service b/nfd/debian/nfd-autoreg.service
new file mode 100644
index 0000000..552b5c5
--- /dev/null
+++ b/nfd/debian/nfd-autoreg.service
@@ -0,0 +1,44 @@
+# Copyright (c) 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.
+#
+# This file is part of NFD (Named Data Networking Forwarding Daemon).
+# See AUTHORS.md for complete list of NFD authors and contributors.
+#
+# 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,
+# either version 3 of the License, or (at your option) any later version.
+#
+# NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Eric Newberry <enewberry@email.arizona.edu>
+
+[Unit]
+Description=NDN Autoreg Server
+Documentation=man:nfd-autoreg
+Wants=nfd.service
+After=nfd.service
+
+[Service]
+User=ndn
+Group=ndn
+Environment=HOME=/var/lib/ndn/nfd-autoreg
+EnvironmentFile=-/etc/default/nfd-autoreg
+ExecStart=/usr/bin/nfd-autoreg $BLACKLIST $WHITELIST $ON_DEMAND_FACES_PREFIXES $ALL_FACES_PREFIXES $FLAGS
+Restart=on-failure
+ProtectSystem=full
+PrivateTmp=yes
+PrivateDevices=yes
+ProtectHome=yes
+
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file
diff --git a/nfd/debian/nfd-autoreg.upstart b/nfd/debian/nfd-autoreg.upstart
index dc0bd7f..379e8ec 100644
--- a/nfd/debian/nfd-autoreg.upstart
+++ b/nfd/debian/nfd-autoreg.upstart
@@ -20,26 +20,6 @@
. /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
-
- all_prefixes=""
- if [ "$ALL_FACES_PREFIXES" != "" ]; then
- all_prefixes=`for i in $ALL_FACES_PREFIXES; do echo -n "--all-faces-prefix $i "; done`
- fi
-
- on_demand_prefixes=""
- if [ "$ON_DEMAND_FACES_PREFIXES" != "" ]; then
- on_demand_prefixes=`for i in $ON_DEMAND_FACES_PREFIXES; do echo -n "--prefix $i "; done`
- fi
-
export HOME=/var/lib/ndn/nfd-autoreg
- exec /usr/bin/nfd-autoreg $blacklist $whitelist $on_demand_prefixes $all_prefixes $FLAGS
+ exec /usr/bin/nfd-autoreg $BLACKLIST $WHITELIST $ON_DEMAND_FACES_PREFIXES $ALL_FACES_PREFIXES $FLAGS
end script
diff --git a/nfd/debian/nfd-start b/nfd/debian/nfd-start
index 0edfea9..d350776 100755
--- a/nfd/debian/nfd-start
+++ b/nfd/debian/nfd-start
@@ -1,3 +1,3 @@
#!/bin/sh
-sudo start nfd
+sudo systemctl start nfd
diff --git a/nfd/debian/nfd-start.precise b/nfd/debian/nfd-start.precise
new file mode 100755
index 0000000..0edfea9
--- /dev/null
+++ b/nfd/debian/nfd-start.precise
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+sudo start nfd
diff --git a/nfd/debian/nfd-start.trusty b/nfd/debian/nfd-start.trusty
new file mode 100755
index 0000000..0edfea9
--- /dev/null
+++ b/nfd/debian/nfd-start.trusty
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+sudo start nfd
diff --git a/nfd/debian/nfd-status-http-server.service b/nfd/debian/nfd-status-http-server.service
new file mode 100644
index 0000000..3088a83
--- /dev/null
+++ b/nfd/debian/nfd-status-http-server.service
@@ -0,0 +1,40 @@
+# Copyright (c) 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.
+#
+# This file is part of NFD (Named Data Networking Forwarding Daemon).
+# See AUTHORS.md for complete list of NFD authors and contributors.
+#
+# 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,
+# either version 3 of the License, or (at your option) any later version.
+#
+# NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Eric Newberry <enewberry@email.arizona.edu>
+
+[Unit]
+Description=NFD HTTP Status Server
+Documentation=man:nfd-status-http-server
+After=nfd.service
+
+[Service]
+EnvironmentFile=-/etc/default/nfd-status-http-server
+ExecStart=/usr/bin/nfd-status-http-server $FLAGS
+Restart=on-failure
+ProtectSystem=full
+PrivateTmp=yes
+PrivateDevices=yes
+ProtectHome=yes
+
+[Install]
+WantedBy=multi-user.target
\ No newline at end of file
diff --git a/nfd/debian/nfd-status-http-server.upstart b/nfd/debian/nfd-status-http-server.upstart
index 21740ea..df28359 100644
--- a/nfd/debian/nfd-status-http-server.upstart
+++ b/nfd/debian/nfd-status-http-server.upstart
@@ -1,4 +1,4 @@
-description "NDN HTTP Status Server"
+description "NFD HTTP Status Server"
author "Alexander Afanasyev <alexander.afanasyev@ucla.edu>"
start on started nfd
diff --git a/nfd/debian/nfd-stop b/nfd/debian/nfd-stop
index 2069e9c..301cf15 100755
--- a/nfd/debian/nfd-stop
+++ b/nfd/debian/nfd-stop
@@ -1,3 +1,3 @@
#!/bin/sh
-sudo stop nfd
+sudo systemctl stop nfd
diff --git a/nfd/debian/nfd-stop.precise b/nfd/debian/nfd-stop.precise
new file mode 100755
index 0000000..2069e9c
--- /dev/null
+++ b/nfd/debian/nfd-stop.precise
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+sudo stop nfd
diff --git a/nfd/debian/nfd-stop.trusty b/nfd/debian/nfd-stop.trusty
new file mode 100755
index 0000000..2069e9c
--- /dev/null
+++ b/nfd/debian/nfd-stop.trusty
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+sudo stop nfd
diff --git a/nfd/debian/nfd.service b/nfd/debian/nfd.service
new file mode 100644
index 0000000..873cf42
--- /dev/null
+++ b/nfd/debian/nfd.service
@@ -0,0 +1,42 @@
+# Copyright (c) 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.
+#
+# This file is part of NFD (Named Data Networking Forwarding Daemon).
+# See AUTHORS.md for complete list of NFD authors and contributors.
+#
+# 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,
+# either version 3 of the License, or (at your option) any later version.
+#
+# NFD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
+# without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# NFD, e.g., in COPYING.md file. If not, see <http://www.gnu.org/licenses/>.
+#
+# Author: Eric Newberry <enewberry@email.arizona.edu>
+
+[Unit]
+Description=NDN Forwarding Daemon
+Documentation=man:nfd man:nfdc man:nfd-status
+Wants=network-online.target
+After=network-online.target
+
+[Service]
+Environment=HOME=/var/lib/ndn/nfd
+ExecStart=/usr/bin/nfd --config /etc/ndn/nfd.conf
+ExecStartPost=/bin/sh -ec 'sleep 2; if [ -f /etc/ndn/nfd-init.sh ]; then . /etc/ndn/nfd-init.sh; fi'
+Restart=on-failure
+ProtectSystem=full
+PrivateTmp=yes
+PrivateDevices=yes
+ProtectHome=yes
+
+[Install]
+WantedBy=multi-user.target
diff --git a/nfd/debian/rules b/nfd/debian/rules
index b4d146e..cde2d83 100755
--- a/nfd/debian/rules
+++ b/nfd/debian/rules
@@ -14,7 +14,7 @@
CXXFLAGS += -std=c++11
%:
- dh $@ --parallel
+ dh $@ --parallel --with=systemd
override_dh_auto_configure:
CXXFLAGS="$(CXXFLAGS)" ./waf configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
@@ -37,7 +37,14 @@
override_dh_auto_test:
-override_dh_installinit:
- dh_installinit
- dh_installinit --name=nrd
- dh_installinit --name=nfd-restart
+override_dh_systemd_enable:
+ dh_systemd_enable -pnfd
+ dh_systemd_enable -pnfd-status-http-server
+ dh_systemd_enable -pndn-autoconfig-server --no-enable
+ dh_systemd_enable -pnfd-autoreg --no-enable
+
+override_dh_systemd_start:
+ dh_systemd_start -pnfd
+ dh_systemd_start -pnfd-status-http-server
+ dh_systemd_start -pndn-autoconfig-server --no-start
+ dh_systemd_start -pnfd-autoreg --no-start
diff --git a/nfd/debian/rules.precise b/nfd/debian/rules.precise
index 07f0c82..437c89b 100755
--- a/nfd/debian/rules.precise
+++ b/nfd/debian/rules.precise
@@ -36,8 +36,3 @@
rm -f docs/*.pyc
override_dh_auto_test:
-
-override_dh_installinit:
- dh_installinit
- dh_installinit --name=nrd
- dh_installinit --name=nfd-restart
diff --git a/nfd/debian/rules.trusty b/nfd/debian/rules.trusty
new file mode 100755
index 0000000..5318c7e
--- /dev/null
+++ b/nfd/debian/rules.trusty
@@ -0,0 +1,38 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+# export DH_VERBOSE=1
+
+LDFLAGS := $(shell dpkg-buildflags --get LDFLAGS)
+CXXFLAGS := $(shell dpkg-buildflags --get CXXFLAGS)
+CXXFLAGS += -std=c++11
+
+%:
+ dh $@ --parallel
+
+override_dh_auto_configure:
+ CXXFLAGS="$(CXXFLAGS)" ./waf configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var
+
+override_dh_auto_build:
+ ./waf build
+
+override_dh_auto_install:
+ ./waf install --destdir=debian/tmp
+
+override_dh_auto_clean:
+ ./waf distclean
+
+override_dh_clean:
+ dh_clean
+ ./waf distclean
+ rm -rf .waf-1*
+ rm -f .waf-tools/*.pyc
+ rm -f docs/*.pyc
+
+override_dh_auto_test: