openeuler: 修复未纠正网络配置文件的网卡名

This commit is contained in:
bin456789 2025-01-20 14:31:41 +08:00
parent 11035ffa63
commit 605b0b4a95
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
3 changed files with 9 additions and 7 deletions

View File

@ -116,7 +116,7 @@ certutil -urlcache -f -split https://jihulab.com/bin456789/reinstall/-/raw/main/
### Feature 1: Install <img width="16" height="16" src="https://www.kernel.org/theme/images/logos/favicon.png" /> Linux
- The username is `root` with a default password of `123@@@`. It may take a few minutes after the first boot to successfully log in.
- The username is `root` with a default password of `123@@@`.
- When installing the latest version, the version number does not need to be specified.
- Maximizes disk space usage: no boot partition (except for Fedora) and no swap partition.
- Automatically selects different optimized kernels based on machine type, such as `Cloud` or `HWE` kernels.

View File

@ -116,7 +116,7 @@ certutil -urlcache -f -split https://jihulab.com/bin456789/reinstall/-/raw/main/
### 功能 1: 安装 <img width="16" height="16" src="https://www.kernel.org/theme/images/logos/favicon.png" /> Linux
- 用户名 `root` 默认密码 `123@@@`,首次开机可能要等几分钟才能成功登录
- 用户名 `root` 默认密码 `123@@@`
- 安装最新版可不输入版本号
- 最大化利用磁盘空间:不含 boot 分区Fedora 例外),不含 swap 分区
- 自动根据机器类型选择不同的优化内核,例如 `Cloud``HWE` 内核

View File

@ -5,6 +5,9 @@
set -eE
# openeuler 需等待 udev 将网卡名从 eth0 改为 enp3s0
sleep 10
# 本脚本在首次进入新系统后运行
# 将 trans 阶段生成的网络配置中的网卡名(eth0) 改为正确的网卡名,也适用于以下情况
# 1. alpine 要运行此脚本,因为安装后的内核可能有 netboot 没有的驱动
@ -19,8 +22,7 @@ to_lower() {
retry() {
local max_try=$1
local interval=$2
shift 2
shift
for i in $(seq "$max_try"); do
if "$@"; then
@ -30,7 +32,7 @@ retry() {
if [ "$i" -ge "$max_try" ]; then
return $ret
fi
sleep "$interval"
sleep 1
fi
done
}
@ -40,7 +42,7 @@ retry() {
# 因此需要等待网卡出现
get_ethx_by_mac() {
mac=$(echo "$1" | to_lower)
retry 10 0.5 _get_ethx_by_mac "$mac"
retry 10 _get_ethx_by_mac "$mac"
}
_get_ethx_by_mac() {
@ -218,7 +220,7 @@ fix_netplan() {
fix_systemd_networkd() {
for file in /etc/systemd/network/10-cloud-init-eth*.network; do
[ -f "$file" ] || continue
mac=$(grep ^MACAddress= $file | cut -d= -f2 | grep .) || continue
mac=$(grep ^MACAddress= "$file" | cut -d= -f2 | grep .) || continue
ethx=$(get_ethx_by_mac "$mac") || continue
proper_file=/etc/systemd/network/10-$ethx.network