Opensuseマルチラインルーティングスクリプトの追加


Opensuseマルチラインルーティングスクリプトの追加

  
  
  
  
  1. #!/bin/bash 
  2. #author itnihao 
  3. #bolg  http://itnihao.blog.51cto.com 
  4.  
  5.  
  6. green='\e[0;32m' 
  7. red='\e[0;31m' 
  8. blue='\e[0;36m' 
  9. blue1='\e[5;31m' 
  10. NC='\e[0m' 
  11. mkdir route 
  12. cd route 
  13. echo -e "${green} ${blue1}..........." 
  14. wget http://www.tcp5.com/routingtable/telecom.rsc >/dev/null 2>&1 
  15. wget http://www.tcp5.com/routingtable/unicom.rsc >/dev/null 2>&1 
  16. wget http://www.tcp5.com/routingtable/mobile.rsc >/dev/null 2>&1 
  17. wget http://www.tcp5.com/routingtable/cernet.rsc >/dev/null 2>&1 
  18. wget http://www.tcp5.com/routingtable/other.rsc >/dev/null 2>&1 
  19. awk -F "=" '{print $5}' telecom.rsc |sed -e "s/ table//g" -e "/^$/d" >telecom.ip 
  20. awk -F "=" '{print $5}' unicom.rsc |sed -e "s/ table//g" -e "/^$/d" >unicom.ip 
  21. awk -F "=" '{print $5}' mobile.rsc |sed -e "s/ table//g" -e "/^$/d" >mobile.ip 
  22. awk -F "=" '{print $5}' cernet.rsc|sed -e "s/ table//g" -e "/^$/d" >cernet.ip 
  23. awk -F "=" '{print $5}' other.rsc|sed -e "s/ table//g" -e "/^$/d" >other.ip 
  24. echo -e "${blue}1): :" 
  25. echo -e "${blue}2): :" 
  26. echo -e "${blue}3): :" 
  27. echo -e "${blue}4): :" 
  28. echo -e "${blue}5): :" 
  29. echo -e "${blue}6): :" 
  30. echo -e "${blue}7): :" 
  31. echo -e "${blue}8): :" 
  32. echo -e "${NC} :" 
  33. read NUM 
  34. if [ "${NUM}" -lt "1" -o "${NUM}" -gt "8"  ] 
  35. then 
  36.    echo " 1-8 : " 
  37. elif 
  38.    [ "${NUM}" == "1" ] 
  39. then 
  40.    cp /etc/sysconfig/network/routes /etc/sysconfig/network/routes.default 
  41.    [ "$?" == "0" ] && echo -e "${green}  /etc/sysconfig/network/routes /etc/sysconfig/network/routes.default${NC}"  
  42.    [ "$?" != "0" ] && echo -e "${red}   , /etc/sysconfig/network/routes ${NC}" 
  43. elif 
  44.    [ "${NUM}" == "2" ] 
  45. then    
  46.    [ -f /etc/sysconfig/network/routes.default ]  
  47.    if  [ "$?" == "0" ];then 
  48.    cp /etc/sysconfig/network/routes /etc/sysconfig/network/routes.default1 
  49.    mv /etc/sysconfig/network/routes.default /etc/sysconfig/network/routes 
  50.    echo -e " , /etc/sysconfig/network/routes " 
  51.    else 
  52.    echo -e " /etc/sysconfig/network/routes.default " 
  53.    exit 
  54.    fi 
  55. elif 
  56.    [ "${NUM}" == "3" ] 
  57. then 
  58.    echo "input telecom gateway- :" 
  59.    read telecomgateway 
  60.    echo " ${telecomgateway}, , y " 
  61.    read true 
  62.    [ ${true} != "y" ]  && exit 
  63.    echo " , \"eth2\":" 
  64.    read interface 
  65.    echo " ${interface}, , y " 
  66.    read true 
  67.    [ ${true} != "y" ]  && exit 
  68.    echo "# "  >> /etc/sysconfig/network/routes 
  69.    cat telecom.ip|sed "s/$/ $telecomgateway $interface/g" >> /etc/sysconfig/network/routes 
  70.    echo "# "  >> /etc/sysconfig/network/routes 
  71.    echo " " 
  72. elif 
  73.    [ "${NUM}" == "4" ] 
  74. then 
  75.    echo " :" 
  76.    read unicomgateway 
  77.    echo " ${unicomgateway}, , y " 
  78.    read true 
  79.    [ ${true} != "y" ]  && exit 
  80.    echo " , \"eth2\":" 
  81.    read interface 
  82.    echo " ${interface}, , y " 
  83.    read true 
  84.    [ ${true} != "y" ]  && exit 
  85.    echo "# "  >> /etc/sysconfig/network/routes 
  86.    cat uniccom.ip|sed "s/$/ $unicomgateway $interface/g" >> /etc/sysconfig/network/routes 
  87.    echo "# "  >> /etc/sysconfig/network/routes 
  88.    echo " " 
  89. mobile 
  90. elif 
  91.    [ "${NUM}" == "5" ] 
  92. then 
  93.    echo " :" 
  94.    read mobilegateway 
  95.    echo " ${mobilegateway}, , y " 
  96.    read true 
  97.    [ ${true} != "y" ]  && exit 
  98.    echo " , \"eth2\":" 
  99.    read interface 
  100.    echo " ${interface}, , y " 
  101.    read true 
  102.    [ ${true} != "y" ]  && exit 
  103.    echo "# "  >> /etc/sysconfig/network/routes 
  104.    cat mobile.ip|sed "s/$/ $mobilegateway $interface/g" >> /etc/sysconfig/network/routes 
  105.    echo "# "  >> /etc/sysconfig/network/routes 
  106.    echo " " 
  107.  
  108. elif 
  109.    [ "${NUM}" == "6" ] 
  110. then 
  111.    echo " :" 
  112.    read cernetgateway 
  113.    echo " ${cernetgateway}, , y " 
  114.    read true 
  115.    [ ${true} != "y" ]  && exit 
  116.    echo " , \"eth2\":" 
  117.    read interface 
  118.    echo " ${interface}, , y " 
  119.    read true 
  120.    [ ${true} != "y" ]  && exit 
  121.    echo "# "  >> /etc/sysconfig/network/routes 
  122.    cat cernet.ip|sed "s/$/ $cernetgateway $interface/g" >> /etc/sysconfig/network/routes 
  123.    echo "# "  >> /etc/sysconfig/network/routes 
  124.    echo " " 
  125. elif 
  126.    [ "${NUM}" == "7" ] 
  127. then 
  128.    echo " :" 
  129.    read othergateway 
  130.    echo " ${othergateway}, , y " 
  131.    read true 
  132.    [ ${true} != "y" ]  && exit 
  133.    echo " , \"eth2\":" 
  134.    read interface 
  135.    echo " ${interface}, , y " 
  136.    read true 
  137.    [ ${true} != "y" ]  && exit 
  138.    echo "# "  >> /etc/sysconfig/network/routes 
  139.    cat other.ip|sed "s/$/ $othergateway $interface/g" >> /etc/sysconfig/network/routes 
  140.    echo "# "  >> /etc/sysconfig/network/routes 
  141.    echo " " 
  142. elif 
  143.    [ "${NUM}" == "8" ] 
  144. then 
  145. exit 
  146. fi