Skip to content

Commit

Permalink
WIP: Run NM via systemd unit, don't depend on ip=dhcp kargs
Browse files Browse the repository at this point in the history
See https://github.com/coreos/ignition-dracut/issues/94
and coreos/ignition#948

Needs pairing with a cosa PR to drop the default `ip=dhcp` kargs.

And yes we really want to upstream this into NM by default or so.
  • Loading branch information
cgwalters committed Mar 26, 2020
1 parent a7cb9e0 commit 230b0d7
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[Unit]
Description=Network Manager (CoreOS initrd)
Wants=network.target
After=network-pre.target dbus.service
Before=network.target network.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/libexec/nm-initrd-generator rd.neednet=1 ip=dhcp,dhcp6
ExecStart=/usr/sbin/NetworkManager --configure-and-quit=initrd --no-daemon
CapabilityBoundingSet=CAP_NET_ADMIN CAP_DAC_OVERRIDE CAP_NET_RAW CAP_NET_BIND_SERVICE CAP_SETGID CAP_SETUID CAP_SYS_MODULE CAP_AUDIT_WRITE CAP_KILL CAP_SYS_CHROOT
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh

depends() {
echo ignition network-manager
}

install_and_enable_unit() {
unit="$1"; shift
target="$1"; shift
inst_simple "$moddir/$unit" "$systemdsystemunitdir/$unit"
mkdir -p "$initdir/$systemdsystemunitdir/$target.requires"
ln_r "../$unit" "$systemdsystemunitdir/$target.requires/$unit"
}

install() {
# We're forcibly overriding NM to be run as a service
install_and_enable_unit coreos-NetworkManager.service network-online.target
fetchd="$initdir/$systemdsystemunitdir/ignition-fetch.service.d/"
mkdir -p "${fetchd}"
cat >${fetchd}/nm-online.conf << EOF
[Unit]
After=network-online.target
Wants=network-online.target
EOF
}

0 comments on commit 230b0d7

Please sign in to comment.