Skip to content

Commit

Permalink
move code from subroutines to get-boot-info
Browse files Browse the repository at this point in the history
the code tries to determine NIC1 and waits for an interface to come
up, now we have two loops that wais for the interfaces to come
up. I guess this not needed twice and should be cleanup up
  • Loading branch information
Thomas Lange committed Oct 24, 2017
1 parent d2a23b9 commit 11f0e00
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 14 additions & 0 deletions lib/get-boot-info
Expand Up @@ -74,6 +74,19 @@ setnet() {
n=$(($n + 1))
done

# determine the name of the default network interface
# try several times if dhclient needs some more time
local i=0
NIC1=$(ip route | awk '/^default/ {print $5}')
while [ ! "$NIC1" -a $i -lt 8 ]; do
sleep 2
NIC1=$(ip route | awk '/^default/ {print $5}')
(( i += 1 ))
done
if [ -z "$NIC1" ]; then
NIC1=$(ip route | awk '/ dev / {print $3}')
fi

read IPADDR NETMASK BROADCAST dummy<<<$(ifdata -p $dev)
CIDR=$(ip -o -f inet addr show| awk '{print $4}'| grep $IPADDR)
GATEWAYS=$(ip route | awk '/^default/ {print $3}')
Expand All @@ -88,6 +101,7 @@ setnet() {
GATEWAYS=$GATEWAYS
BROADCAST=$BROADCAST
CIDR=$CIDR
NIC1=$NIC1
EOF

if [ -n "$DOMAIN" ]; then
Expand Down
14 changes: 0 additions & 14 deletions lib/subroutines
Expand Up @@ -841,20 +841,6 @@ task_confdir() {
fi
define_fai_flags

# determine the name of the default network interface
# try several times if dhclient needs some more time
local i=0
NIC1=$(ip route | awk '/^default/ {print $5}')
while [ ! "$NIC1" -a $i -lt 8 ]; do
sleep 2
NIC1=$(ip route | awk '/^default/ {print $5}')
(( i += 1 ))
done
if [ -z "$NIC1" ]; then
NIC1=$(ip route | awk '/ dev / {print $3}')
fi
export NIC1

if [ -z "$SERVER" ]; then
# since SERVER is not set (by DHCP) we extract it from FAI_CONFIG_SRC
# extract server name from FAI_CONFIG_SRC and delete user@ from string
Expand Down

0 comments on commit 11f0e00

Please sign in to comment.