fixed for module-tools
[planetlab-umts-tools.git] / backend / root / vsys / umts_backend
1 #!/bin/bash
2
3 sliver=$1
4
5 . /usr/lib/umts_functions
6
7
8 PATH=/bin:/usr/bin:/sbin:/usr/sbin 
9
10 if [[ $sliver == "" ]]; then
11         echo "I need the first argument (the sliver name)";
12         exit 1
13 fi
14
15 read line
16
17 command=`echo ${line%% *}`
18 rest=`echo ${line#* }`
19
20 case "$command" in
21     start)
22         logger "Starting the umts connection for $sliver"
23         start_umts $sliver;
24         
25         if [[ $? == 0 ]] ; then
26                 #echo "OK" 
27                 true
28         else
29                 echo "Failed"
30         fi
31     ;;
32
33     stop)
34         logger "Stopping umts connection for $sliver"
35         stop_umts $sliver;
36
37         if [[ $? == 0 ]] ; then
38                 #echo "OK"
39                 true
40         else
41                 echo "Failed"
42         fi
43
44     ;;
45
46     add)
47         logger "Request to add a destination for the umts connection";  
48         
49         if ! valid_dotted_quad "$rest"; then
50                 echo "Failed"
51         else
52                 add_destination "$rest" $sliver;
53                 if [[ $? == 0 ]] ; then
54                         echo "OK"
55                 else
56                         echo "Failed"
57                 fi
58         fi
59
60         ;;      
61
62     del)
63         logger "Request to del a destination for the umts connection";
64         
65         if ! valid_dotted_quad "$rest"; then
66                 echo "Failed"
67         else
68                 del_destination "$rest" $sliver;
69                 if [[ $? == 0 ]] ; then
70                         echo "OK"
71                 else
72                         echo "Failed"
73                 fi
74         fi
75         ;;
76  
77     status)
78         if  status_umts; then
79                 echo "Connected"
80         else 
81                 echo "Disconnected"
82         fi
83         ;;
84
85     *)
86         echo "Wrong command"
87     ;;
88
89 esac
90
91
92 #sleep 1
93 echo "EOF"
94
95
96 exit 0
97