From 8bc3393d55efe63a6aa7f5964baa0782f8e40142 Mon Sep 17 00:00:00 2001 From: AuxXxilium Date: Sat, 16 Nov 2024 00:35:56 +0100 Subject: [PATCH] functions: move to correct file Signed-off-by: AuxXxilium --- files/initrd/opt/arc/arc-functions.sh | 17 +++-------------- files/initrd/opt/arc/include/functions.sh | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/files/initrd/opt/arc/arc-functions.sh b/files/initrd/opt/arc/arc-functions.sh index 6d2fe85c..f09dc338 100755 --- a/files/initrd/opt/arc/arc-functions.sh +++ b/files/initrd/opt/arc/arc-functions.sh @@ -1609,17 +1609,6 @@ function loaderPorts() { RET=$? case ${RET} in 0) # ok-button - function check_port() { - if [ -z "${1}" ]; then - return 0 - else - if [[ "${1}" =~ ^[0-9]+$ ]] && [ "${1}" -ge 0 ] && [ "${1}" -le 65535 ]; then - return 0 - else - return 1 - fi - fi - } HTTPPORT=$(sed -n '1p' "${TMP_PATH}/resp") DUFSPORT=$(sed -n '2p' "${TMP_PATH}/resp") TTYDPORT=$(sed -n '3p' "${TMP_PATH}/resp") @@ -1631,9 +1620,9 @@ function loaderPorts() { [ $? -eq 0 ] && continue || break fi rm -f "/etc/arc.conf" - [ ! "${HTTPPORT:-8080}" = "8080" ] && echo "HTTP_PORT=${HTTPPORT}" >>"/etc/arc.conf" && /etc/init.d/S90thttpd restart >/dev/null 2>&1 - [ ! "${DUFSPORT:-7304}" = "7304" ] && echo "DUFS_PORT=${DUFSPORT}" >>"/etc/arc.conf" && /etc/init.d/S99dufs restart >/dev/null 2>&1 - [ ! "${TTYDPORT:-7681}" = "7681" ] && echo "TTYD_PORT=${TTYDPORT}" >>"/etc/arc.conf" && /etc/init.d/S99ttyd restart >/dev/null 2>&1 + if [ ! "${HTTPPORT:-8080}" = "8080" ]; then echo "HTTP_PORT=${HTTPPORT}" >>"/etc/arc.conf"; /etc/init.d/S90thttpd restart >/dev/null 2>&1; fi + if [ ! "${DUFSPORT:-7304}" = "7304" ]; then echo "DUFS_PORT=${DUFSPORT}" >>"/etc/arc.conf"; /etc/init.d/S99dufs restart >/dev/null 2>&1; fi + if [ ! "${TTYDPORT:-7681}" = "7681" ]; then echo "TTYD_PORT=${TTYDPORT}" >>"/etc/arc.conf"; /etc/init.d/S99ttyd restart >/dev/null 2>&1; fi RDXZ_PATH="${TMP_PATH}/rdxz_tmp" rm -rf "${RDXZ_PATH}" mkdir -p "${RDXZ_PATH}" diff --git a/files/initrd/opt/arc/include/functions.sh b/files/initrd/opt/arc/include/functions.sh index d77149c9..794410a8 100755 --- a/files/initrd/opt/arc/include/functions.sh +++ b/files/initrd/opt/arc/include/functions.sh @@ -567,4 +567,18 @@ function systemCheck () { function genHWID () { HWID="$(echo $(dmidecode -t 4 | grep ID | sed 's/.*ID://;s/ //g' | head -1) $(ifconfig | grep eth | awk '{print $NF}' | sed 's/://g' | sort | head -1) | sha256sum | awk '{print $1}' | cut -c1-16)" 2>/dev/null echo "${HWID}" +} + +############################################################################### +# Check if port is valid +function check_port() { + if [ -z "${1}" ]; then + return 0 + else + if [[ "${1}" =~ ^[0-9]+$ ]] && [ "${1}" -ge 0 ] && [ "${1}" -le 65535 ]; then + return 0 + else + return 1 + fi + fi } \ No newline at end of file