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