forked from crowbar/crowbar
/
bootif
24 lines (24 loc) · 864 Bytes
/
bootif
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/sh
export DEBIAN_FRONTEND=none
. /usr/share/debconf/confmodule
bootif=`sed 's/.*BOOTIF=\([-a-z0-9]*\).*/\1/; t; d' /proc/cmdline`
if [ "$bootif" ]; then
interface_found=""
# bootif is 01-00-19-b9-e1-c6-94, convert to MAC
mac=${bootif#01-}
mac=`echo $mac | sed 's/-/:/g'`
log-output -t ethdetect echo "Found bootif $bootif, looking for MAC $mac"
cd /sys/class/net
for interface in *; do
if [ `cat $interface/address` = "$mac" ]; then
log-output -t ethdetect echo "Found matching interface $interface"
interface_found=$interface
db_set netcfg/choose_interface $interface
# must mark question as seen otherwise you are reprompted
db_fset netcfg/choose_interface seen true
fi
done
if [ ! "$interface_found" ]; then
log-output -t ethdetect echo "No matching interface for MAC $mac"
fi
fi