mirror of
https://github.com/bin456789/reinstall.git
synced 2025-10-05 14:34:53 +00:00
core: 完善 tty
This commit is contained in:
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
|
||||
|
Reference in New Issue
Block a user