Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #/bin/bash
- . "/etc/CFG_FULL.cfg"
- cd $pwd/vlan
- while read IP
- do
- PORTOV=$($VARSNMPGET -v2c -c $CommunityRO $IP iso.3.6.1.2.1.17.1.2.0 | awk '{print $4}')
- HW=$($VARSNMPGET -v2c -c $CommunityRO $IP iso.3.6.1.2.1.16.19.3.0 | awk '{ print $4 }' | sed -e "s/\"//g")
- if [ "$HW" = "A1" -o "$HW" = "B1" ]
- then
- 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")
- elif [ "$HW" = "C1" -o "$HW" = "A3" ]
- then
- 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")
- fi
- cat tmp/top.exp > tmp/$IP.exp
- echo "send \"create vlan v100 tag 100\r\"" >> tmp/$IP.exp
- echo "expect \"*#\"" >> tmp/$IP.exp
- if [ "$PORTOV" = "28" ]
- then
- echo "send \"config vlan vlanid 100 add u 25-28\r\"" >> tmp/$IP.exp
- echo "expect \"*#\"" >> tmp/$IP.exp
- elif [ "$PORTOV" = "52" ]
- then
- echo "send \"config vlan vlanid 100 add u 49-52\r\"" >> tmp/$IP.exp
- echo "expect \"*#\"" >> tmp/$IP.exp
- elif [ "$PORTOV" = "26" ]
- then
- echo "send \"config vlan vlanid 100 add u 25-26\r\"" >> tmp/$IP.exp
- echo "expect \"*#\"" >> tmp/$IP.exp
- elif [ "$PORTOV" = "10" ]
- then
- echo "send \"config vlan vlanid 100 add u 9-10\r\"" >> tmp/$IP.exp
- echo "expect \"*#\"" >> tmp/$IP.exp
- else
- echo "Port XZ" > error.log
- fi
- ports=$(cat log/"$IP"_port.log | awk -F";" '{ for(i = 2; i <= NF; i++) { printf("%s ", $i); } }')
- for i in $ports
- do
- cat log/"$IP"_*tag.txt | grep -w "$i" | sed -e "s/TAG\://g" | awk -F"," '{print $1}' | sort -n | uniq > tmp/vlans.tmp
- #cat log/"$IP"_*tag.txt | grep -w "$i" | sed -e "s/TAG\://g" | awk -F"," '{print $1}' | sort -n | uniq
- while read vlanid
- do
- echo "send \"config vlan vlanid $vlanid delete $i\r\"" >> tmp/$IP.exp
- echo "expect \"*#\"" >> tmp/$IP.exp
- echo "send \"config vlan vlanid 100 add u $i\r\"" >> tmp/$IP.exp
- echo "expect \"*#\"" >> tmp/$IP.exp
- done < tmp/vlans.tmp
- echo "send \"config igmp_snooping multicast_vlan $ip_tv delete tag_member_port $i\r\"" >> tmp/$IP.exp
- echo "expect \"*#\"" >> tmp/$IP.exp
- echo "send \"config igmp_snooping multicast_vlan $ip_tv add member_port $i\r\"" >> tmp/$IP.exp
- echo "expect \"*#\"" >> tmp/$IP.exp
- done
- echo "send \"disable gvrp\r\"" >> tmp/$IP.exp
- echo "expect \"*#\"" >> tmp/$IP.exp
- echo "send \"config gvrp all state disable acceptable_frame admit_all\r\"" >> tmp/$IP.exp
- echo "expect \"*#\"" >> tmp/$IP.exp
- cat tmp/bottom.exp >> tmp/$IP.exp
- done < $pwd/db_ip_test.txt
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement