aboutsummaryrefslogtreecommitdiff
path: root/fai/config/scripts/LAST/90-show-network-cards
blob: 2b3f85c69db0d37eac2e1f4739a5ea18e2cefc90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#! /bin/bash

if [ X$FAI_ACTION = Xinstall -o X$FAI_ACTION = X ]; then
    :
else
    return 0
fi
if [ X$action = Xdirinstall ]; then
    return 0
fi

grep -q INSTALL $LOGDIR/FAI_CLASSES || return 0
[ "$flag_menu" ] || return 0

NETDEVS=$(LANG=C ip a | grep -E "^[0-9]+:" | grep -v "lo:" | sed -r -e 's/[0-9]+:\ ([^:]+):.*/\1/')

NETDEVINFO=""
for dev in $NETDEVS; do
	mac=$(LANG=C ip -o l show $dev | grep "link/ether" | sed -r -e 's/.*link\/ether\ ([^\ ]+)\ .*/\1/')
	NETDEVINFO="$NETDEVINFO\nDevice: $dev\nMAC-Address: $mac\n\n"
done

out=$(tty)
blue=$(mktemp)
echo 'screen_color = (CYAN,BLUE,ON)' > $blue

DIALOGRC=$blue dialog --colors \
                     --clear \
                     --aspect 6 \
                     --title "FAI - Fully Automatic Installation" \
                     --trim \
                     --msgbox "\n\nHostname: $HOSTNAME\n\nYour network cards are:\n
$NETDEVINFO\n\n" 0 0 1>$out

# stop on any error, or if ESC was hit
if [ $? -ne 0 ]; then
    task_error 999
fi

rm $blue
unset blue