|
@@ -26,32 +26,37 @@ for ethtool_command in "${ethtool_commands_array[@]}"; do
|
|
|
fi
|
|
fi
|
|
|
done
|
|
done
|
|
|
|
|
|
|
|
-getip=$(${ipcommand} -o -4 addr | awk '{print $4}' | grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}' | sort -u | grep -v 127.0.0)
|
|
|
|
|
-getipwc=$(${ipcommand} -o -4 addr | awk '{print $4}' | grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}' | sort -u | grep -vc 127.0.0)
|
|
|
|
|
|
|
+mapfile -t current_ips < <(${ipcommand} -o -4 addr | awk '{print $4}' | grep -oe '\([0-9]\{1,3\}\.\?\)\{4\}' | sort -u | grep -v 127.0.0)
|
|
|
|
|
+
|
|
|
|
|
+function fn_is_valid_ip() {
|
|
|
|
|
+ local ip="${1}"
|
|
|
|
|
+ # excluding 0.* ips also
|
|
|
|
|
+ grep -qEe '^[1-9]+[0-9]*\.[0-9]+\.[0-9]+\.[0-9]+$' <<< "${ip}"
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
# Check if server has multiple IP addresses
|
|
# Check if server has multiple IP addresses
|
|
|
|
|
|
|
|
# If the IP variable has been set by user.
|
|
# If the IP variable has been set by user.
|
|
|
-if [ -n "${ip}" ] && [ "${ip}" != "0.0.0.0" ]; then
|
|
|
|
|
- queryips=("${ip}")
|
|
|
|
|
- webadminip=("${ip}")
|
|
|
|
|
- telnetip=("${ip}")
|
|
|
|
|
|
|
+if fn_is_valid_ip "${ip}"; then
|
|
|
|
|
+ queryips=( "${ip}" )
|
|
|
|
|
+ webadminip=( "${ip}" )
|
|
|
|
|
+ telnetip=( "${ip}" )
|
|
|
# If game config does have an IP set.
|
|
# If game config does have an IP set.
|
|
|
-elif [ -n "${configip}" ] && [ "${configip}" != "0.0.0.0" ]; then
|
|
|
|
|
- queryips=("${configip}")
|
|
|
|
|
|
|
+elif fn_is_valid_ip "${configip}";then
|
|
|
|
|
+ queryips=( "${configip}" )
|
|
|
ip="${configip}"
|
|
ip="${configip}"
|
|
|
webadminip=("${configip}")
|
|
webadminip=("${configip}")
|
|
|
telnetip=("${configip}")
|
|
telnetip=("${configip}")
|
|
|
# If there is only 1 server IP address.
|
|
# If there is only 1 server IP address.
|
|
|
# Some IP details can automaticly use the one IP
|
|
# Some IP details can automaticly use the one IP
|
|
|
-elif [ "${getipwc}" == "1" ]; then
|
|
|
|
|
- queryips=($(echo "${getip}"))
|
|
|
|
|
|
|
+elif [ "${#current_ips[@]}" == "1" ]; then
|
|
|
|
|
+ queryips=( "127.0.0.1" "${current_ips[@]}" )
|
|
|
ip="0.0.0.0"
|
|
ip="0.0.0.0"
|
|
|
- webadminip=("${getip}")
|
|
|
|
|
- telnetip=("${getip}")
|
|
|
|
|
|
|
+ webadminip=("${current_ips[@]}")
|
|
|
|
|
+ telnetip=("${current_ips[@]}")
|
|
|
# If no ip is set by the user and server has more than one IP.
|
|
# If no ip is set by the user and server has more than one IP.
|
|
|
else
|
|
else
|
|
|
- queryips=($(echo "${getip}"))
|
|
|
|
|
|
|
+ queryips=( "127.0.0.1" "${current_ips[@]}" )
|
|
|
ip="0.0.0.0"
|
|
ip="0.0.0.0"
|
|
|
webadminip=("${ip}")
|
|
webadminip=("${ip}")
|
|
|
telnetip=("${ip}")
|
|
telnetip=("${ip}")
|