|
4 | 4 | # |
5 | 5 | # Original Creation Date: 2023-Oct-01 by @ExtremeFiretop. |
6 | 6 | # Official Co-Author: @Martinski W. - Date: 2023-Nov-01 |
7 | | -# Last Modified: 2025-Jun-02 |
| 7 | +# Last Modified: 2025-Jun-06 |
8 | 8 | ################################################################### |
9 | 9 | set -u |
10 | 10 |
|
11 | 11 | ## Set version for each Production Release ## |
12 | | -readonly SCRIPT_VERSION=1.4.7 |
| 12 | +readonly SCRIPT_VERSION=1.4.8 |
13 | 13 | readonly SCRIPT_NAME="MerlinAU" |
14 | 14 | ## Set to "master" for Production Releases ## |
15 | 15 | SCRIPT_BRANCH="master" |
@@ -4638,33 +4638,38 @@ _GetLoginCredentials_() |
4638 | 4638 | return 0 |
4639 | 4639 | } |
4640 | 4640 |
|
4641 | | -##----------------------------------------## |
4642 | | -## Modified by Martinski W. [2024-Apr-06] ## |
4643 | | -##----------------------------------------## |
| 4641 | +##-------------------------------------------## |
| 4642 | +## Modified by ExtremeFiretop [2025-June-06] ## |
| 4643 | +##-------------------------------------------## |
4644 | 4644 | _GetNodeIPv4List_() |
4645 | 4645 | { |
4646 | | - # Get the value of asus_device_list # |
4647 | | - local ip_addresses |
4648 | | - local device_list="$(nvram get asus_device_list)" |
| 4646 | + local NODE_ROLE="2" # keep only nodes whose last field == 2 |
| 4647 | + local device_list ip_addresses |
4649 | 4648 |
|
4650 | | - # Check if asus_device_list is not empty # |
4651 | | - if [ -n "$device_list" ] |
4652 | | - then |
4653 | | - # Split the device list into records and extract the IP addresses, excluding Main Router LAN IP address # |
4654 | | - ip_addresses="$(echo "$device_list" | tr '<' '\n' | awk -v exclude="$mainLAN_IPaddr" -F'>' '{if (NF>=4 && $3 != exclude) print $3}')" |
| 4649 | + device_list="$(nvram get asus_device_list)" |
4655 | 4650 |
|
4656 | | - # Check if IP addresses are not empty # |
4657 | | - if [ -n "$ip_addresses" ]; then |
4658 | | - # Print each IP address on a separate line |
4659 | | - printf "%s\n" "$ip_addresses" |
4660 | | - else |
4661 | | - return 1 |
4662 | | - fi |
4663 | | - else |
| 4651 | + if [ -z "$device_list" ]; then |
4664 | 4652 | Say "NVRAM asus_device_list is NOT populated. No Mesh Nodes were found." |
4665 | 4653 | return 1 |
4666 | 4654 | fi |
4667 | | - return 0 |
| 4655 | + |
| 4656 | + ip_addresses="$( |
| 4657 | + printf '%s\n' "$device_list" | |
| 4658 | + tr '<' '\n' | |
| 4659 | + awk -F'>' \ |
| 4660 | + -v role="$NODE_ROLE" \ |
| 4661 | + -v exclude="$mainLAN_IPaddr" ' |
| 4662 | + NF >= 4 && $3 != exclude && $NF == role { print $3 } |
| 4663 | + ' |
| 4664 | + )" |
| 4665 | + |
| 4666 | + if [ -n "$ip_addresses" ]; then |
| 4667 | + printf '%s\n' "$ip_addresses" |
| 4668 | + return 0 |
| 4669 | + fi |
| 4670 | + |
| 4671 | + # nothing matched |
| 4672 | + return 1 |
4668 | 4673 | } |
4669 | 4674 |
|
4670 | 4675 | ##----------------------------------------## |
|
0 commit comments