core: 完善 tty

This commit is contained in:
bin456789
2023-09-03 19:35:01 +08:00
parent 15de1ac098
commit e2ca64a255
4 changed files with 46 additions and 40 deletions

32
ttys.sh
View File

@@ -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