[dhcp-forwarder] added systemd initscripts and disabled generation of the old sysv ones

ensc ensc at fedoraproject.org
Tue Dec 14 22:44:06 UTC 2010


commit e1baecaf1a0fd29493302a62500e2da59913a123
Author: Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de>
Date:   Tue Dec 14 23:39:06 2010 +0100

    added systemd initscripts and disabled generation of the old sysv ones

 dhcp-forwarder.spec            |   90 ++++++++++++++++++++++++++++++++--------
 dhcp-forwarder.systemd.service |   12 +++++
 2 files changed, 85 insertions(+), 17 deletions(-)
---
diff --git a/dhcp-forwarder.spec b/dhcp-forwarder.spec
index 6a4584c..16d8b84 100644
--- a/dhcp-forwarder.spec
+++ b/dhcp-forwarder.spec
@@ -9,6 +9,9 @@
 %bcond_without		noarch
 %bcond_without		dietlibc
 %bcond_with		minit
+%bcond_with		sysv
+%bcond_without		systemd
+%bcond_without		upstart
 ##
 
 
@@ -19,6 +22,7 @@
 %global service		dhcp-fwd
 
 %{?with_noarch:%global noarch	BuildArch:	noarch}
+%{!?_unitdir:%global _unitdir /lib/systemd/system}
 %{!?release_func:%global release_func() %1%{?dist}}
 
 Summary:	DHCP relay agent
@@ -40,6 +44,7 @@ Provides:	group(%username) = 11
 
 %{?with_dietlibc:BuildRequires:	dietlibc}
 
+# Remove me after EOL of RHEL5
 %package sysvinit
 Summary:		SysV initscripts for dhcp-forwarder
 Group:			System Environment/Base
@@ -73,6 +78,22 @@ Requires(pre):		minit-setup
 Requires(postun):	minit-setup
 %{?noarch}
 
+%package systemd
+Summary:		Systemd initscripts for %name
+Group:			System Environment/Daemons
+Provides:		init(%name) = systemd
+Source20:		%name.systemd.service
+Requires(post):		/bin/systemctl
+Requires(preun):	/bin/systemctl
+Requires(postun):	/bin/systemctl
+%{?noarch}
+
+# Remove me after F17
+%if 0%{!?with_sysv:1}
+Provides:	%name-sysvinit = %version-%release
+Obsoletes:	%name-sysvinit < %version-%release
+%endif
+
 
 %description
 dhcp-fwd forwards DHCP messages between subnets with different sublayer
@@ -110,6 +131,14 @@ This package provides the scripts which can be used to start dhcp-forwarder
 with the minit initconcept.
 
 
+%description systemd
+dhcp-fwd forwards DHCP messages between subnets with different sublayer
+broadcast domains.
+
+This package provides the scripts which can be used to start dhcp-forwarder
+with the systemd initconcept.
+
+
 
 %prep
 %setup -q
@@ -129,8 +158,15 @@ rm -rf $RPM_BUILD_ROOT
 %__make DESTDIR=$RPM_BUILD_ROOT install install-contrib
 %__install -d  -m 0700 $RPM_BUILD_ROOT%homedir
 %__install -pD -m 0644 %SOURCE10 $RPM_BUILD_ROOT/etc/init/dhcp-forwarder.conf
+install -D -p -m 0644 %SOURCE20 $RPM_BUILD_ROOT%_unitdir/%name.service
 
 %{!?with_minit:rm -rf $RPM_BUILD_ROOT%minitsvcdir}
+touch $RPM_BUILD_ROOT%_var/run/dhcp-fwd.pid
+
+%{!?with_systemd: rm -rf $RPM_BUILD_ROOT%_unitdir}
+%{!?with_sysv:    rm -rf $RPM_BUILD_ROOT%_var/run/dhcp-fwd.pid}
+%{!?with_sysv:    rm -rf $RPM_BUILD_ROOT%_initrddir}
+%{!?with_sysv:    rm -rf $RPM_BUILD_ROOT%_sysconfdir/sysconfig/dhcp-fwd}
 
 
 %check
@@ -172,6 +208,18 @@ test "$1" = "0" || %_initrddir/%service condrestart &>/dev/null
 test "$1" != "0" || /sbin/initctl -q stop dhcp-forwarder || :
 
 
+%post systemd
+test "$1" -ne 1 || /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+
+%preun systemd
+test "$1" -ne 1 || /bin/systemctl disable %name.service > /dev/null 2>&1 || :
+test "$1" -ne 1 || /bin/systemctl stop    %name.service > /dev/null 2>&1 || :
+
+%postun systemd
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+test "$1" -eq 1 || /bin/systemctl try-restart %name.service >/dev/null 2>&1 || :
+
+
 %files
 %defattr(-,root,root,-)
 %doc AUTHORS COPYING ChangeLog NEWS README THANKS
@@ -185,26 +233,33 @@ test "$1" != "0" || /sbin/initctl -q stop dhcp-forwarder || :
 %homedir
 
 
-%files sysvinit
-%defattr(-,root,root,-)
-%config %_initrddir/*
-%config(noreplace) %_sysconfdir/sysconfig/*
-
-
-%files upstart
-%defattr(-,root,root,-)
-%config(noreplace) /etc/init/*
-
-
 %if 0%{?with_minit:1}
-
 %files minit
-%defattr(-,root,root,-)
-%dir %minitsvcdir
-%minitsvcdir/run
-%minitsvcdir/respawn
-%config(noreplace) %minitsvcdir/params
+  %defattr(-,root,root,-)
+  %dir %minitsvcdir
+  %minitsvcdir/run
+  %minitsvcdir/respawn
+  %config(noreplace) %minitsvcdir/params
+%endif
+
+%if 0%{?with_systemd:1}
+%files systemd
+  %defattr(-,root,root,-)
+  %_unitdir/%name.service
+%endif
 
+%if 0%{?with_sysv:1}
+%files sysvinit
+  %defattr(-,root,root,-)
+  %config %_initrddir/*
+  %config(noreplace) %_sysconfdir/sysconfig/*
+  %ghost %_var/run/dhcp-fwd.pid
+%endif
+
+%if 0%{?with_upstart:1}
+%files upstart
+  %defattr(-,root,root,-)
+  %config(noreplace) /etc/init/*
 %endif
 
 
@@ -212,6 +267,7 @@ test "$1" != "0" || /sbin/initctl -q stop dhcp-forwarder || :
 * Tue Dec 14 2010 Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de> - 0.9-1500
 - updated to 0.9
 - fixed source url and switched to .xz tarball
+- added systemd initscripts and disabled generation of the old sysv ones
 
 * Sun Dec  6 2009 Enrico Scholz <enrico.scholz at informatik.tu-chemnitz.de> - 0.8-1300
 - updated -upstart to upstart 0.6.3
diff --git a/dhcp-forwarder.systemd.service b/dhcp-forwarder.systemd.service
new file mode 100644
index 0000000..a2f174c
--- /dev/null
+++ b/dhcp-forwarder.systemd.service
@@ -0,0 +1,12 @@
+# --*- conf -*--
+[Unit]
+Description = Agent to relay DHCP messages between two networks
+After = syslog.target
+
+[Service]
+Type = simple
+ExecStart = /usr/sbin/dhcp-fwd -n -c /etc/dhcp-fwd.conf
+Restart = on-failure
+
+[Install]
+WantedBy = multi-user.target


More information about the scm-commits mailing list