Ubuntu | f6ce96c | 2013-02-07 01:45:07 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | VIP_ONOS1=10.0.1.217 |
| 3 | VIP_ONOS2=10.0.1.176 |
| 4 | VIP_ONOS3=10.0.1.173 |
| 5 | VIP_ONOS4=10.0.1.222 |
| 6 | VIP_ONOS5=10.0.1.191 |
| 7 | VIP_ONOS6=10.0.1.158 |
| 8 | VIP_ONOS9=10.0.1.29 |
| 9 | VIP_ONOS10=10.0.1.28 |
| 10 | VIP_ONOS11=10.0.1.62 |
| 11 | |
| 12 | NW_ID="a" |
| 13 | # [[tap_if_nr, tag, other_end],..] |
| 14 | TUNNEL=("0 1 VIP_ONOS5") |
| 15 | |
| 16 | start () { |
| 17 | ## Modify ## |
| 18 | ulimit -c |
| 19 | for (( i = 0; i< ${#TUNNEL[@]}; i ++)); do |
| 20 | t=`echo ${TUNNEL[$i]}` |
| 21 | ifnr=`echo $t | awk '{print $1}'` |
| 22 | tun_tag=`echo $t | awk '{print $2}'` |
| 23 | tun_end_=`echo $t | awk '{print $3}'` |
| 24 | tun_end=`eval echo '$'$tun_end_` |
| 25 | ifconfig tap${NW_ID}${ifnr} |
| 26 | echo "ifconfig tap${NW_ID}${ifnr}" |
| 27 | if [ $? -ne 0 ]; then |
| 28 | echo "creating tap${NW_ID}${ifnr}" |
| 29 | sudo tunctl |
| 30 | fi |
| 31 | echo "./capsulator -v -d -t eth0 -f ${tun_end} -vb tap${NW_ID}${ifnr}#${tun_tag}" |
| 32 | sudo ifconfig tap${NW_ID}${ifnr} 0.0.0.0 up > /dev/null 2>&1 |
| 33 | sudo ./capsulator -v -d -t eth0 -f ${tun_end} -vb tap${NW_ID}${ifnr}#${tun_tag} > /dev/null 2>&1 & |
| 34 | done |
| 35 | } |
| 36 | |
| 37 | stop () { |
| 38 | sudo pkill capsulator |
| 39 | } |
| 40 | |
| 41 | case "$1" in |
| 42 | start | restart) |
| 43 | stop |
| 44 | start |
| 45 | ;; |
| 46 | stop) |
| 47 | stop |
| 48 | ;; |
| 49 | status) |
| 50 | nr=`pgrep capsulator | wc -l` |
| 51 | if [ $nr -gt 0 ]; then |
| 52 | echo "$nr tunnel(s) is running" |
| 53 | else |
| 54 | echo "tunnel is not running" |
| 55 | fi |
| 56 | ;; |
| 57 | *) |
| 58 | echo "Usage: $0 {start|stop|restart|status}" >&2 |
| 59 | exit 1 |
| 60 | ;; |
| 61 | esac |