summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2024-03-18 13:56:15 +0100
committerSimon Rettberg2024-03-18 13:59:02 +0100
commitaa2c25a225eed8dac551586a84600b7de7790ebd (patch)
tree5bb603c72489b104e23b528b2151df529d789bd6
parent[dhcpc-busybox] Var is empty, no need to remove (diff)
downloadmltk-aa2c25a225eed8dac551586a84600b7de7790ebd.tar.gz
mltk-aa2c25a225eed8dac551586a84600b7de7790ebd.tar.xz
mltk-aa2c25a225eed8dac551586a84600b7de7790ebd.zip
[run-virt] dhcpd config: Remove fallback for entries if not known
WINS is hopefully dead by now. So don't try to guess which address it might actually have if the real DHCP server didn't supply one. Also remove fallback for search and domain (virtual.localnet), just leave them unset if the real DHCP server didn't supply those either.
-rwxr-xr-xcore/modules/run-virt/data/opt/openslx/scripts/runvirt-start_dhcpd22
1 files changed, 11 insertions, 11 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/scripts/runvirt-start_dhcpd b/core/modules/run-virt/data/opt/openslx/scripts/runvirt-start_dhcpd
index e920855a..827c66aa 100755
--- a/core/modules/run-virt/data/opt/openslx/scripts/runvirt-start_dhcpd
+++ b/core/modules/run-virt/data/opt/openslx/scripts/runvirt-start_dhcpd
@@ -33,14 +33,6 @@ dns=( $( awk '$1 == "nameserver" && $2 ~ "\\..*\\..*\\." {print $2}' /etc/resolv
[ -z "${dns}" ] && dns=( $SLX_DNS )
# Fallbacks
[ -z "${dns}" ] && dns=( "8.8.8.8" "8.8.4.4" )
-[ -z "${SLX_NET_DOMAIN}" ] && SLX_NET_DOMAIN="$FALLBACK_DOMAIN"
-[ -z "${SLX_NET_SEARCH}" ] && SLX_NET_SEARCH="$FALLBACK_DOMAIN"
-# WINS - if not supplied, try to get it from the search base of our ldap config
-if [ -z "${SLX_NET_WINS}" ]; then
- DC=$(grep -m1 -i '^BASE\s*DC=' "/etc/ldap.conf" | grep -o -i 'DC=.*' | sed -r 's/\s*,\s*DC=/./gI;s/^\s*DC=//I')
- [ -z "$DC" ] && DC=$(grep -m1 -i '^ldap_search_base\s*=\s*DC=' "/etc/sssd/sssd.conf" | grep -o -i 'DC=.*' | sed -r 's/\s*,\s*DC=/./gI;s/^\s*DC=//I')
- [ -n "$DC" ] && SLX_NET_WINS=$(getips "$DC")
-fi
# NTP - default to pool.ntp.org
NTPSRV=
[ -z "$SLX_NTP_SERVER" ] && SLX_NTP_SERVER="pool.ntp.org"
@@ -52,9 +44,17 @@ for ips in $SLX_NTP_SERVER; do
NTPSRV="$NTPSRV $ips"
done
[ -z "$NTPSRV" ] && NTPSRV="0.0.0.0"
-[ -z "${SLX_NET_WINS}" ] && SLX_NET_WINS=$(getips "$SLX_NET_DOMAIN")
-[ -z "${SLX_NET_WINS}" ] && SLX_NET_WINS="0.0.0.0"
-sed "s#%DNSSERVER%#${dns[*]}#;s#%DOMAIN%#${SLX_NET_DOMAIN}#;s#%SEARCH%#${SLX_NET_SEARCH}#;s#%WINS%#${SLX_NET_WINS}#;s#%NTPSERVER%#${NTPSRV}#" "${DHCP_NAT_CONF}.template" > "${DHCP_NAT_CONF}.$$"
+declare -a seds=(
+ "s#%DNSSERVER%#${dns[*]}#"
+ "s#%NTPSERVER%#${NTPSRV}#"
+)
+for var in DOMAIN SEARCH WINS; do
+ slxvar="SLX_NET_$var"
+ [ -n "${!slxvar}" ] && seds+=( "s#%${var}%#${!slxvar}#" )
+ [ -z "${!slxvar}" ] && seds+=( "/%${var}%/d" )
+done
+
+( IFS=';' ; sed "${seds[*]}" "${DHCP_NAT_CONF}.template" > "${DHCP_NAT_CONF}.$$" )
# Make sure the primary vm running (we most likely never run more than one at a time anyways) always gets the same ip
echo "static_lease $(echo "$MACADDRPREFIX:$MACADDRSUFFIX" | sed 's/%VMID%/01/') 192.168.101.20" >> "${DHCP_NAT_CONF}.$$"