Skip to content
This repository has been archived by the owner on Aug 25, 2021. It is now read-only.

30ignition: remove initramfs networking #78

Merged
merged 1 commit into from
May 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions dracut/30ignition/coreos-teardown-initramfs-network.service
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
16 changes: 16 additions & 0 deletions dracut/30ignition/coreos-teardown-initramfs-network.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh

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
1 change: 1 addition & 0 deletions dracut/30ignition/ignition-generator
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ if $(cmdline_bool 'ignition.firstboot' 0); then
add_requires ignition-disks.service
add_requires ignition-files.service
add_requires ignition-ask-var-mount.service
add_requires coreos-teardown-initramfs-network.service
#if [[ $(cmdline_arg coreos.oem.id) == "packet" ]]; then
# add_requires coreos-static-network.service
#fi
Expand Down
6 changes: 6 additions & 0 deletions dracut/30ignition/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ install() {
inst_script "$moddir/ignition-setup.sh" \
"/usr/sbin/ignition-setup"

inst_script "$moddir/coreos-teardown-initramfs-network.sh" \
"/usr/sbin/coreos-teardown-initramfs-network"

# inst_script "$moddir/retry-umount.sh" \
# "/usr/sbin/retry-umount"

Expand All @@ -51,6 +54,9 @@ install() {
inst_simple "$moddir/ignition-remount-sysroot.service" \
"$systemdutildir/system/ignition-remount-sysroot.service"

inst_simple "$moddir/coreos-teardown-initramfs-network.service" \
"$systemdutildir/system/coreos-teardown-initramfs-network.service"

# inst_simple "$moddir/sysroot-boot.service" \
# "$systemdsystemunitdir/sysroot-boot.service"

Expand Down