How to detect when networking initialized in /etc/init.d script on redhat 6 -
i have init.d script start process on boot , requires networking initialized. can use utility nm-online comes networkmanager package problem @ deployment nw not installed have have other reliable option can tell me network set , can connect other server on network. can keep trying till networking or connection set cause other problem related error reporting.
here similar question asked other folk.
how detect when networking initialized in /etc/init.d script?
wait_for_network() { [ -z "${linkdelay}" ] && linkdelay=10 $info "waiting network..." if [ -f /usr/sbin/nm-online ]; nm-online -q --timeout=$linkdelay || nm-online -q -x --timeout=30 else check_for_network_up $linkdelay || check_for_network_up 30 fi [ "$?" = "0" ] && success "network startup" || failure "network startup" echo }
i trying other approach can check route table. if network not up, route command return 0 entry problem don’t know real number of route entry. 2 on 1 machine 10 on other machine.
check_for_network_up_old3() { let no_of_routes=`/bin/netstat -rn | wc -l` $info "netstat result $?" timeout=$1 while [ "$timeout" != "0" ]; let routes=`/sbin/ip route show | wc -l` $info "$routes" if [ $routes -gt 1 ]; return 0 fi timeout=$((timeout-1)) sleep 1 $info "check_for_network_up $timeout" done return 1 }
Comments
Post a Comment