-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
overlay: add 40coreos-network dracut module
Add coreos-teardown-initramfs-network.service to run after ignition has finished using initramfs networking, so NetworkManager properly brings up ignition-configured networking in the real root. Otherwise the initramfs network persists into the real root. Signed-off-by: Yu Qi Zhang <[email protected]>
- Loading branch information
1 parent
9e94fca
commit 479b58d
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
overlay/usr/lib/dracut/modules.d/40coreos-network/coreos-teardown-initramfs-network.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Clean up the initramfs networking on first boot | ||
# so the real network is being brought up | ||
|
||
[Unit] | ||
Description=Tear down initramfs networking | ||
DefaultDependencies=false | ||
After=ignition-files.service | ||
|
||
# Make sure ExecStop= runs before we switch root | ||
Conflicts=initrd-switch-root.target umount.target | ||
Before=initrd-switch-root.target | ||
|
||
# Make sure if ExecStart= fails, the boot fails | ||
OnFailure=emergency.target | ||
OnFailureJobMode=isolate | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStop=/usr/sbin/coreos-teardown-initramfs-network |
13 changes: 13 additions & 0 deletions
13
overlay/usr/lib/dracut/modules.d/40coreos-network/coreos-teardown-initramfs-network.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
# Clean up the interfaces set up in the initramfs | ||
# This mimics the behaviour of dracut's ifdown() in net-lib.sh | ||
if ! [ -z "$(ls /sys/class/net)" ]; then | ||
for f in /sys/class/net/*; do | ||
interface=$(basename "$f") | ||
ip link set $interface down | ||
ip addr flush dev $interface | ||
rm -f -- /tmp/net.$interface.did-setup | ||
done | ||
fi |
14 changes: 14 additions & 0 deletions
14
overlay/usr/lib/dracut/modules.d/40coreos-network/module-setup.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- | ||
# ex: ts=8 sw=4 sts=4 et filetype=sh | ||
|
||
check() { | ||
return 0 | ||
} | ||
|
||
install() { | ||
local unit=coreos-teardown-initramfs-network.service | ||
inst_simple "$moddir/$unit" "$systemdsystemunitdir/$unit" | ||
inst_script "$moddir/coreos-teardown-initramfs-network.sh" \ | ||
"/usr/sbin/coreos-teardown-initramfs-network" | ||
} |