Masayoshi Kobayashi | 80493be | 2013-08-01 17:33:44 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | onosdev1=192.168.56.11 |
| 3 | onosdev2=192.168.56.12 |
| 4 | onosdev3=192.168.56.13 |
| 5 | onosdev4=192.168.56.14 |
| 6 | |
| 7 | dir=`dirname $0` |
| 8 | TUNNEL=("2 2 onosdev2" "3 3 onosdev3" "4 4 onosdev4" "5 5 onosdev2") |
| 9 | NW_ID=01 |
| 10 | |
| 11 | start () { |
| 12 | ## Modify ## |
| 13 | ulimit -c |
| 14 | for (( i = 0; i< ${#TUNNEL[@]}; i ++)); do |
| 15 | t=`echo ${TUNNEL[$i]}` |
| 16 | ifnr=`echo $t | awk '{print $1}'` |
| 17 | tun_tag=`echo $t | awk '{print $2}'` |
| 18 | tun_end_=`echo $t | awk '{print $3}'` |
| 19 | tun_end=`eval echo '$'$tun_end_` |
| 20 | echo "ifconfig tap${NW_ID}_${ifnr}" |
| 21 | ifconfig tap${NW_ID}_${ifnr} |
| 22 | if [ $? -ne 0 ]; then |
| 23 | echo "creating tap${NW_ID}_${ifnr}" |
| 24 | sudo tunctl -t tap${NW_ID}_${ifnr} |
| 25 | fi |
| 26 | echo "$dir/capsulator -v -d -t eth1 -f ${tun_end} -vb tap${NW_ID}_${ifnr}#${tun_tag}" |
| 27 | sudo ifconfig tap${NW_ID}_${ifnr} 0.0.0.0 up > /dev/null 2>&1 |
| 28 | sudo $dir/capsulator -v -d -t eth1 -f ${tun_end} -vb tap${NW_ID}_${ifnr}#${tun_tag} > /dev/null 2>&1 & |
| 29 | done |
| 30 | } |
| 31 | |
| 32 | stop () { |
| 33 | sudo pkill capsulator |
| 34 | } |
| 35 | |
| 36 | case "$1" in |
| 37 | start | restart) |
| 38 | stop |
| 39 | start |
| 40 | ;; |
| 41 | stop) |
| 42 | stop |
| 43 | ;; |
| 44 | status) |
| 45 | nr=`pgrep capsulator | wc -l` |
| 46 | if [ $nr -gt 0 ]; then |
| 47 | echo "$nr tunnel(s) is running" |
| 48 | else |
| 49 | echo "tunnel is not running" |
| 50 | fi |
| 51 | ;; |
| 52 | *) |
| 53 | echo "Usage: $0 {start|stop|restart|status}" >&2 |
| 54 | exit 1 |
| 55 | ;; |
| 56 | esac |