core: 修复新系统没有 /usr/lib/systemd/system-preset 文件夹时报错

This commit is contained in:
bin456789 2025-03-05 22:34:59 +08:00
parent 8b60b7d2df
commit efb1614b6b
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
2 changed files with 8 additions and 1 deletions

View File

@ -22,6 +22,7 @@ ExecStart=/usr/bin/env bash /fix-eth-name.sh
ExecStart=/usr/bin/env rm -f /fix-eth-name.sh
ExecStart=/usr/bin/env rm -f /etc/systemd/system/fix-eth-name.service
ExecStart=/usr/bin/env rm -f /etc/systemd/system/multi-user.target.wants/fix-eth-name.service
ExecStart=/usr/bin/env rm -f /lib/systemd/system-preset/01-fix-eth-name.preset
ExecStart=/usr/bin/env rm -f /usr/lib/systemd/system-preset/01-fix-eth-name.preset
[Install]

View File

@ -1681,7 +1681,13 @@ add_fix_eth_name_systemd_service() {
# 因此需要设置 fix-eth-name 的 preset 状态
# 不然首次开机 /etc/systemd/system/multi-user.target.wants/fix-eth-name.service 会被删除
# 通常 /etc/systemd/system-preset/ 文件夹要新建,因此不放在这里
echo 'enable fix-eth-name.service' >"$os_dir/usr/lib/systemd/system-preset/01-fix-eth-name.preset"
# 可能是 /usr/lib/systemd/system-preset/ 或者 /lib/systemd/system-preset/
if [ -d "$os_dir/usr/lib/systemd/system-preset" ]; then
echo 'enable fix-eth-name.service' >"$os_dir/usr/lib/systemd/system-preset/01-fix-eth-name.preset"
else
echo 'enable fix-eth-name.service' >"$os_dir/lib/systemd/system-preset/01-fix-eth-name.preset"
fi
}
basic_init() {