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