mirror of
https://github.com/bin456789/reinstall.git
synced 2025-01-19 04:49:13 +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
|
# 设置 tty
|
||||||
include=/tmp/include-bootloader
|
include=/tmp/include-bootloader
|
||||||
str=
|
console_cmdline=$(wget $confhome/ttys.sh -O- | sh -s console=)
|
||||||
for tty in tty0 ttyS0 ttyAMA0; do
|
echo "bootloader --append=\"$console_cmdline\"" >$include
|
||||||
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
|
|
||||||
|
|
||||||
# 有 installer 分区,表示用了两步安装
|
# 有 installer 分区,表示用了两步安装
|
||||||
include=/tmp/include-packages-for-resize
|
include=/tmp/include-packages-for-resize
|
||||||
|
12
reinstall.sh
12
reinstall.sh
@ -882,6 +882,16 @@ build_extra_cmdline() {
|
|||||||
fi
|
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
|
# shellcheck disable=SC2154
|
||||||
build_cmdline() {
|
build_cmdline() {
|
||||||
if [ -n "$finalos_cmdline" ]; then
|
if [ -n "$finalos_cmdline" ]; then
|
||||||
@ -1064,7 +1074,7 @@ menuentry "reinstall" {
|
|||||||
insmod lvm
|
insmod lvm
|
||||||
insmod xfs
|
insmod xfs
|
||||||
search --no-floppy --file --set=root /reinstall-vmlinuz
|
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
|
initrd$efi /reinstall-initrd
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
24
trans.sh
24
trans.sh
@ -141,20 +141,12 @@ setup_lighttpd() {
|
|||||||
rc-service lighttpd start
|
rc-service lighttpd start
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 最后一个 tty 是主tty,显示的信息最多
|
||||||
|
# 有些平台例如 aws/gcp 只能截图,不能输入(没有鼠标)
|
||||||
|
# 所以如果有显示器且有鼠标,tty0 放最后面,否则 tty0 放前面
|
||||||
get_ttys() {
|
get_ttys() {
|
||||||
prefix=$1
|
prefix=$1
|
||||||
str=
|
wget $confhome/ttys.sh -O- | sh -s $prefix
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setup_tty_and_log() {
|
setup_tty_and_log() {
|
||||||
@ -390,9 +382,9 @@ EOF
|
|||||||
|
|
||||||
# 如果是 vm 就用 virt 内核
|
# 如果是 vm 就用 virt 内核
|
||||||
if is_virt; then
|
if is_virt; then
|
||||||
kernel_opt="-k virt"
|
kernel_flavor="virt"
|
||||||
else
|
else
|
||||||
kernel_opt="-k lts"
|
kernel_flavor="lts"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# 重置为官方仓库配置
|
# 重置为官方仓库配置
|
||||||
@ -405,8 +397,10 @@ EOF
|
|||||||
|
|
||||||
# 安装到硬盘
|
# 安装到硬盘
|
||||||
# alpine默认使用 syslinux (efi 环境除外),这里强制使用 grub,方便用脚本再次重装
|
# alpine默认使用 syslinux (efi 环境除外),这里强制使用 grub,方便用脚本再次重装
|
||||||
|
KERNELOPTS="$(get_ttys console=)"
|
||||||
|
export KERNELOPTS
|
||||||
export BOOTLOADER="grub"
|
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
|
# shellcheck disable=SC2154
|
||||||
|
30
ttys.sh
30
ttys.sh
@ -1,13 +1,29 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
prefix=$1
|
prefix=$1
|
||||||
for tty in tty0 ttyS0 ttyAMA0; do
|
|
||||||
dev_tty=/dev/$tty
|
# 最后一个 tty 是主 tty,显示的信息最全
|
||||||
if [ -e $dev_tty ] && echo >$dev_tty 2>/dev/null; then
|
# 有些平台例如 aws/gcp 后台vnc只能截图,不能输入,用有没有鼠标判断
|
||||||
if [ -z "$str" ]; then
|
# 因此如果有显示器且有鼠标,tty0 放最后面,否则 tty0 放前面
|
||||||
str="$prefix$tty"
|
ttys="ttyS0 ttyAMA0"
|
||||||
|
if [ -e /dev/fb0 ] && [ -e /dev/input/mouse0 ]; then
|
||||||
|
ttys="$ttys tty0"
|
||||||
else
|
else
|
||||||
str="$str $prefix$tty"
|
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
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo $str
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user