forked from pool/warewulf4
- check if automatic configured ip range doesn'y contain ip address
of ww4 host OBS-URL: https://build.opensuse.org/package/show/network:cluster/warewulf4?expand=0&rev=42
This commit is contained in:
parent
1a1882fa33
commit
bedbbac318
@ -27,6 +27,21 @@ network_address() {
|
||||
|
||||
echo $( IFS=.; echo "${octets[*]}" )
|
||||
}
|
||||
# Check if last Octed is in range
|
||||
function is_ip_in_range() {
|
||||
# split the ip addresses into their octets.
|
||||
local ip_start_octets=($(echo $DYNSTART | tr "." " "))
|
||||
local ip_end_octets=($(echo $DYNEND | tr "." " "))
|
||||
local ip_address_octets=($(echo $1 | tr "." " "))
|
||||
|
||||
# compare the octets one at a time to see if the ip address is within the range.
|
||||
if [[ ${ip_address_octets[3]} -lt ${ip_start_octets[3]} || ${ip_address_octets[3]} -gt ${ip_end_octets[3]} ]]; then
|
||||
return 1
|
||||
fi
|
||||
# if we reach this point, the ip address is in the range.
|
||||
return 0
|
||||
}
|
||||
|
||||
echo "-- WW4 CONFIGURAION $* --"
|
||||
|
||||
# Make sure that a ip address was defined for out network so that
|
||||
@ -39,13 +54,21 @@ IP4NET=$(network_address "$IP4/$IP4PREFIX")
|
||||
|
||||
if [ "$IP4PREFIX" -gt 25 ] ; then
|
||||
echo "ERROR: warewulf does at least a /25 network for dynamic addresses"
|
||||
cat << EOF
|
||||
ipaddr: $IP4
|
||||
netmask: $IP4MASK
|
||||
network: $IP4NET
|
||||
range start: $DYNSTART
|
||||
range end: $DYNEND
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DYNSIZE=20
|
||||
DYNSTART=${IP4#*.*.*.}
|
||||
DYNSTART=$(( $DYNSTART + 2))
|
||||
DYNPRE=${IP4%.*}
|
||||
DYNEND=$(( $DYNSTART + $DYNSIZE ))
|
||||
DYNEND=$(( $DYNSTART + $DYNSIZE + 1 ))
|
||||
if [ $DYNEND -gt 254 ] ; then
|
||||
DYNEND=$(( $IPNET + 2 + $DYNSIZE ))
|
||||
DYNSTART=$(( $IPNET + 2 ))
|
||||
@ -53,6 +76,11 @@ fi
|
||||
DYNSTART="${DYNPRE}.${DYNSTART}"
|
||||
DYNEND="${DYNPRE}.${DYNEND}"
|
||||
|
||||
if is_ip_in_range $IP4 ; then
|
||||
echo "ERROR: ip address is in range for dynamic address, please set this manually"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
if [ -e $WW4CONF ] ; then
|
||||
test -n $IP4 && sed -i 's/^ipaddr:.*/ipaddr: '$IP4'/' $WW4CONF
|
||||
|
@ -1,3 +1,9 @@
|
||||
-------------------------------------------------------------------
|
||||
Thu Oct 12 07:43:32 UTC 2023 - Christian Goll <cgoll@suse.com>
|
||||
|
||||
- check if automatic configured ip range doesn'y contain ip address
|
||||
of ww4 host
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Thu Sep 21 09:23:31 UTC 2023 - Christian Goll <cgoll@suse.com>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user