redhat: add systemd service files

 * redhat/*.service: add systemd service file for each routing daemon
 * redhat/quagga.sysconfig: add comment about watchquagga and systemd
 * redhat/Makefile.am: add systemd service files to distribution

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Signed-off-by: David Lamparter <equinox@diac24.net>
diff --git a/redhat/Makefile.am b/redhat/Makefile.am
index e037ec5..c83e959 100644
--- a/redhat/Makefile.am
+++ b/redhat/Makefile.am
@@ -1,4 +1,6 @@
 
-EXTRA_DIST = quagga.pam quagga.sysconfig quagga.spec quagga.logrotate \
-	zebra.init ripd.init ospfd.init ripngd.init ospf6d.init bgpd.init \
-	isisd.init babeld.init watchquagga.init quagga.pam.stack
+EXTRA_DIST = babeld.init babeld.service bgpd.init bgpd.service isisd.init \
+	isisd.service ospf6d.init ospf6d.service ospfd.init ospfd.service \
+	quagga.logrotate quagga.pam quagga.pam.stack quagga.spec \
+	quagga.sysconfig ripd.init ripd.service ripngd.init ripngd.service \
+	watchquagga.init zebra.init zebra.service
diff --git a/redhat/babeld.service b/redhat/babeld.service
new file mode 100644
index 0000000..b1ea943
--- /dev/null
+++ b/redhat/babeld.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Babel routing daemon
+BindTo=zebra.service
+After=syslog.target network.target zebra.service
+ConditionPathExists=/etc/quagga/babeld.conf
+
+[Service]
+Type=forking
+EnvironmentFile=/etc/sysconfig/quagga
+ExecStart=/usr/sbin/babeld -d $BABELD_OPTS -f /etc/quagga/babeld.conf
+Restart=on-abort
+
+[Install]
+WantedBy=network.target
diff --git a/redhat/bgpd.service b/redhat/bgpd.service
new file mode 100644
index 0000000..5040284
--- /dev/null
+++ b/redhat/bgpd.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=BGP routing daemon
+BindTo=zebra.service
+After=syslog.target network.target zebra.service
+ConditionPathExists=/etc/quagga/bgpd.conf
+
+[Service]
+Type=forking
+EnvironmentFile=/etc/sysconfig/quagga
+ExecStart=/usr/sbin/bgpd -d $BGPD_OPTS -f /etc/quagga/bgpd.conf
+Restart=on-abort
+
+[Install]
+WantedBy=network.target
diff --git a/redhat/isisd.service b/redhat/isisd.service
new file mode 100644
index 0000000..4cdf67d
--- /dev/null
+++ b/redhat/isisd.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=IS-IS routing daemon
+BindTo=zebra.service
+After=syslog.target network.target zebra.service
+ConditionPathExists=/etc/quagga/isisd.conf
+
+[Service]
+Type=forking
+EnvironmentFile=/etc/sysconfig/quagga
+ExecStart=/usr/sbin/isisd -d $ISISD_OPTS -f /etc/quagga/isisd.conf
+Restart=on-abort
+
+[Install]
+WantedBy=network.target
diff --git a/redhat/ospf6d.service b/redhat/ospf6d.service
new file mode 100644
index 0000000..3c9c466
--- /dev/null
+++ b/redhat/ospf6d.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=OSPF routing daemon for IPv6
+BindTo=zebra.service
+After=syslog.target network.target zebra.service
+ConditionPathExists=/etc/quagga/ospf6d.conf
+
+[Service]
+Type=forking
+EnvironmentFile=/etc/sysconfig/quagga
+ExecStart=/usr/sbin/ospf6d -d $OSPF6D_OPTS -f /etc/quagga/ospf6d.conf
+Restart=on-abort
+
+[Install]
+WantedBy=network.target
diff --git a/redhat/ospfd.service b/redhat/ospfd.service
new file mode 100644
index 0000000..5e3de23
--- /dev/null
+++ b/redhat/ospfd.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=OSPF routing daemon
+BindTo=zebra.service
+After=syslog.target network.target zebra.service
+ConditionPathExists=/etc/quagga/ospfd.conf
+
+[Service]
+Type=forking
+EnvironmentFile=/etc/sysconfig/quagga
+ExecStart=/usr/sbin/ospfd -d $OSPFD_OPTS -f /etc/quagga/ospfd.conf
+Restart=on-abort
+
+[Install]
+WantedBy=network.target
diff --git a/redhat/quagga.sysconfig b/redhat/quagga.sysconfig
index 2befc0f..4d6ec5a 100644
--- a/redhat/quagga.sysconfig
+++ b/redhat/quagga.sysconfig
@@ -10,7 +10,12 @@
 RIPNGD_OPTS="-A ::1"
 ZEBRA_OPTS="-A 127.0.0.1"
 
-# Watchquagga configuration
+# Watchquagga configuration for LSB initscripts
+#
+# (Not needed with systemd: the service files are configured to automatically
+# restart any daemon on failure. If zebra fails, all running daemons will be
+# stopped; zebra will be started again; and then the previously running daemons
+# will be started again.)
 #
 # Uncomment and edit this line to reflect the daemons you are actually using:
 #WATCH_DAEMONS="zebra bgpd ospfd ospf6d ripd ripngd"
diff --git a/redhat/ripd.service b/redhat/ripd.service
new file mode 100644
index 0000000..d35dc47
--- /dev/null
+++ b/redhat/ripd.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=RIP routing daemon
+BindTo=zebra.service
+After=syslog.target network.target zebra.service
+ConditionPathExists=/etc/quagga/ripd.conf
+
+[Service]
+Type=forking
+EnvironmentFile=/etc/sysconfig/quagga
+ExecStart=/usr/sbin/ripd -d $RIPD_OPTS -f /etc/quagga/ripd.conf
+Restart=on-abort
+
+[Install]
+WantedBy=network.target
diff --git a/redhat/ripngd.service b/redhat/ripngd.service
new file mode 100644
index 0000000..567e888
--- /dev/null
+++ b/redhat/ripngd.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=RIP routing daemon for IPv6
+BindTo=zebra.service
+After=syslog.target network.target zebra.service
+ConditionPathExists=/etc/quagga/ripngd.conf
+
+[Service]
+Type=forking
+EnvironmentFile=/etc/sysconfig/quagga
+ExecStart=/usr/sbin/ripngd -d $RIPNGD_OPTS -f /etc/quagga/ripngd.conf
+Restart=on-abort
+
+[Install]
+WantedBy=network.target
diff --git a/redhat/zebra.service b/redhat/zebra.service
new file mode 100644
index 0000000..27c3a52
--- /dev/null
+++ b/redhat/zebra.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=GNU Zebra routing manager
+After=syslog.target network.target
+ConditionPathExists=/etc/quagga/zebra.conf
+
+[Service]
+Type=forking
+EnvironmentFile=-/etc/sysconfig/quagga
+ExecStartPre=/sbin/ip route flush proto zebra
+ExecStart=/usr/sbin/zebra -d $ZEBRA_OPTS -f /etc/quagga/zebra.conf
+Restart=on-abort
+
+[Install]
+WantedBy=network.target