diff options
author | Simon Rettberg | 2017-02-03 12:22:45 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-02-03 12:22:45 +0100 |
commit | bad5f10d82d1ffb23749bb8267c041380fbab309 (patch) | |
tree | dd24e35d70f24499f6c468e839023c5a8821de8e /core/modules/run-virt/data/opt/openslx/scripts | |
parent | [rfs-s32] copy /usr/lib/ssl/openssl.cnf (diff) | |
download | mltk-bad5f10d82d1ffb23749bb8267c041380fbab309.tar.gz mltk-bad5f10d82d1ffb23749bb8267c041380fbab309.tar.xz mltk-bad5f10d82d1ffb23749bb8267c041380fbab309.zip |
[run-virt/dhcp-busybox] Get WINS server from upstream DHCP, pass on to VMs via local DHCPD
Diffstat (limited to 'core/modules/run-virt/data/opt/openslx/scripts')
-rwxr-xr-x | core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env b/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env index f53983ec..68afd189 100755 --- a/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env +++ b/core/modules/run-virt/data/opt/openslx/scripts/systemd-run_virt_env @@ -172,16 +172,30 @@ for wait in 1 1 2 2 3 end; do . /opt/openslx/config done +getips () { + # Output in one line by using echo without quotes + echo $(nslookup "$1" 2>/dev/null | grep -A 3 '^Name:' | grep '^Address .*: ' | awk '{print $3}') +} + # read the DNS configuration and configure the udhcpd [ -z "${SLX_DNS}" ] && SLX_DNS="8.8.8.8 8.8.4.4" [ -z "${SLX_NET_DOMAIN}" ] && SLX_NET_DOMAIN="virtual.site" [ -z "${SLX_NET_SEARCH}" ] && SLX_NET_SEARCH="virtual.site" -sed -i "s#%DNSSERVER%#${SLX_DNS}#;s#%DOMAIN%#${SLX_NET_DOMAIN}#;s#%SEARCH%#${SLX_NET_SEARCH}#" "${DHCP_NAT_CONF}" +# 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 +[ -z "${SLX_NET_WINS}" ] && SLX_NET_WINS=$(getips "$SLX_NET_DOMAIN") +[ -z "${SLX_NET_WINS}" ] && SLX_NET_WINS="0.0.0.0" +sed -i "s#%DNSSERVER%#${SLX_DNS}#;s#%DOMAIN%#${SLX_NET_DOMAIN}#;s#%SEARCH%#${SLX_NET_SEARCH}#;s#%WINS%#${SLX_NET_WINS}#" "${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}" mkdir -p /var/lib/udhcpd +# TODO: systemd udhcpd -S "${DHCP_NAT_CONF}" # creating and configuring vsw2 |