blob: 4f9767fafa5ca2496b56a18f96002a884fd8e13e [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`
8TUNNEL=("2 2 onosdev2" "3 3 onosdev3" "4 4 onosdev4" "5 5 onosdev2")
9NW_ID=01
10
11start () {
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
32stop () {
33 sudo pkill capsulator
34}
35
36case "$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 ;;
56esac