diff options
Diffstat (limited to 'modules.d/slx-network/scripts/setup-bootif-network.stage4')
-rwxr-xr-x | modules.d/slx-network/scripts/setup-bootif-network.stage4 | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/modules.d/slx-network/scripts/setup-bootif-network.stage4 b/modules.d/slx-network/scripts/setup-bootif-network.stage4 new file mode 100755 index 00000000..61f925d0 --- /dev/null +++ b/modules.d/slx-network/scripts/setup-bootif-network.stage4 @@ -0,0 +1,56 @@ +#!/bin/bash +# +# This script sets up the main network interface we booted from, +# as designated by SLX_PXE_NETIF in /opt/openslx/config +# It will run on either the bridge (SLX_BRIDGE is set) or the +# physical interface directly. + +export PATH=$PATH:/opt/openslx/sbin:/opt/openslx/bin + +. /opt/openslx/config + +if [ -z "$SLX_PXE_NETIF" ]; then + echo "Missing network information of the main boot interface." + exit 1 +fi + +MAIN_NETIF="$SLX_PXE_NETIF" +[ -n "$SLX_VLAN_ID" ] && MAIN_NETIF="${SLX_PXE_NETIF}.${SLX_VLAN_ID}" +[ -n "$SLX_BRIDGE" ] && MAIN_NETIF="${SLX_BRIDGE}" +readonly MAIN_NETIF + +# set default options +declare -a udhcpc_opts +udhcpc_opts+=("-t" "8") +udhcpc_opts+=("-O" "domain") +udhcpc_opts+=("-O" "nissrv") +udhcpc_opts+=("-O" "nisdomain") +udhcpc_opts+=("-O" "wpad") +udhcpc_opts+=("-O" "search") +udhcpc_opts+=("-O" "wins") + +# send machine uuid during DHCP if configured +if [ "$SLX_NET_DHCP_UUID" = "yes" ]; then + uid=$(dmidecode -s system-uuid | \ + sed -r 's/^(..)(..)(..)(..)-(..)(..)-(..)(..)-(....)-/00\4\3\2\1\6\5\8\7\9/') + if [ "${#uid}" = 34 ]; then + echo "Using SMBIOS uid for DHCP" + udhcpc_opts+=( "-x" "0x3d:$uid" ) + fi +fi + +mkdir -p /run/udhcpc || echo "Could not create '/run/udhcpc'." + +udhcpc "${udhcpc_opts[@]}" \ + -i "$MAIN_NETIF" \ + -r "${SLX_PXE_CLIENT_IP}" \ + -s /opt/openslx/scripts/udhcpc-trigger \ + -p "/run/udhcpc/udhcpc.${MAIN_NETIF}.pid" +ret=$? + +if [ "${ret}" != 0 ]; then + echo "udhcpc" "Could not run 'udhcpc ${udhcpc_opts[*]}' on ${MAIN_NETIF}." +fi + +exit "${ret}" + |