mirror of
https://github.com/leitbogioro/Tools.git
synced 2025-11-12 10:20:34 +08:00
Update InstallNET.sh
This commit is contained in:
parent
3ee2a62c96
commit
f1f0b5780e
1 changed files with 29 additions and 0 deletions
|
|
@ -1461,6 +1461,32 @@ function getInterface() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# $1 is "$ipMask", $2 is "$ip6Mask". Can only accept prefix number transmit.
|
||||||
|
function acceptIPv4AndIPv6SubnetValue() {
|
||||||
|
[[ -n "$1" ]] && {
|
||||||
|
if [[ `echo "$1" | grep '^[[:digit:]]*$'` && "$1" -ge "1" && "$1" -le "32" ]]; then
|
||||||
|
ipPrefix="$1"
|
||||||
|
actualIp4Prefix="$ipPrefix"
|
||||||
|
ipMask=`netmask "$1"`
|
||||||
|
actualIp4Subnet="$1"
|
||||||
|
else
|
||||||
|
echo -ne "\n[${red}Warning${plain}] Only accept prefix format of IPv4 address, length from 1 to 32."
|
||||||
|
echo -ne "\nIPv4 CIDR Calculator: https://www.vultr.com/resources/subnet-calculator/\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
[[ -n "$2" ]] && {
|
||||||
|
if [[ `echo "$2" | grep '^[[:digit:]]*$'` && "$2" -ge "1" && "$2" -le "128" ]]; then
|
||||||
|
actualIp6Prefix="$2"
|
||||||
|
ipv6SubnetCalc "$2"
|
||||||
|
else
|
||||||
|
echo -ne "\n[${red}Warning${plain}] Only accept prefix format of IPv6 address, length from 1 to 128."
|
||||||
|
echo -ne "\nIPv6 CIDR Calculator: https://en.rakko.tools/tools/27/\n"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
# To confuse whether ipv4 is dhcp or static and whether ipv6 is dhcp or static in Redhat like os in version 9 and later,
|
# To confuse whether ipv4 is dhcp or static and whether ipv6 is dhcp or static in Redhat like os in version 9 and later,
|
||||||
# $1 is $NetCfgDir, $2 is $NetCfgFile, $3 is "ipv4" or "ipv6", $4 is "method="
|
# $1 is $NetCfgDir, $2 is $NetCfgFile, $3 is "ipv4" or "ipv6", $4 is "method="
|
||||||
function checkIpv4OrIpv6ConfigForRedhat9Later() {
|
function checkIpv4OrIpv6ConfigForRedhat9Later() {
|
||||||
|
|
@ -2041,17 +2067,20 @@ if [[ -n "$ipAddr" && -n "$ipMask" && -n "$ipGate" ]] && [[ -z "$ip6Addr" && -z
|
||||||
setNet='1'
|
setNet='1'
|
||||||
checkDHCP "$CurrentOS" "$CurrentOSVer" "$IPStackType"
|
checkDHCP "$CurrentOS" "$CurrentOSVer" "$IPStackType"
|
||||||
[[ -n "$interface" ]] || interface=`getInterface "$CurrentOS"`
|
[[ -n "$interface" ]] || interface=`getInterface "$CurrentOS"`
|
||||||
|
acceptIPv4AndIPv6SubnetValue "$ipMask" ""
|
||||||
Network4Config="isStatic"
|
Network4Config="isStatic"
|
||||||
[[ "$IPStackType" != "IPv4Stack" ]] && getIPv6Address
|
[[ "$IPStackType" != "IPv4Stack" ]] && getIPv6Address
|
||||||
elif [[ -n "$ipAddr" && -n "$ipMask" && -n "$ipGate" ]] && [[ -n "$ip6Addr" && -n "$ip6Mask" && -n "$ip6Gate" ]]; then
|
elif [[ -n "$ipAddr" && -n "$ipMask" && -n "$ipGate" ]] && [[ -n "$ip6Addr" && -n "$ip6Mask" && -n "$ip6Gate" ]]; then
|
||||||
setNet='1'
|
setNet='1'
|
||||||
[[ -n "$interface" ]] || interface=`getInterface "$CurrentOS"`
|
[[ -n "$interface" ]] || interface=`getInterface "$CurrentOS"`
|
||||||
|
acceptIPv4AndIPv6SubnetValue "$ipMask" "$ip6Mask"
|
||||||
Network4Config="isStatic"
|
Network4Config="isStatic"
|
||||||
Network6Config="isStatic"
|
Network6Config="isStatic"
|
||||||
elif [[ -z "$ipAddr" && -z "$ipMask" && -z "$ipGate" ]] && [[ -n "$ip6Addr" && -n "$ip6Mask" && -n "$ip6Gate" ]]; then
|
elif [[ -z "$ipAddr" && -z "$ipMask" && -z "$ipGate" ]] && [[ -n "$ip6Addr" && -n "$ip6Mask" && -n "$ip6Gate" ]]; then
|
||||||
setNet='1'
|
setNet='1'
|
||||||
checkDHCP "$CurrentOS" "$CurrentOSVer" "$IPStackType"
|
checkDHCP "$CurrentOS" "$CurrentOSVer" "$IPStackType"
|
||||||
[[ -n "$interface" ]] || interface=`getInterface "$CurrentOS"`
|
[[ -n "$interface" ]] || interface=`getInterface "$CurrentOS"`
|
||||||
|
acceptIPv4AndIPv6SubnetValue "" "$ip6Mask"
|
||||||
Network6Config="isStatic"
|
Network6Config="isStatic"
|
||||||
getIPv4Address
|
getIPv4Address
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue