alpine: 临时修复 liveos getty 运行在 tty0

This commit is contained in:
bin456789
2026-09-23 21:45:04 +08:00
parent 9e8f65f2e5
commit 808e13bc1b
2 changed files with 18 additions and 14 deletions
+14
View File
@@ -368,6 +368,10 @@ insert_into_file() {
case "$location" in case "$location" in
before) line_num=$((line_num - 1)) ;; before) line_num=$((line_num - 1)) ;;
replace)
sed -i "${line_num}d" "$file"
line_num=$((line_num - 1))
;;
after) ;; after) ;;
*) return 1 ;; *) return 1 ;;
esac esac
@@ -4351,6 +4355,16 @@ EOF
insert_into_file init before '^exec (/bin/busybox )?switch_root' <<EOF insert_into_file init before '^exec (/bin/busybox )?switch_root' <<EOF
cp /can_use_cloud_kernel.sh \$sysroot/ cp /can_use_cloud_kernel.sh \$sysroot/
chmod a+x \$sysroot/can_use_cloud_kernel.sh chmod a+x \$sysroot/can_use_cloud_kernel.sh
EOF
fi
# 临时修复 liveos getty 运行在 tty0
# shellcheck disable=SC2016
if [ "$nextos_releasever" = 3.24 ] &&
txt_to_grep='done < "$ROOT"/sys/class/tty/"$1"/active' &&
grep -qF "$txt_to_grep" init; then
insert_into_file init replace "$txt_to_grep" -F <<EOF
done < <(cat "\$ROOT"/sys/class/tty/"\$1"/active | xargs -n 1)
EOF EOF
fi fi
} }
+4 -14
View File
@@ -1163,6 +1163,10 @@ insert_into_file() {
case "$location" in case "$location" in
before) line_num=$((line_num - 1)) ;; before) line_num=$((line_num - 1)) ;;
replace)
sed -i "${line_num}d" "$file"
line_num=$((line_num - 1))
;;
after) ;; after) ;;
*) return 1 ;; *) return 1 ;;
esac esac
@@ -1711,20 +1715,6 @@ install_alpine() {
set_ssh_keys_and_del_password /os set_ssh_keys_and_del_password /os
fi fi
# alpine 3.24+
# 要从 /etc/inittab 删除多余的 tty0
# 否则开机时 vnc 会有两个登录提示,一个是 tty0,一个是 tty1
# sed 找到 # enable login on alternative console 的行
# 用 N 读取下一行到当前空间
# 再匹配 \ntty0:
sed -i '
/^# enable login on alternative console$/{
N
/\ntty0:/d
}
' /os/etc/inittab
# 下载 fix-eth-name # 下载 fix-eth-name
download "$confhome/fix-eth-name.sh" /os/fix-eth-name.sh download "$confhome/fix-eth-name.sh" /os/fix-eth-name.sh
download "$confhome/fix-eth-name.initd" /os/etc/init.d/fix-eth-name download "$confhome/fix-eth-name.initd" /os/etc/init.d/fix-eth-name