Skip to content

Commit

Permalink
优化 changePorts 函数,简化端口配置保存和服务重启逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
wjz304 committed Dec 6, 2024
1 parent 7faab1b commit eeb8746
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions files/initrd/opt/rr/menu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2781,9 +2781,9 @@ function changePorts() {
--infobox "$(TEXT "Setting ...")" 20 100
# save to rrorg.conf
rm -f "/etc/rrorg.conf"
[ ! "${HTTP:-7080}" = "7080" ] && (echo "HTTP_PORT=${HTTP}" >>"/etc/rrorg.conf" && /etc/init.d/S90thttpd restart >/dev/null 2>&1)
[ ! "${DUFS:-7304}" = "7304" ] && (echo "DUFS_PORT=${DUFS}" >>"/etc/rrorg.conf" && /etc/init.d/S99dufs restart >/dev/null 2>&1)
[ ! "${TTYD:-7681}" = "7681" ] && (echo "TTYD_PORT=${TTYD}" >>"/etc/rrorg.conf" && /etc/init.d/S99ttyd restart >/dev/null 2>&1)
[ ! "${HTTP:-7080}" = "7080" ] && echo "HTTP_PORT=${HTTP}" >>"/etc/rrorg.conf"
[ ! "${DUFS:-7304}" = "7304" ] && echo "DUFS_PORT=${DUFS}" >>"/etc/rrorg.conf"
[ ! "${TTYD:-7681}" = "7681" ] && echo "TTYD_PORT=${TTYD}" >>"/etc/rrorg.conf"
# save to rru
local RDXZ_PATH="${TMP_PATH}/rdxz_tmp"
rm -rf "${RDXZ_PATH}"
Expand Down Expand Up @@ -2826,6 +2826,11 @@ function changePorts() {
rm -f "${RR_RAMUSER_FILE}"
fi
rm -rf "${RDXZ_PATH}"
{
[ ! "${HTTP:-7080}" = "7080" ] && /etc/init.d/S90thttpd restart
[ ! "${DUFS:-7304}" = "7304" ] && /etc/init.d/S99dufs restart
[ ! "${TTYD:-7681}" = "7681" ] && /etc/init.d/S99ttyd restart
} >/dev/null 2>&1 &
[ ! -f "/etc/rrorg.conf" ] && MSG="$(TEXT "Ports for TTYD/DUFS/HTTP restored.")" || MSG="$(TEXT "Ports for TTYD/DUFS/HTTP changed.")"
DIALOG --title "$(TEXT "Settings")" \
--msgbox "${MSG}" 0 0
Expand Down

0 comments on commit eeb8746

Please sign in to comment.