From d5225055ef2403b461083f5d76c67bc8410539a7 Mon Sep 17 00:00:00 2001
From: Derek Higgins <derekh@redhat.com>
Date: Wed, 2 Nov 2016 11:01:15 +0000
Subject: [PATCH] dhcp-all-interfaces: support Centos/RHEL 6

On Centos and RHEL 6 the init system is upsart but but networking is using
sysv compatabiliy and a code path the handle this situation.

We can't use DISTRO_NAME because the centos-minimal element sets it to
centos for CentOS 7 but the centos element sets it to centos for CentOS 6.

Change-Id: Ib8e33ed78b3d6a5737eb7449bccef2d33f72b131
Closes-Bug: #1638527
---
 .../dhcp-all-interfaces/install.d/50-dhcp-all-interfaces  | 8 +++++++-
 .../install.d/dhcp-all-interfaces.init                    | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces b/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces
index f17b23a7a..24c109ebd 100755
--- a/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces
+++ b/elements/dhcp-all-interfaces/install.d/50-dhcp-all-interfaces
@@ -15,7 +15,13 @@ fi
 
 DIB_INIT_SYSTEM=$(dib-init-system)
 if [ "$DIB_INIT_SYSTEM" == "upstart" ]; then
-    install -D -g root -o root -m 0755 ${SCRIPTDIR}/dhcp-all-interfaces.conf /etc/init/dhcp-all-interfaces.conf
+    if [ -e "/etc/redhat-release" ] ; then
+        # the init system is upstart but networking is using sysv compatabiliy (i.e. Centos/RHEL 6)
+        install -D -g root -o root -m 0755 ${SCRIPTDIR}/dhcp-all-interfaces.init /etc/init.d/dhcp-all-interfaces
+        chkconfig dhcp-all-interfaces on
+    else
+        install -D -g root -o root -m 0755 ${SCRIPTDIR}/dhcp-all-interfaces.conf /etc/init/dhcp-all-interfaces.conf
+    fi
 elif [ "$DIB_INIT_SYSTEM" == "systemd" ]; then
     install -D -g root -o root -m 0755 ${SCRIPTDIR}/dhcp-interface@.service /usr/lib/systemd/system/dhcp-interface@.service
     install -D -g root -o root -m 0644 ${SCRIPTDIR}/dhcp-all-interfaces-udev.rules /etc/udev/rules.d/99-dhcp-all-interfaces.rules
diff --git a/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.init b/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.init
index 8023e154b..89fb79197 100755
--- a/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.init
+++ b/elements/dhcp-all-interfaces/install.d/dhcp-all-interfaces.init
@@ -6,6 +6,7 @@
 # Default-Start:     S
 # Default-Stop:      0 6
 # X-Start-Before:    networking
+# chkconfig:         3 9 50
 # Short-Description: Autodetect network interfaces
 # Description:       Autodetect network interfaces during boot and configure them for DHCP
 ### END INIT INFO