pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

Bash pastebin - collaborative debugging tool View Help


Posted by smok on Mon 11 May 06:10
report abuse | download | new post

  1. #!/bin/sh
  2.  
  3. # interface
  4. dev1=eth1
  5. # gateway
  6. p1=provider_1_gateway
  7. name1=provider_1_name
  8.  
  9. dev2=eth2
  10. p2=provider_2_gateway
  11. name2=provider_2_name
  12.  
  13. test_host=91.194.(hidden digits).129
  14. ping_c=3
  15. ip=/sbin/ip
  16.  
  17. test1=`ping -I $dev1 -c $ping_c $test_host | grep "64 bytes" | wc -l`
  18. test2=`ping -I $dev2 -c $ping_c $test_host | grep "64 bytes" | wc -l`
  19.  
  20. cur_date=`date "+%Y %b %d %H:%M"`
  21.  
  22. $ip route del default
  23.  
  24. if [ $test1 -gt 0 ]; then
  25.         if [ $test2 -gt 0 ]; then
  26.                 echo "$cur_date all links is Ok"
  27.                 $ip route add default scope global nexthop via $p1 dev $dev1 weight 1 nexthop via $p2 dev $dev2 weight 1
  28.         else
  29.                 echo "$cur_date link to $name2 is down"
  30.                 $ip route add default scope global nexthop via $p1 dev $dev1
  31.         fi
  32. else
  33.         if [ $test2 -gt 0 ]; then
  34.                 echo "$cur_date link to $name1 is down"
  35.                 $ip route add default scope global nexthop via $p2 dev $dev2
  36.         else
  37.                 echo "$cur_date all links is down"
  38.                 $ip route add default scope global nexthop via $p1 dev $dev1 weight 1 nexthop via $p2 dev $dev2 weight 1
  39.         fi
  40. fi

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me so that I can delete my post