mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-19 21:41:05 +02:00
networkd: Emulate old kernel naming
The old kernel names are handed out by netname.sh which is called by 79-netname.rules. rename-network-interfaces.service does the rename by stopping networkd, taking down the interfaces, re-adding the interfaces, and then restarting networkd.
This commit is contained in:
parent
2708fd70a0
commit
2a2ff85a46
@ -1,5 +1,19 @@
|
|||||||
#cloud-config
|
#cloud-config
|
||||||
|
|
||||||
|
write_files:
|
||||||
|
- path: /run/udev/rules.d/79-netname.rules
|
||||||
|
permissions: 444
|
||||||
|
content: |
|
||||||
|
SUBSYSTEM!="net", GOTO="netname_end"
|
||||||
|
ACTION!="add", GOTO="netname_end"
|
||||||
|
ENV{ID_BUS}!="pci", GOTO="netname_end"
|
||||||
|
|
||||||
|
IMPORT{program}="/usr/share/oem/bin/netname.sh $env{IFINDEX}"
|
||||||
|
|
||||||
|
NAME=="", ENV{ID_NET_NAME_SIMPLE}!="", NAME="$env{ID_NET_NAME_SIMPLE}"
|
||||||
|
|
||||||
|
LABEL="netname_end"
|
||||||
|
|
||||||
coreos:
|
coreos:
|
||||||
units:
|
units:
|
||||||
- name: user-configdrive.service.d/netconf.conf
|
- name: user-configdrive.service.d/netconf.conf
|
||||||
@ -22,6 +36,20 @@ coreos:
|
|||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=user-config.target
|
WantedBy=user-config.target
|
||||||
|
- name: rename-network-interfaces.service
|
||||||
|
command: start
|
||||||
|
runtime: yes
|
||||||
|
content: |
|
||||||
|
[Unit]
|
||||||
|
Before=user-config.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=oneshot
|
||||||
|
RemainAfterExit=yes
|
||||||
|
ExecStart=/usr/bin/systemctl stop systemd-networkd
|
||||||
|
ExecStart=/usr/bin/bash -c "for dev in $(ip link show | gawk -F ':' '/^[0-9]+/ { print $2 }' | tr -d ' ' | sed 's/lo//'); do ip link set $dev down; done"
|
||||||
|
ExecStart=/usr/bin/bash -c "udevadm test /sys/class/net/*"
|
||||||
|
ExecStart=/usr/bin/systemctl start systemd-networkd
|
||||||
- name: media-configdrive.mount
|
- name: media-configdrive.mount
|
||||||
command: start
|
command: start
|
||||||
runtime: yes
|
runtime: yes
|
||||||
|
@ -0,0 +1,4 @@
|
|||||||
|
#! /bin/bash
|
||||||
|
|
||||||
|
IFINDEX=$1
|
||||||
|
echo "ID_NET_NAME_SIMPLE=eth$((${IFINDEX} - 2))"
|
@ -15,6 +15,9 @@ KEYWORDS="amd64 x86"
|
|||||||
S="${WORKDIR}"
|
S="${WORKDIR}"
|
||||||
|
|
||||||
src_install() {
|
src_install() {
|
||||||
|
into "/usr/share/oem"
|
||||||
|
dobin ${FILESDIR}/netname.sh
|
||||||
|
|
||||||
insinto "/usr/share/oem"
|
insinto "/usr/share/oem"
|
||||||
doins ${FILESDIR}/cloud-config.yml
|
doins ${FILESDIR}/cloud-config.yml
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user