blob: 1367b75f683b83f89915f5e74113ce783c10f568 [file] [log] [blame]
Masayoshi Kobayashi80493be2013-08-01 17:33:44 -07001#!/bin/bash
2onosdev1=192.168.56.11
3onosdev2=192.168.56.12
4onosdev3=192.168.56.13
5onosdev4=192.168.56.14
6
7dir=`dirname $0`
8
9TUNNEL=("1 4 onosdev1")
10NW_ID=04
11
12start () {
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
33stop () {
34 sudo pkill capsulator
35}
36
37case "$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 ;;
57esac