performs various sanity checks at network init and if curl fails
authorThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 14 Jan 2011 13:23:24 +0000 (14:23 +0100)
committerThierry Parmentelat <thierry.parmentelat@sophia.inria.fr>
Fri, 14 Jan 2011 13:23:24 +0000 (14:23 +0100)
initscripts/pl_boot
initscripts/pl_functions [new file with mode: 0644]
initscripts/pl_netinit
initscripts/pl_sysinit
prep.sh

index 6541dec..ce685c9 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/bash
 
+. /etc/init.d/pl_functions
+
 . /tmp/planet.cnf
 
 # Run gpg once to create default options
@@ -168,11 +170,6 @@ while : ; do
                     echo $(date "+%H:%M:%S") " we recommend checking your DNS settings.  If you cannot, then "
                     echo $(date "+%H:%M:%S") " please double check your network settings registered at PLC and "
                     echo $(date "+%H:%M:%S") " stored on this Boot Image."
-                    for file in $(ls /etc/sysconfig/network-scripts/ifcfg-eth* /etc/resolv.conf) ; do 
-                        echo $(date "+%H:%M:%S") contents of $file :
-                        cat $file
-                        echo $(date "+%H:%M:%S") end of $file :
-                    done
                 ;;
                 60)
                     echo $(date "+%H:%M:%S") " This error likely indicates that the hardware clock is likely not set "
@@ -188,6 +185,9 @@ while : ; do
                     echo $(date "+%H:%M:%S") " with as much detail as possible."
                 ;;
             esac
+           # in any case display as much info as we can (see pl_functions)
+           pl_network_sanity_checks
+           # retry
             continue
         fi
     elif [ -n "$DISCONNECTED_OPERATION" ]; then
diff --git a/initscripts/pl_functions b/initscripts/pl_functions
new file mode 100644 (file)
index 0000000..040a37a
--- /dev/null
@@ -0,0 +1,40 @@
+#-*-shell-script-*-
+
+function verbose_show_message () {
+    echo $(date "+%H:%M:%S") " ==================== " "$@"
+}
+
+function verbose_run_command () {
+    echo $(date "+%H:%M:%S") " ========== running" "$@"
+    "$@"
+    echo $(date "+%H:%M:%S") " ==========" "$@" "returned with retcod=$?"
+}
+
+function pl_network_sanity_checks () {
+    echo $(date "+%H:%M:%S") " ======================================== BEG SANITY CHECKS"
+    for file in $(ls /etc/resolv.conf /etc/sysconfig/network-scripts/ifcfg-eth* ) ; do 
+       verbose_run_command cat $file
+    done
+    verbose_show_message Loaded modules
+    verbose_run_command lsmod
+    verbose_show_message Configured interfaces
+    verbose_run_command ifconfig
+    verbose_show_message Routing table
+    verbose_run_command netstat -rn
+    verbose_show_message Pinging google public DNS 
+    verbose_run_command ping -c 1 -w 5 8.8.8.8
+    # try to resolve this hostname as that's the one used for ntp
+    dnss=$(grep '^nameserver' /etc/resolv.conf 2>/dev/null | awk '{print $2;}')
+    if [ -z "$dnss" ] ; then
+       # not too helpful, but..
+       verbose_show_message No server found in /etc/resolv.conf - Resolving hostname at the google public DNS
+       verbose_run_command host -W 4 pool.ntp.org 8.8.8.8
+    else
+       for dns in $dnss; do
+           verbose_show_message Resolving hostname at $dns
+           verbose_run_command host -W 4 pool.ntp.org $dns
+       done
+    fi
+    echo $(date "+%H:%M:%S") " ======================================== END SANITY CHECKS"
+}
+
index 914d091..afd4c03 100755 (executable)
@@ -1,4 +1,5 @@
 #!/bin/sh
+#-*-shell-script-*-
 
 # the name of the floppy based network configuration
 # files (checked first). the name planet.cnf is kept
index aa5bb52..4f5d2ac 100755 (executable)
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+. /etc/init.d/pl_functions
+
 echo ""
 echo "PlanetLab BootCD - distro @PLDISTRO@ based on @FCDISTRO@"
 
@@ -148,6 +150,9 @@ echo ""
 echo $(date "+%H:%M:%S") "pl_sysinit: bringing network online"
 /etc/init.d/pl_netinit
 
+# just in case, sometimes we're seeing weird stuff already at this point
+pl_network_sanity_checks
+
 echo ""
 echo $(date "+%H:%M:%S") "pl_sysinit: attempting to sync clock"
 /usr/sbin/ntpdate -b -t 10 -u pool.ntp.org
diff --git a/prep.sh b/prep.sh
index f25e390..4d45e76 100755 (executable)
--- a/prep.sh
+++ b/prep.sh
@@ -58,7 +58,7 @@ install -D -m 755 ipnmac/ipnmac.x86 $bootcd/usr/sbin/ipnmac
 
 # Install initscripts
 echo "* Installing initscripts"
-for file in pl_sysinit pl_hwinit pl_netinit pl_validateconf pl_boot ; do
+for file in pl_functions pl_sysinit pl_hwinit pl_netinit pl_validateconf pl_boot ; do
     sed -i -e "s,@PLDISTRO@,$pldistro,g" -e "s,@FCDISTRO@,$fcdistro,g" initscripts/$file
     install -D -m 755 initscripts/$file $bootcd/etc/init.d/$file
 done