X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=initscripts%2Fpl_netinit;h=9ebc18202a7fdd27b6ae8874106713229de6af74;hb=07fee163dd47c168fe628ae417f3c1a6abb89a7c;hp=ae9dbeae172a965241ec8d2943385d6d67f79d11;hpb=ed5ce94453595611f867aa26801094938cc690bd;p=bootcd.git diff --git a/initscripts/pl_netinit b/initscripts/pl_netinit index ae9dbea..9ebc182 100755 --- a/initscripts/pl_netinit +++ b/initscripts/pl_netinit @@ -20,7 +20,7 @@ CD_NET_CONF_BOOT=/usr/boot/$NEW_NODE_CONF_NAME # the other location of cd-based network configuration file CD_NET_CONF_ROOT=/usr/$NEW_NODE_CONF_NAME -# if all other network configuration file sources +# if all other network configuration file sources # don't exist, fall back to this one (always on the cd) FALLBACK_NET_CONF=/usr/boot/default-node.txt @@ -66,14 +66,14 @@ function net-init-failed() { } # find and parse a node network configuration file. return 0 if not found, -# return 1 if found and parsed. if this is the case, DEFAULT_NET_CONF will +# return 1 if found and parsed. if this is the case, DEFAULT_NET_CONF will # be set to 1. For any found configuration file, $USED_NET_CONF will # contain the validated contents function find-node-config() { /bin/rm -f $TMP_OLD_FLOPPY_CONF_FILE 2>&1 > /dev/null verbose-message "pl_netinit: looking for node configuration file on floppy" - + /bin/mount -o ro -t $NODE_CONF_DEVICE_FS_TYPES /dev/fd0 \ $CONF_DEVICE_MOUNT_POINT 2>&1 > /dev/null if [[ $? -eq 0 ]]; then @@ -103,7 +103,7 @@ function find-node-config() { verbose-message "pl_netinit: no floppy could be mounted, continuing search." fi - # 2. check for a new named file on removable flash devices (those + # 2. check for a new named file on removable flash devices (those # that start with sd*, because usb_storage emulates scsi devices). # to prevent checking normal scsi disks, also make sure # /sys/block//removable is set to 1 @@ -136,7 +136,7 @@ function find-node-config() { /bin/umount $CONF_DEVICE_MOUNT_POINT return 1 fi - + verbose-message "pl_netinit: ERROR - not found" /bin/umount $CONF_DEVICE_MOUNT_POINT @@ -160,17 +160,17 @@ function find-node-config() { # 4. check for plnode.txt on the cd at /usr/boot verbose-message "pl_netinit: looking for network configuration on cd in /usr/boot" if [ -r "$CD_NET_CONF_BOOT" ]; then - + verbose-message "pl_netinit: found cd configuration file $CD_NET_BOOT_CONF" /etc/init.d/pl_validateconf < $CD_NET_CONF_BOOT > $USED_NET_CONF return 1 fi - + # 5. check for plnode.txt on the cd at /usr verbose-message "pl_netinit: looking for network configuration on cd in /usr" if [ -r "$CD_NET_CONF_ROOT" ]; then - + verbose-message "pl_netinit: found cd configuration file $CD_NET_CONF_ROOT" /etc/init.d/pl_validateconf < $CD_NET_CONF_ROOT > $USED_NET_CONF return 1 @@ -194,7 +194,8 @@ function find-node-config() { verbose-message "pl_netinit: bringing loopback network device up" -/sbin/ifconfig lo 127.0.0.1 up +ip address add dev lo 127.0.0.1/8 +ip link set lo up find-node-config if [ $? -eq 0 ]; then @@ -206,7 +207,7 @@ if [ $? -eq 0 ]; then fi # load the configuration file. if it was a default one (not user specified), -# then remove the saved copy from /tmp, but continue on. since a network +# then remove the saved copy from /tmp, but continue on. since a network # configuration file is required and boot scripts only know about this location # they will fail (as they should) - but the network will be up if dhcp is # available @@ -274,29 +275,18 @@ fi # within a systemd-driven startup, we often see this stage # triggered before the network interface is actually exposed # by udev/kernel -# although of course we have network-online.target -# as a requirement; go figure what systemd actually does.. - -# in any case, let us try to work around that by allowing some delay -# here - -# tmp: Thierry June 2015 -# on fedora 21 nodes we see this running in a context where eth0 is not known to the system -# could be related to a dependency that we poorly describe to systemd -# I am increasing this timeout to 1 minute in order to check that conjecture -ALLOW=60 +# so allow for some small delay here +ALLOW=10 COUNTER=0 while true; do - if /sbin/ifconfig $ETH_DEVICE >& /dev/null; then - verbose-message "pl_netinit: device present $ETH_DEVICE, proceeding (${COUNTER}s/${ALLOW}s)" - break + ### check if the interface is known + # instead of using ifconfig, check the kernel area + if [ -e /sys/class/net/$ETH_DEVICE ]; then + verbose-message "pl_netinit: device present $ETH_DEVICE" + break fi verbose-message "pl_netinit: waiting for device $ETH_DEVICE - ${COUNTER}s/${ALLOW}s" - set -x - /sbin/ifconfig - journalctl -b | egrep 'eth|bnx|udev' - systemctl list-unit-files | grep -i network - set +x + sleep 1 COUNTER=$(($COUNTER+1)) [ $COUNTER -ge $ALLOW ] && net-init-failed sleep 1 @@ -305,7 +295,7 @@ done # actually check to make sure ifconfig succeeds -/sbin/ifconfig $ETH_DEVICE up 2>&1 > /dev/null || { +/usr/libexec/nm-ifup $ETH_DEVICE >& /dev/null || { verbose-message "pl_netinit: device $ETH_DEVICE does not exist, most likely" verbose-message "pl_netinit: this CD does not have hardware support for your" verbose-message "pl_netinit: network adapter. please send the following lines"