[dhcp/f18] convert DHC*ARGS from /etc/sysconfig/dhc* to service unit

Jiří Popelka jpopelka at fedoraproject.org
Thu Jan 17 16:46:15 UTC 2013


commit dd392244183abcf5181df301597b0d988b02609c
Author: Jiri Popelka <jpopelka at redhat.com>
Date:   Thu Jan 17 17:45:01 2013 +0100

    convert DHC*ARGS from /etc/sysconfig/dhc* to service unit

 dhcp.spec |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)
---
diff --git a/dhcp.spec b/dhcp.spec
index 6ca0913..e6ce6df 100644
--- a/dhcp.spec
+++ b/dhcp.spec
@@ -18,7 +18,7 @@
 Summary:  Dynamic host configuration protocol software
 Name:     dhcp
 Version:  4.2.5
-Release:  1%{?dist}
+Release:  2%{?dist}
 # NEVER CHANGE THE EPOCH on this package.  The previous maintainer (prior to
 # dcantrell maintaining the package) made incorrect use of the epoch and
 # that's why it is at 12 now.  It should have never been used, but it was.
@@ -490,6 +490,28 @@ fi
 
 %postun libs -p /sbin/ldconfig
 
+%triggerun -- dhcp < 12:4.2.4-14.P1
+# convert DHC*ARGS from /etc/sysconfig/dhc* to /etc/systemd/system/dhc*.service
+for servicename in dhcpd dhcpd6 dhcrelay; do
+  if [ -f %{dhcpconfdir}/sysconfig/${servicename} ]; then
+    if [ "${servicename}" == "dhcrelay" ]; then
+        key="DHCRELAYARGS"
+    else
+        key="DHCPDARGS"
+    fi
+    # get the value of $key from /etc/sysconfig/$servicename
+    args=$(grep $key %{dhcpconfdir}/sysconfig/${servicename} | sed -r "s/${key}=\"?([^\"]*)\"?/\1/")
+    # value is non-empty (i.e. user modified) and there isn't a service unit yet
+    if [ -n "${args}" -a ! -f %{dhcpconfdir}/systemd/system/${servicename}.service ]; then
+      # in $args replace / with \/ otherwise the next sed won't take it
+      args=$(echo $args | sed 's/\//\\\//'g)
+      # add $args to the end of ExecStart line
+      sed -r -e "s/(ExecStart=[^$]*)/\1 ${args}/" \
+                < %{_unitdir}/${servicename}.service \
+                > %{dhcpconfdir}/systemd/system/${servicename}.service
+    fi
+  fi
+done
 
 %files
 %doc server/dhcpd.conf.example server/dhcpd6.conf.example
@@ -555,6 +577,11 @@ fi
 
 
 %changelog
+* Thu Jan 17 2013 Jiri Popelka <jpopelka at redhat.com> - 12:4.2.5-2
+- during update convert DHC*ARGS from /etc/sysconfig/dhc*
+  to /etc/systemd/system/dhc*.service (#895475)
+- 12-dhcpd NM dispatcher script now restarts also dhcpd6 service
+
 * Thu Jan 10 2013 Jiri Popelka <jpopelka at redhat.com> - 12:4.2.5-1
 - 4.2.5
 


More information about the scm-commits mailing list