Advertisement
iklio

Untitled

Oct 14th, 2013
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.74 KB | None | 0 0
  1. ----------------------------------------
  2. Script that adds another route to internet. Add table "admin" to /etc/iproute2/rt_tables once before running the script the first time. Here, 10.0.0.138 is the router, eth0 is the network device that connects to the secondary route.
  3. ----------------------------------------
  4.  
  5. #!/bin/bash
  6. #Add table "admin" to /etc/iproute2/rt_tables
  7. myotherdevice=eth0
  8. myothernetwork=10.0.0
  9. myothergateway=10.0.0.138
  10. myotherip=$(ifconfig | grep $myothernetwork | cut -d: -f2 | cut -f1 -d' ')
  11. ip route add ${myothernetwork}.0/24 dev $myotherdevice src $myotherip table admin
  12. ip route add default via $myothergateway dev $myotherdevice table admin
  13. ip rule add from ${myotherip}/32 table admin
  14. ip rule add to ${myotherip}/32 table admin
  15. ip route flush cache
  16.  
  17.  
  18. ----------------------------------------
  19. Script that downloads a directory using rsync, with resume.
  20. ----------------------------------------
  21.  
  22. #!/bin/bash
  23. while [ 1 ]
  24. do
  25.     rsync -avrvv --size-only --partial --progress username@host:/source_dir destination_dir
  26.     if [ "$?" = "0" ] ; then
  27.         echo "Rsync completed normally."
  28.         exit
  29.     else
  30.         echo "Rsync failed. Retrying in 3 minutes."
  31.         sleep 180
  32.     fi
  33. done
  34.  
  35. ----------------------------------------
  36. Same, but binds the connection to the other interface/route (10.0.0.2 is the assigned ip).
  37. ----------------------------------------
  38.  
  39. #!/bin/bash
  40.  
  41. while [ 1 ]
  42. do
  43.     rsync --address=10.0.0.2 -avrvv --size-only --partial --progress -e 'ssh -oBindAddress=10.0.0.2' username@host:/source_dir destination_dir
  44.     if [ "$?" = "0" ] ; then
  45.         echo "Rsync completed normally."
  46.         exit
  47.     else
  48.         echo "Rsync failed. Retrying in 3 minutes."
  49.         sleep 180
  50.     fi
  51. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement