summaryrefslogtreecommitdiffstats
path: root/core/modules/run-virt/data/opt/openslx/scripts/runvirt-start_dhcpd
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/run-virt/data/opt/openslx/scripts/runvirt-start_dhcpd')
-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}.$$"