diff --git a/.gitattributes b/.gitattributes index 8e8afd5..05888da 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,5 +1,13 @@ +* text eol=lf *.sh text eol=lf *.md text eol=lf *.asp text eol=lf +*.js text eol=lf +*.css text eol=lf *.config.example text eol=lf -* text=auto eol=lf +*.gz binary +*.png binary +*.jpg binary +*.jpeg binary +*.zip binary +*.tar.gz binary diff --git a/.github/workflows/Create-NewReleases.yml b/.github/workflows/Create-NewReleases.yml index ef961c3..4efb568 100644 --- a/.github/workflows/Create-NewReleases.yml +++ b/.github/workflows/Create-NewReleases.yml @@ -19,7 +19,7 @@ jobs: steps: # 1--- Check out master so we tag the exact merge commit - name: Checkout source code - uses: actions/checkout@v4.2.2 + uses: actions/checkout@v5.0.0 with: fetch-depth: 0 ref: 'master' @@ -97,7 +97,7 @@ jobs: # 7--- Publish a GitHub Release with auto-generated notes - name: Create Release with Automated Release Notes - uses: softprops/action-gh-release@v2.3.2 + uses: softprops/action-gh-release@v2.4.1 with: token: ${{ secrets.GITHUB_TOKEN }} tag_name: ${{ steps.nextver.outputs.tag }} diff --git a/README.md b/README.md index 23a2400..b7b2039 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ # YazFi - enhanced AsusWRT-Merlin Guest WiFi Networks -## v4.4.8 -### Updated on 2025-Jul-20 +## v4.4.9 +### Updated on 2025-Nov-08 + ## About Feature expansion of guest WiFi networks on AsusWRT-Merlin, including, but not limited to: diff --git a/YazFi.sh b/YazFi.sh index 31220e3..19ada98 100644 --- a/YazFi.sh +++ b/YazFi.sh @@ -17,7 +17,7 @@ ## Guest Network DHCP script and for ## ## AsusWRT-Merlin firmware ## ################################################### -# Last Modified: 2025-Jul-18 +# Last Modified: 2025-Nov-04 #-------------------------------------------------- ###### Shellcheck directives ###### @@ -41,10 +41,10 @@ ### Start of script variables ### readonly SCRIPT_NAME="YazFi" readonly SCRIPT_CONF="/jffs/addons/$SCRIPT_NAME.d/config" -readonly YAZFI_VERSION="v4.4.8" -readonly SCRIPT_VERSION="v4.4.8" -readonly SCRIPT_VERSTAG="25071823" -SCRIPT_BRANCH="master" +readonly YAZFI_VERSION="v4.4.9" +readonly SCRIPT_VERSION="v4.4.9" +readonly SCRIPT_VERSTAG="25110423" +SCRIPT_BRANCH="develop" SCRIPT_REPO="https://raw.githubusercontent.com/AMTM-OSR/$SCRIPT_NAME/$SCRIPT_BRANCH" readonly SCRIPT_DIR="/jffs/addons/$SCRIPT_NAME.d" readonly USER_SCRIPT_DIR="$SCRIPT_DIR/userscripts.d" @@ -65,21 +65,13 @@ readonly BOLD="\\e[1m" readonly SETTING="${BOLD}\\e[36m" readonly CLEARFORMAT="\\e[0m" readonly CLRct="\e[0m" +readonly REDct="\e[1;31m" +readonly GRNct="\e[1;32m" readonly MGNTct="\e[1;35m" ### End of output format variables ### ### Start of router environment variables ### -##-------------------------------------## -## Added by Martinski W. [2025-Mar-16] ## -##-------------------------------------## -readonly scriptVersRegExp="v[0-9]{1,2}([.][0-9]{1,2})([.][0-9]{1,2})" -readonly webPageFileRegExp="user([1-9]|[1-2][0-9])[.]asp" -readonly webPageLineTabExp="\{url: \"$webPageFileRegExp\", tabName: " -readonly webPageLineRegExp="${webPageLineTabExp}\"$SCRIPT_NAME\"\}," -readonly branchx_TAG="Branch: $SCRIPT_BRANCH" -readonly version_TAG="${SCRIPT_VERSION}_${SCRIPT_VERSTAG}" - # Give higher priority to built-in binaries # export PATH="/bin:/usr/bin:/sbin:/usr/sbin:$PATH" @@ -91,6 +83,17 @@ readonly LAN_IFname="$(nvram get lan_ifname)" [ -z "$(nvram get odmpid)" ] && ROUTER_MODEL="$(nvram get productid)" || ROUTER_MODEL="$(nvram get odmpid)" ROUTER_MODEL="$(echo "$ROUTER_MODEL" | tr 'a-z' 'A-Z')" +##-------------------------------------## +## Added by Martinski W. [2025-Mar-16] ## +##-------------------------------------## +readonly scriptVersRegExp="v[0-9]{1,2}([.][0-9]{1,2})([.][0-9]{1,2})" +readonly webPageFileRegExp="user([1-9]|[1-2][0-9])[.]asp" +readonly webPageLineTabExp="\{url: \"$webPageFileRegExp\", tabName: " +readonly webPageLineRegExp="${webPageLineTabExp}\"$SCRIPT_NAME\"\}," +readonly branchxStr_TAG="[Branch: $SCRIPT_BRANCH]" +readonly versionDev_TAG="${SCRIPT_VERSION}_${SCRIPT_VERSTAG}" +readonly versionMod_TAG="$SCRIPT_VERSION on $ROUTER_MODEL" + ##-------------------------------------## ## Added by Martinski W. [2025-Mar-16] ## ##-------------------------------------## @@ -2549,7 +2552,7 @@ Routing_NVRAM() do if [ "$(eval echo '$'"VPN_IP_LIST_ORIG_$COUNTER")" != "$(eval echo '$'"VPN_IP_LIST_NEW_$COUNTER")" ] then - Print_Output true "VPN Client $COUNTER client list has changed, restarting VPN Client $COUNTER" + Print_Output true "VPN Client $COUNTER client list has changed, restarting VPN Client $COUNTER" "$PASS" if [ "$(/bin/uname -m)" = "aarch64" ] then @@ -2677,7 +2680,7 @@ DHCP_Conf() then cp "$TMPCONF" "$DNSCONF" service restart_dnsmasq >/dev/null 2>&1 - Print_Output true "DHCP configuration updated" + Print_Output true "DHCP configuration updated" "$PASS" sleep 2 fi @@ -2711,7 +2714,7 @@ _NVRAM_Get_WAN_IFace_() ##----------------------------------------## Config_Networks() { - Print_Output true "$SCRIPT_NAME $SCRIPT_VERSION starting up" + Print_Output true "$SCRIPT_NAME $SCRIPT_VERSION starting up" "$PASS" WIRELESSRESTART="false" GUESTLANENABLED="false" @@ -2770,7 +2773,7 @@ Config_Networks() then if [ "$(eval echo '$'"$(Get_Iface_Var "$IFACE")_REDIRECTALLTOVPN")" = "true" ] then - Print_Output true "$IFACE (SSID: $(nvram get "${IFACE}_ssid")) - VPN redirection enabled, sending all interface internet traffic over VPN Client $VPNCLIENTNO" + Print_Output true "$IFACE (SSID: $(nvram get "${IFACE}_ssid")) - VPN redirection enabled, sending all interface internet traffic over VPN Client $VPNCLIENTNO" "$PASS" if [ "$(_FWVersionStrToNum_ "$fwInstalledBranchVer")" -lt "$(_FWVersionStrToNum_ 3004.386.3)" ] then @@ -2781,7 +2784,7 @@ Config_Networks() Firewall_NAT create "$IFACE" "$VPNCLIENTNO" 2>/dev/null else - Print_Output true "$IFACE (SSID: $(nvram get "${IFACE}_ssid")) - sending all interface internet traffic over WAN interface" + Print_Output true "$IFACE (SSID: $(nvram get "${IFACE}_ssid")) - sending all interface internet traffic over WAN interface" "$PASS" Firewall_NAT delete "$IFACE" 2>/dev/null @@ -2807,7 +2810,7 @@ Config_Networks() if [ "$(eval echo '$'"$(Get_Iface_Var "$IFACE")_ALLOWINTERNET")" = "false" ] then - Print_Output true "$IFACE (SSID: $(nvram get "${IFACE}_ssid")) - allow internet disabled, blocking all interface internet traffic" + Print_Output true "$IFACE (SSID: $(nvram get "${IFACE}_ssid")) - allow internet disabled, blocking all interface internet traffic" "$WARN" Firewall_BlockInternet create "$IFACE" 2>/dev/null else Firewall_BlockInternet delete "$IFACE" 2>/dev/null @@ -2913,7 +2916,7 @@ Execute_UserScripts() for shFile in $FILES do if [ -f "$shFile" ]; then - Print_Output true "Executing user script: $shFile" + Print_Output true "Executing user script: $shFile" "$PASS" sh "$shFile" fi done @@ -2991,50 +2994,82 @@ PressEnter() return 0 } +##-------------------------------------## +## Added by Martinski W. [2025-Oct-26] ## +##-------------------------------------## +_CenterTextStr_() +{ + if [ $# -lt 2 ] || [ -z "$1" ] || [ -z "$2" ] || \ + ! echo "$2" | grep -qE "^[1-9][0-9]+$" + then echo ; return 1 + fi + local stringLen="${#1}" + local space1Len="$((($2 - stringLen)/2))" + local space2Len="$space1Len" + local totalLen="$((space1Len + stringLen + space2Len))" + + if [ "$totalLen" -lt "$2" ] + then space2Len="$((space2Len + 1))" + elif [ "$totalLen" -gt "$2" ] + then space1Len="$((space1Len - 1))" + fi + if [ "$space1Len" -gt 0 ] && [ "$space2Len" -gt 0 ] + then printf "%*s%s%*s" "$space1Len" '' "$1" "$space2Len" '' + else printf "%s" "$1" + fi +} + +##----------------------------------------## +## Modified by Martinski W. [2025-Oct-26] ## +##----------------------------------------## ScriptHeader() { clear - printf "\n" - printf "${BOLD}###################################################${CLEARFORMAT}\\n" - printf "${BOLD}## ##${CLEARFORMAT}\\n" - printf "${BOLD}## __ __ ______ _ ##${CLEARFORMAT}\\n" - printf "${BOLD}## \ \ / / | ____|(_) ##${CLEARFORMAT}\\n" - printf "${BOLD}## \ \_/ /__ _ ____| |__ _ ##${CLEARFORMAT}\\n" - printf "${BOLD}## \ // _ ||_ /| __| | | ##${CLEARFORMAT}\\n" - printf "${BOLD}## | || (_| | / / | | | | ##${CLEARFORMAT}\\n" - printf "${BOLD}## |_| \__,_|/___||_| |_| ##${CLEARFORMAT}\\n" - printf "${BOLD}## ##${CLEARFORMAT}\\n" - printf "${BOLD}## %9s on %-18s ##${CLEARFORMAT}\n" "$SCRIPT_VERSION" "$ROUTER_MODEL" - printf "${BOLD}## ##${CLEARFORMAT}\\n" - printf "${BOLD}## https://github.com/AMTM-OSR/YazFi ##${CLEARFORMAT}\\n" - printf "${BOLD}## Forked from: https://github.com/jackyaz/YazFi ##${CLEARFORMAT}\\n" - printf "${BOLD}## ##${CLEARFORMAT}\\n" - printf "${BOLD}###################################################${CLEARFORMAT}\\n" - printf "\n" + local spaceLen=46 colorCT + [ "$SCRIPT_BRANCH" = "master" ] && colorCT="$GRNct" || colorCT="$MGNTct" + echo + printf "${BOLD}####################################################${CLRct}\n" + printf "${BOLD}## __ __ ______ _ ##${CLRct}\n" + printf "${BOLD}## \ \ / / | ____|(_) ##${CLRct}\n" + printf "${BOLD}## \ \_/ /__ _ ____| |__ _ ##${CLRct}\n" + printf "${BOLD}## \ // _ ||_ /| __| | | ##${CLRct}\n" + printf "${BOLD}## | || (_| | / / | | | | ##${CLRct}\n" + printf "${BOLD}## |_| \__,_|/___||_| |_| ##${CLRct}\n" + printf "${BOLD}## ##${CLRct}\n" + printf "${BOLD}## ${GRNct}%s${CLRct}${BOLD} ##${CLRct}\n" "$(_CenterTextStr_ "$versionMod_TAG" "$spaceLen")" + printf "${BOLD}## ${colorCT}%s${CLRct}${BOLD} ##${CLRct}\n" "$(_CenterTextStr_ "$branchxStr_TAG" "$spaceLen")" + printf "${BOLD}## ##${CLRct}\n" + printf "${BOLD}## https://github.com/AMTM-OSR/YazFi ##${CLRct}\n" + printf "${BOLD}## Forked from: https://github.com/jackyaz/YazFi ##${CLRct}\n" + printf "${BOLD}## ##${CLRct}\n" + printf "${BOLD}####################################################${CLRct}\n\n" } +##----------------------------------------## +## Modified by Martinski W. [2025-Oct-26] ## +##----------------------------------------## MainMenu() { - printf "WebUI for %s is available at:\n${SETTING}%s${CLEARFORMAT}\n\n" "$SCRIPT_NAME" "$(Get_WebUI_URL)" + printf "WebUI for %s is available at:\n${SETTING}%s${CLRct}\n\n" "$SCRIPT_NAME" "$(Get_WebUI_URL)" printf "1. Apply %s settings\n\n" "$SCRIPT_NAME" - printf "2. Show connected clients using %s\\n\\n" "$SCRIPT_NAME" - printf "3. Edit %s config\\n" "$SCRIPT_NAME" - printf "4. Edit Guest Network config (SSID + passphrase)\\n\\n" + printf "2. Show connected clients using %s\n\n" "$SCRIPT_NAME" + printf "3. Edit %s config\n" "$SCRIPT_NAME" + printf "4. Edit Guest Network config (SSID + passphrase)\n\n" if [ -f /opt/bin/qrencode ] then printf "5. Show QR Code for Guest Network\n\n" else printf "\nQR Code generation NOT supported.\n\n" fi - printf "u. Check for updates\\n" - printf "uf. Update %s with latest version (force update)\\n\\n" "$SCRIPT_NAME" - printf "d. Generate %s diagnostics\\n\\n" "$SCRIPT_NAME" - printf "e. Exit %s\\n\\n" "$SCRIPT_NAME" - printf "z. Uninstall %s\\n" "$SCRIPT_NAME" - printf "\\n" - printf "${BOLD}#############################################${CLEARFORMAT}\\n" - printf "\\n" + printf "u. Check for updates\n" + printf "uf. Update %s with latest version (force update)\n\n" "$SCRIPT_NAME" + printf "d. Generate %s diagnostics\n\n" "$SCRIPT_NAME" + printf "e. Exit %s\n\n" "$SCRIPT_NAME" + printf "z. Uninstall %s\n" "$SCRIPT_NAME" + printf "\n" + printf "${BOLD}#############################################${CLRct}\n" + printf "\n" while true do @@ -3042,7 +3077,7 @@ MainMenu() read -r menuOption case "$menuOption" in 1) - printf "\\n" + printf "\n" if Check_Lock menu; then Config_Networks Clear_Lock @@ -3112,7 +3147,7 @@ MainMenu() ;; e) ScriptHeader - printf "\\n${BOLD}Thanks for using %s!${CLEARFORMAT}\\n\\n\\n" "$SCRIPT_NAME" + printf "\n${BOLD}Thanks for using %s!${CLEARFORMAT}\n\n\n" "$SCRIPT_NAME" exit 0 ;; z) @@ -3218,7 +3253,7 @@ Menu_Install() then Conf_Download "$SCRIPT_CONF" else - Print_Output false "Existing $SCRIPT_CONF found. This will be kept by $SCRIPT_NAME" + Print_Output false "Existing $SCRIPT_CONF found. This will be kept by $SCRIPT_NAME" "$PASS" Conf_Download "$SCRIPT_CONF.example" fi @@ -3264,6 +3299,7 @@ Menu_Startup() Create_Dirs Create_Symlinks Auto_Cron create 2>/dev/null + Set_Version_Custom_Settings local "$SCRIPT_VERSION" Mount_WebUI } @@ -3927,8 +3963,8 @@ EOF modprobe xt_comment if [ "$SCRIPT_BRANCH" = "master" ] -then SCRIPT_VERS_INFO="[$branchx_TAG]" -else SCRIPT_VERS_INFO="[$version_TAG, $branchx_TAG]" +then SCRIPT_VERS_INFO="" +else SCRIPT_VERS_INFO="[$versionDev_TAG]" fi ##----------------------------------------## @@ -3957,6 +3993,7 @@ then Auto_ServiceEvent create 2>/dev/null Auto_ServiceStart create 2>/dev/null Auto_OpenVPNEvent create 2>/dev/null + Set_Version_Custom_Settings local "$SCRIPT_VERSION" Shortcut_Script create _CheckFor_WebGUI_Page_ ScriptHeader diff --git a/YazFi_www.asp b/YazFi_www.asp index 43779af..f59b98a 100644 --- a/YazFi_www.asp +++ b/YazFi_www.asp @@ -21,30 +21,33 @@ p{font-weight:bolder}thead.collapsible-jquery{color:#fff;padding:0;width:100%;bo - -