From f290099ea3f130fad20e44366c639e0704505957 Mon Sep 17 00:00:00 2001 From: Molly Lau Date: Tue, 24 Oct 2023 20:10:00 +0900 Subject: [PATCH] Update alpineInit.sh --- Linux_reinstall/Alpine/alpineInit.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Linux_reinstall/Alpine/alpineInit.sh b/Linux_reinstall/Alpine/alpineInit.sh index 486d836..3e8ddfe 100644 --- a/Linux_reinstall/Alpine/alpineInit.sh +++ b/Linux_reinstall/Alpine/alpineInit.sh @@ -2,9 +2,15 @@ # # Alpine Linux use "ash" as the default shell. -exec >/dev/tty0 2>&1 -exec >/dev/ttyS0 2>&1 -exec >/dev/ttyAMA0 2>&1 +# Find available tty. +# Parameters of outputs of "stty": https://www.ibm.com/docs/en/aix/7.3?topic=s-stty-command +for ttyItems in "/dev/tty0" "/dev/ttyS0" "/dev/ttyAMA0"; do + ttyAttribute=$(stty -F "$ttyItems") + [[ -n "$ttyAttribute" && -n $(echo "$ttyAttribute" | grep -io "\-brkint ixoff \-imaxbel") ]] && { + break + } +done +exec >"$ttyItems" 2>&1 insertIntoFile() { file=$1