e2d24c1571070c3592beca203516bbddb62e1eea
[bootcd.git] / initscripts / pl_functions
1 #-*-shell-script-*-
2
3 function verbose_show_message () {
4     echo $(date "+%H:%M:%S") " ==================== " "$@"
5 }
6
7 function verbose_run_command () {
8     echo $(date "+%H:%M:%S") " ========== running" "$@"
9     "$@"
10     echo $(date "+%H:%M:%S") " ==========" "$@" "returned with retcod=$?"
11 }
12
13 function pl_network_sanity_checks () {
14     echo $(date "+%H:%M:%S") " ======================================== BEG SANITY CHECKS"
15     for file in $(ls /etc/resolv.conf /etc/sysconfig/network-scripts/ifcfg-eth* ) ; do 
16         verbose_run_command cat $file
17     done
18     verbose_show_message Loaded modules
19     verbose_run_command lsmod
20     verbose_show_message Configured interfaces
21     verbose_run_command ifconfig
22     verbose_show_message cat /proc/net/dev
23     verbose_run_command cat /proc/net/dev
24     verbose_show_message Routing table
25     verbose_run_command netstat -rn
26     BOOT_FILE=/usr/boot/boot_server
27     BOOT_SERVER=$(cat $BOOT_FILE)
28     verbose_show_message Pinging boot server "(" $BOOT_SERVER ")" from file $BOOT_FILE
29     verbose_run_command ping -c 4 -w 4 $BOOT_SERVER
30     verbose_show_message Pinging google public DNS 
31     verbose_run_command ping -c 1 -w 5 8.8.8.8
32     # try to resolve this hostname as that's the one used for ntp
33     dnss=$(grep '^nameserver' /etc/resolv.conf 2>/dev/null | awk '{print $2;}')
34     if [ -z "$dnss" ] ; then
35         # not too helpful, but..
36         verbose_show_message No server found in /etc/resolv.conf - Resolving hostname at the google public DNS
37         verbose_run_command host -W 4 pool.ntp.org 8.8.8.8
38     else
39         for dns in $dnss; do
40             verbose_show_message Resolving hostname at $dns
41             verbose_run_command host -W 4 pool.ntp.org $dns
42         done
43     fi
44     echo $(date "+%H:%M:%S") " ======================================== END SANITY CHECKS"
45 }
46