From 87236af75c954efc6eceab8c956a666b87a43edc Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Mon, 27 Mar 2017 15:45:48 -0400 Subject: [PATCH] Have simple-init enable network.service When a glean is running on centos with multiple NICs, it will try to systemctl enable network.service multiple times for each interface. Because of systemd magic, it is possible for the systemctl command to fail in a race condition. glean shouldn't be enabling network.service during boot in pre-networking phases (Ib2b618dd975ca44e9c6b0a2c9027642ffc46b9b0). I have proposed I8319f1ed6498a9d447950c2b4b34bca59e7b97e4 to remove this and document the behaviour. This also bring across suse's version (I20bffabd333ea290d8712ec2a467f2b2d5678f3a) Change-Id: I89d9443cb61e287bd0d9da3f48315272218ee335 Signed-off-by: Paul Belanger --- .../elements/simple-init/element-deps | 1 + .../simple-init/post-install.d/80-simple-init | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 diskimage_builder/elements/simple-init/post-install.d/80-simple-init diff --git a/diskimage_builder/elements/simple-init/element-deps b/diskimage_builder/elements/simple-init/element-deps index 5c7f9bb3..9d4a9f73 100644 --- a/diskimage_builder/elements/simple-init/element-deps +++ b/diskimage_builder/elements/simple-init/element-deps @@ -1,4 +1,5 @@ cloud-init-datasources +dib-init-system install-types pip-and-virtualenv runtime-ssh-host-keys diff --git a/diskimage_builder/elements/simple-init/post-install.d/80-simple-init b/diskimage_builder/elements/simple-init/post-install.d/80-simple-init new file mode 100755 index 00000000..898dd41b --- /dev/null +++ b/diskimage_builder/elements/simple-init/post-install.d/80-simple-init @@ -0,0 +1,37 @@ +#!/bin/bash + +if [ "${DIB_DEBUG_TRACE:-0}" -gt 0 ]; then + set -x +fi +set -eu +set -o pipefail + +case "$DIB_INIT_SYSTEM" in + upstart) + # nothing to do + exit 0 + ;; + systemd) + if [[ ${DISTRO_NAME} =~ (centos|rhel7|fedora) ]]; then + # NOTE(pabelanger): Glean requires network.service for + # these platforms. + systemctl enable network.service + elif [[ ${DISTRO_NAME} =~ (opensuse) ]]; then + # on suse, this is named wicked.service, but it's the same + # as network.service. + systemctl enable wicked.service + fi + ;; + openrc) + # let dib-init-system's postinstall handle enabling init scripts + exit 0 + ;; + sysv) + # nothing to do + exit 0 + ;; + *) + echo "Unsupported init system $DIB_INIT_SYSTEM" + exit 1 + ;; +esac