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