mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-18 20:39:14 +08:00
core: 完善 tty
This commit is contained in:
parent
15de1ac098
commit
e2ca64a255
18
redhat.cfg
18
redhat.cfg
@ -46,22 +46,8 @@ done
|
||||
|
||||
# 设置 tty
|
||||
include=/tmp/include-bootloader
|
||||
str=
|
||||
for tty in tty0 ttyS0 ttyAMA0; do
|
||||
dev_tty=/dev/$tty
|
||||
if [ -e $dev_tty ] && echo >$dev_tty 2>/dev/null; then
|
||||
if [ -z "$str" ]; then
|
||||
str="console=$tty"
|
||||
else
|
||||
str="$str console=$tty"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
if [ -n "$str" ]; then
|
||||
echo "bootloader --append=\"$str\"" >$include
|
||||
else
|
||||
echo "bootloader" >$include
|
||||
fi
|
||||
console_cmdline=$(wget $confhome/ttys.sh -O- | sh -s console=)
|
||||
echo "bootloader --append=\"$console_cmdline\"" >$include
|
||||
|
||||
# 有 installer 分区,表示用了两步安装
|
||||
include=/tmp/include-packages-for-resize
|
||||
|
12
reinstall.sh
12
reinstall.sh
@ -882,6 +882,16 @@ build_extra_cmdline() {
|
||||
fi
|
||||
}
|
||||
|
||||
echo_tmp_ttys() {
|
||||
# 由于 windows 下无法测试各tty是否有效
|
||||
# 这里的 tty 只临时使用,非最终系统的 tty
|
||||
if is_in_windows; then
|
||||
echo "console=ttyS0,115200n8 console=tty0"
|
||||
else
|
||||
curl -L $confhome/ttys.sh | sh -s "console="
|
||||
fi
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
build_cmdline() {
|
||||
if [ -n "$finalos_cmdline" ]; then
|
||||
@ -1064,7 +1074,7 @@ menuentry "reinstall" {
|
||||
insmod lvm
|
||||
insmod xfs
|
||||
search --no-floppy --file --set=root /reinstall-vmlinuz
|
||||
linux$efi /reinstall-vmlinuz $cmdline
|
||||
linux$efi /reinstall-vmlinuz $(echo_tmp_ttys) $cmdline
|
||||
initrd$efi /reinstall-initrd
|
||||
}
|
||||
EOF
|
||||
|
24
trans.sh
24
trans.sh
@ -141,20 +141,12 @@ setup_lighttpd() {
|
||||
rc-service lighttpd start
|
||||
}
|
||||
|
||||
# 最后一个 tty 是主tty,显示的信息最多
|
||||
# 有些平台例如 aws/gcp 只能截图,不能输入(没有鼠标)
|
||||
# 所以如果有显示器且有鼠标,tty0 放最后面,否则 tty0 放前面
|
||||
get_ttys() {
|
||||
prefix=$1
|
||||
str=
|
||||
for tty in tty0 ttyS0 ttyAMA0; do
|
||||
dev_tty=/dev/$tty
|
||||
if [ -e $dev_tty ] && echo >$dev_tty 2>/dev/null; then
|
||||
if [ -z "$str" ]; then
|
||||
str="$prefix$tty"
|
||||
else
|
||||
str="$str $prefix$tty"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo $str
|
||||
wget $confhome/ttys.sh -O- | sh -s $prefix
|
||||
}
|
||||
|
||||
setup_tty_and_log() {
|
||||
@ -390,9 +382,9 @@ EOF
|
||||
|
||||
# 如果是 vm 就用 virt 内核
|
||||
if is_virt; then
|
||||
kernel_opt="-k virt"
|
||||
kernel_flavor="virt"
|
||||
else
|
||||
kernel_opt="-k lts"
|
||||
kernel_flavor="lts"
|
||||
fi
|
||||
|
||||
# 重置为官方仓库配置
|
||||
@ -405,8 +397,10 @@ EOF
|
||||
|
||||
# 安装到硬盘
|
||||
# alpine默认使用 syslinux (efi 环境除外),这里强制使用 grub,方便用脚本再次重装
|
||||
KERNELOPTS="$(get_ttys console=)"
|
||||
export KERNELOPTS
|
||||
export BOOTLOADER="grub"
|
||||
printf 'y' | setup-disk -m sys $kernel_opt -s 0 /dev/$xda
|
||||
printf 'y' | setup-disk -m sys -k $kernel_flavor -s 0 /dev/$xda
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
|
32
ttys.sh
32
ttys.sh
@ -1,13 +1,29 @@
|
||||
#!/bin/sh
|
||||
prefix=$1
|
||||
for tty in tty0 ttyS0 ttyAMA0; do
|
||||
dev_tty=/dev/$tty
|
||||
if [ -e $dev_tty ] && echo >$dev_tty 2>/dev/null; then
|
||||
if [ -z "$str" ]; then
|
||||
str="$prefix$tty"
|
||||
else
|
||||
str="$str $prefix$tty"
|
||||
|
||||
# 最后一个 tty 是主 tty,显示的信息最全
|
||||
# 有些平台例如 aws/gcp 后台vnc只能截图,不能输入,用有没有鼠标判断
|
||||
# 因此如果有显示器且有鼠标,tty0 放最后面,否则 tty0 放前面
|
||||
ttys="ttyS0 ttyAMA0"
|
||||
if [ -e /dev/fb0 ] && [ -e /dev/input/mouse0 ]; then
|
||||
ttys="$ttys tty0"
|
||||
else
|
||||
ttys="tty0 $ttys"
|
||||
fi
|
||||
|
||||
is_first=true
|
||||
for tty in $ttys; do
|
||||
if [ -e /dev/$tty ] && echo >/dev/$tty 2>/dev/null; then
|
||||
if ! $is_first; then
|
||||
printf " "
|
||||
fi
|
||||
|
||||
is_first=false
|
||||
|
||||
printf "%s" "$prefix$tty"
|
||||
|
||||
if [ "$prefix" = "console=" ] && [ "$tty" = ttyS0 ]; then
|
||||
printf ",115200n8"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo $str
|
||||
|
Loading…
x
Reference in New Issue
Block a user