Advertisement
Izya12

run_vlan.sh

Apr 6th, 2015
299
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.48 KB | None | 0 0
  1. #/bin/bash
  2. . "/etc/CFG_FULL.cfg"
  3. cd $pwd/vlan
  4.  
  5. while read IP
  6. do
  7. PORTOV=$($VARSNMPGET -v2c -c $CommunityRO $IP iso.3.6.1.2.1.17.1.2.0 | awk '{print $4}')
  8. HW=$($VARSNMPGET -v2c -c $CommunityRO $IP iso.3.6.1.2.1.16.19.3.0 | awk '{ print $4 }' | sed -e "s/\"//g")
  9. if [ "$HW" = "A1" -o "$HW" = "B1" ]
  10. then
  11.   ip_tv=$($VARSNMPWALK -v2c -c $CommunityRO $IP 1.3.6.1.4.1.171.11.113.1.3.2.7.8.1.2 | awk '{ print $4 }' | sed -e "s/\"//g")
  12. elif [ "$HW" = "C1" -o "$HW" = "A3" ]
  13. then
  14.   ip_tv=$($VARSNMPWALK -v2c -c $CommunityRO $IP 1.3.6.1.4.1.171.12.64.3.1.1.2 | awk '{print $4}' | sed -e "s/\"//g")
  15. fi
  16.  
  17.  
  18. cat tmp/top.exp > tmp/$IP.exp
  19. echo "send \"create vlan v100 tag 100\r\"" >> tmp/$IP.exp
  20. echo "expect \"*#\"" >> tmp/$IP.exp
  21.  
  22. if [ "$PORTOV" = "28" ]
  23. then
  24.   echo "send \"config vlan vlanid 100 add u 25-28\r\"" >> tmp/$IP.exp
  25.   echo "expect \"*#\"" >> tmp/$IP.exp
  26. elif [ "$PORTOV" = "52" ]
  27. then
  28.   echo "send \"config vlan vlanid 100 add u 49-52\r\"" >> tmp/$IP.exp
  29.   echo "expect \"*#\"" >> tmp/$IP.exp
  30. elif [ "$PORTOV" = "26" ]
  31. then
  32.   echo "send \"config vlan vlanid 100 add u 25-26\r\"" >> tmp/$IP.exp
  33.   echo "expect \"*#\"" >> tmp/$IP.exp
  34. elif [ "$PORTOV" = "10" ]
  35. then
  36.   echo "send \"config vlan vlanid 100 add u 9-10\r\"" >> tmp/$IP.exp
  37.   echo "expect \"*#\"" >> tmp/$IP.exp
  38. else
  39.   echo "Port XZ" > error.log
  40. fi
  41.  
  42. ports=$(cat log/"$IP"_port.log | awk -F";" '{ for(i = 2; i <= NF; i++) { printf("%s ", $i); } }')
  43. for i in $ports
  44. do
  45.   cat log/"$IP"_*tag.txt | grep -w "$i" |  sed -e "s/TAG\://g" | awk -F"," '{print $1}' | sort -n | uniq > tmp/vlans.tmp
  46.   #cat log/"$IP"_*tag.txt | grep -w "$i" |  sed -e "s/TAG\://g" | awk -F"," '{print $1}' | sort -n | uniq
  47.   while read vlanid
  48.   do
  49.     echo "send \"config vlan vlanid $vlanid delete $i\r\"" >> tmp/$IP.exp
  50.     echo "expect \"*#\"" >> tmp/$IP.exp
  51.     echo "send \"config vlan vlanid 100 add u $i\r\"" >> tmp/$IP.exp
  52.     echo "expect \"*#\"" >> tmp/$IP.exp
  53.   done < tmp/vlans.tmp
  54.   echo "send \"config igmp_snooping multicast_vlan $ip_tv delete tag_member_port $i\r\"" >> tmp/$IP.exp
  55.   echo "expect \"*#\"" >> tmp/$IP.exp
  56.   echo "send \"config igmp_snooping multicast_vlan $ip_tv add member_port $i\r\"" >> tmp/$IP.exp
  57.   echo "expect \"*#\"" >> tmp/$IP.exp
  58. done
  59. echo "send \"disable gvrp\r\"" >> tmp/$IP.exp
  60. echo "expect \"*#\"" >> tmp/$IP.exp
  61. echo "send \"config gvrp all state disable acceptable_frame admit_all\r\"" >> tmp/$IP.exp
  62. echo "expect \"*#\"" >> tmp/$IP.exp
  63. cat tmp/bottom.exp >> tmp/$IP.exp
  64. done < $pwd/db_ip_test.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement