#!/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" "1") udhcpc_opts+=("-A" "5") udhcpc_opts+=("-t" "8") udhcpc_opts+=("-O" "hostname") 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}"