diff options
author | Simon Rettberg | 2019-10-28 11:33:02 +0100 |
---|---|---|
committer | Simon Rettberg | 2019-10-28 11:33:02 +0100 |
commit | 01f8b005ca8fd211b43fdace4a7c86e1fac5ab3d (patch) | |
tree | 6723d2b9c77ce5af25fb4eb899ca89679e89acd2 /core | |
parent | [vmware-common] Remove any existing usb autoconnect entries (diff) | |
download | mltk-01f8b005ca8fd211b43fdace4a7c86e1fac5ab3d.tar.gz mltk-01f8b005ca8fd211b43fdace4a7c86e1fac5ab3d.tar.xz mltk-01f8b005ca8fd211b43fdace4a7c86e1fac5ab3d.zip |
[run-virt] Make dhcpd its own service
Diffstat (limited to 'core')
4 files changed, 25 insertions, 18 deletions
diff --git a/core/modules/run-virt/data/etc/systemd/system/graphical.target.wants/run-virt-dhcpd.service b/core/modules/run-virt/data/etc/systemd/system/graphical.target.wants/run-virt-dhcpd.service new file mode 120000 index 00000000..a47d9c0b --- /dev/null +++ b/core/modules/run-virt/data/etc/systemd/system/graphical.target.wants/run-virt-dhcpd.service @@ -0,0 +1 @@ +../run-virt-dhcpd.service
\ No newline at end of file diff --git a/core/modules/run-virt/data/etc/systemd/system/run-virt-dhcpd.service b/core/modules/run-virt/data/etc/systemd/system/run-virt-dhcpd.service new file mode 100644 index 00000000..7453e85b --- /dev/null +++ b/core/modules/run-virt/data/etc/systemd/system/run-virt-dhcpd.service @@ -0,0 +1,9 @@ +[Unit] +Description=DHCP server for VM NAT network +Wants=run-virt-env.service +After=run-virt-env.service + +[Service] +ExecStart=/opt/openslx/sbin/udhcpd -f /opt/openslx/vmchooser/config/udhcpd-nat1.conf +Restart=on-failure +RestartSec=3 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 8306c2b1..30a37fb1 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 @@ -32,6 +32,7 @@ export PATH=$PATH:/opt/openslx/bin:/opt/openslx/sbin VMCHOOSER_DIR="/opt/openslx/vmchooser" VMCHOOSER_CONF_DIR="${VMCHOOSER_DIR}/config" VMCHOOSER_VIRT_CONF="${VMCHOOSER_CONF_DIR}/virtualization.conf" +# Same as in service file for udhcpd DHCP_NAT_CONF="${VMCHOOSER_CONF_DIR}/udhcpd-nat1.conf" # setup more scratch space for virtual machines, if configured @@ -209,16 +210,25 @@ if [ -z "${SLX_NET_WINS}" ]; then [ -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" +for ips in $SLX_NTP_SERVER; do + if ! printf "%s" "$ips" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then + ips="$( getips "$ips" )" + [ -z "$ips" ] && continue + fi + 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 -i "s#%DNSSERVER%#${SLX_DNS}#;s#%DOMAIN%#${SLX_NET_DOMAIN}#;s#%SEARCH%#${SLX_NET_SEARCH}#;s#%WINS%#${SLX_NET_WINS}#" "${DHCP_NAT_CONF}" +sed "s#%DNSSERVER%#${SLX_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}" # 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 brctl addbr vsw2 diff --git a/core/modules/run-virt/data/opt/openslx/vmchooser/config/udhcpd-nat1.conf b/core/modules/run-virt/data/opt/openslx/vmchooser/config/udhcpd-nat1.conf index f3a6fbe0..19731d80 100644 --- a/core/modules/run-virt/data/opt/openslx/vmchooser/config/udhcpd-nat1.conf +++ b/core/modules/run-virt/data/opt/openslx/vmchooser/config/udhcpd-nat1.conf @@ -32,7 +32,7 @@ offer_time 6000 lease_file /var/lib/udhcpd/udhcpd-nat1.leases # location of the pid file -pidfile /var/run/udhcpd-nat1.pid +pidfile /run/udhcpd-nat1.pid option dns %DNSSERVER% option subnet 255.255.255.0 @@ -41,18 +41,5 @@ option wins %WINS% option domain %DOMAIN% option search %SEARCH% option lprsrv 192.168.101.1 -#option ntpsrv NTPSERVER - -# additional options known to udhcpd not used in OpenSLX at the moment -#subnet #timezone -#router #timesvr -#namesvr #dns -#logsvr #cookiesvr -#lprsvr #bootsize -#domain #swapsvr -#rootpath #ipttl -#mtu #broadcast -#wins #lease -#ntpsrv #tftp -#bootfile #wpad +option ntpsrv %NTPSERVER% |