mod ttyd port to 5000, add NIC check connect

This commit is contained in:
Ing 2023-07-07 17:41:45 +08:00
parent 674bb2f1ec
commit 96f1c96f79
8 changed files with 564 additions and 504 deletions

View File

@ -34,7 +34,7 @@ null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr
tty1::respawn:/sbin/agetty -a root --noclear tty1
tty2::askfirst:/sbin/agetty --noclear tty2
ttyS0::askfirst:/sbin/agetty -a root ttyS0 115200 linux
::respawn:/usr/bin/ttyd -t enableZmodem=true -t enableSixel=true -t enableTrzsz=true login -f root
::respawn:/usr/bin/ttyd -t enableZmodem=true -t enableSixel=true -t enableTrzsz=true -p 5000 login -f root
# Stuff to do for the 3-finger salute
::ctrlaltdel:/sbin/reboot

View File

@ -165,21 +165,42 @@ if [ "${DIRECT}" = "true" ]; then
reboot
exit 0
else
(/etc/init.d/S41dhcpcd restart >/dev/null 2>&1 &) || true
BOOTIPWAIT="$(readConfigKey "bootipwait" "${USER_CONFIG_FILE}")"
[ -z "${BOOTIPWAIT}" ] && BOOTIPWAIT=10
sleep ${BOOTIPWAIT}
ETHX=($(ls /sys/class/net/ | grep eth)) # real network cards list
echo "$(printf "$(TEXT "Detected %s network cards, Waiting IP.(For reference only)")" "${#ETHX[@]}")"
echo "$(printf "$(TEXT "Detected %s network cards.")" "${#ETHX[@]}")"
echo "$(TEXT "Checking Connect.")"
COUNT=0
while [ ${COUNT} -lt ${BOOTIPWAIT} ]; do
hasConnect="false"
for N in $(seq 0 $(expr ${#ETHX[@]} - 1)); do
if ethtool ${ETHX[${N}]} | grep 'Link detected' | grep -q 'yes'; then
echo -en "${ETHX[${N}]} "
hasConnect="true"
fi
done
if [ ${hasConnect} = "true" ]; then
echo -en "connected.\n"
break
fi
COUNT=$((${COUNT} + 1))
echo -n "."
sleep 1
done
echo "$(TEXT "Waiting IP.(For reference only)")"
for N in $(seq 0 $(expr ${#ETHX[@]} - 1)); do
COUNT=0
DRIVER=$(ls -ld /sys/class/net/${ETHX[${N}]}/device/driver 2>/dev/null | awk -F '/' '{print $NF}')
echo -en "${ETHX[${N}]}(${DRIVER}): "
while true; do
if [ -z "$(ip link show ${ETHX[${N}]} | grep 'UP')" ]; then
if ! ip link show ${ETHX[${N}]} | grep -q 'UP'; then
echo -en "\r${ETHX[${N}]}(${DRIVER}): $(TEXT "DOWN")\n"
break
fi
if ethtool ${ETHX[${N}]} | grep 'Link detected' | grep -q 'no'; then
echo -en "\r${ETHX[${N}]}(${DRIVER}): $(TEXT "NOT CONNECTED")\n"
break
fi
if [ ${COUNT} -eq 8 ]; then # Under normal circumstances, no errors should occur here.
echo -en "\r${ETHX[${N}]}(${DRIVER}): $(TEXT "ERROR")\n"
break

View File

@ -176,24 +176,47 @@ if [ ${BOOT} -eq 1 ]; then
fi
# Wait for an IP
echo "$(printf "$(TEXT "Detected %s network cards, Waiting IP.")" "${#ETHX[@]}")"
echo "$(printf "$(TEXT "Detected %s network cards.")" "${#ETHX[@]}")"
echo "$(TEXT "Checking Connect.")"
COUNT=0
while [ ${COUNT} -lt 30 ]; do
hasConnect="false"
for N in $(seq 0 $(expr ${#ETHX[@]} - 1)); do
if ethtool ${ETHX[${N}]} | grep 'Link detected' | grep -q 'yes'; then
echo -en "${ETHX[${N}]} "
hasConnect="true"
fi
done
if [ ${hasConnect} = "true" ]; then
echo -en "connected.\n"
break
fi
COUNT=$((${COUNT} + 1))
echo -n "."
sleep 1
done
echo "$(TEXT "Waiting IP.")"
for N in $(seq 0 $(expr ${#ETHX[@]} - 1)); do
COUNT=0
DRIVER=$(ls -ld /sys/class/net/${ETHX[${N}]}/device/driver 2>/dev/null | awk -F '/' '{print $NF}')
echo -en "${ETHX[${N}]}(${DRIVER}): "
while true; do
if [ -z "$(ip link show ${ETHX[${N}]} | grep 'UP')" ]; then
if ! ip link show ${ETHX[${N}]} | grep -q 'UP'; then
echo -en "\r${ETHX[${N}]}(${DRIVER}): $(TEXT "DOWN")\n"
break
fi
if [ ${COUNT} -eq 30 ]; then
if ethtool ${ETHX[${N}]} | grep 'Link detected' | grep -q 'no'; then
echo -en "\r${ETHX[${N}]}(${DRIVER}): $(TEXT "NOT CONNECTED")\n"
break
fi
if [ ${COUNT} -eq 8 ]; then
echo -en "\r${ETHX[${N}]}(${DRIVER}): $(TEXT "ERROR")\n"
break
fi
COUNT=$((${COUNT} + 1))
IP=$(ip route show dev ${ETHX[${N}]} 2>/dev/null | sed -n 's/.* via .* src \(.*\) metric .*/\1/p')
if [ -n "${IP}" ]; then
echo -en "\r${ETHX[${N}]}(${DRIVER}): $(printf "$(TEXT "Access \033[1;34mhttp://%s:7681\033[0m to configure the loader via web terminal.")" "${IP}")\n"
echo -en "\r${ETHX[${N}]}(${DRIVER}): $(printf "$(TEXT "Access \033[1;34mhttp://%s:5000\033[0m to configure the loader via web terminal.")" "${IP}")\n"
break
fi
echo -n "."

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -151,7 +151,7 @@ function productversMenu() {
ITEMS="$(readConfigEntriesArray "productvers" "${MODEL_CONFIG_PATH}/${MODEL}.yml" | sort -r)"
if [ -z "${1}" ]; then
dialog --backtitle "$(backtitle)" --colors \
--no-items --menu "$(TEXT "Choose a build number")" 0 0 0 ${ITEMS} \
--no-items --menu "$(TEXT "Choose a product version")" 0 0 0 ${ITEMS} \
2>${TMP_PATH}/resp
[ $? -ne 0 ] && return
resp=$(<${TMP_PATH}/resp)
@ -163,17 +163,17 @@ function productversMenu() {
if [ "${PRODUCTVER}" != "${resp}" ]; then
local KVER=$(readModelKey "${MODEL}" "productvers.[${resp}].kver")
if [ -d "/sys/firmware/efi" -a "${KVER:0:1}" = "3" ]; then
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Build Number")" \
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Product Version")" \
--msgbox "$(TEXT "This version does not support UEFI startup, Please select another version or switch the startup mode.")" 0 0
return
fi
if [ ! "usb" = "$(udevadm info --query property --name ${LOADER_DISK} | grep BUS | cut -d= -f2)" -a "${KVER:0:1}" = "5" ]; then
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Build Number")" \
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Product Version")" \
--msgbox "$(TEXT "This version only support usb startup, Please select another version or switch the startup mode.")" 0 0
return
fi
# get online pat data
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Build Number")" \
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Product Version")" \
--infobox "$(TEXT "Get online pat data ..")" 0 0
idx=1
while [ $idx -le 3 ]; do # Loop 3 times, if successful, break
@ -198,7 +198,7 @@ function productversMenu() {
else
MSG="Successfully to get online pat data,\nPlease confirm or modify as needed."
fi
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Build Number")" \
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Product Version")" \
--form "${MSG}" 10 110 2 "URL" 1 1 "${paturl}" 1 5 100 0 "MD5" 2 1 "${patsum}" 2 5 100 0 \
2>"${TMP_PATH}/resp"
[ $? -ne 0 ] && return
@ -213,7 +213,7 @@ function productversMenu() {
SMALLNUM=""
writeConfigKey "buildnum" "" "${USER_CONFIG_FILE}"
writeConfigKey "smallnum" "" "${USER_CONFIG_FILE}"
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Build Number")" \
dialog --backtitle "$(backtitle)" --colors --title "$(TEXT "Product Version")" \
--infobox "$(TEXT "Reconfiguring Synoinfo, Addons and Modules")" 0 0
# Delete synoinfo and reload model/build synoinfo
writeConfigKey "synoinfo" "{}" "${USER_CONFIG_FILE}"

View File

@ -1,6 +1,6 @@
<!DOCTYPE html>
<html>
<head>
<script language="javascript"> location.replace("https://github.com/wjz304/arpl-i18n")</script>
<script language="javascript"> location.replace(`http://${location.hostname}:5000`)</script>
</head>
</html>