some fixes and files moved
[planetlab-umts-tools.git] / umts_backend
1 #!/bin/bash
2
3 # Vsys backend
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     #init)
25         #logger "Initialitation of the UMTS inteface requested by $sliver"
26         #init_umts $sliver;
27         #
28         #if [[ $? != 0 ]] ; then
29         #       echo "Failed"
30         #fi
31     #;;
32
33     start)
34         logger "Starting the umts connection for $sliver"
35         start_umts $sliver;
36         
37         if [[ $? != 0 ]] ; then
38                 echo "Failed"
39         fi
40     ;;
41
42     stop)
43         logger "Stopping umts connection for $sliver"
44         stop_umts $sliver;
45
46         if [[ $? != 0 ]] ; then
47                 echo "Failed"
48         fi
49
50     ;;
51
52     add)
53         logger "Request to add a destination by $sliver for the UMTS connection";       
54         
55         if ! valid_dotted_quad "$rest"; then
56                 echo "Failed"
57         else
58                 add_destination "$rest" $sliver;
59                 if [[ $? != 0 ]] ; then
60                         echo "OK"
61                 else
62                         echo "Failed"
63                 fi
64         fi
65
66         ;;      
67
68     del)
69         logger "Request to del a destination by $sliver for the UMTS connection";
70         
71         if ! valid_dotted_quad "$rest"; then
72                 echo "Failed"
73         else
74                 del_destination "$rest" $sliver;
75                 if [[ $? == 0 ]] ; then
76                         echo "OK"
77                 else
78                         echo "Failed"
79                 fi
80         fi
81         ;;
82  
83     status)
84         if  status_umts $sliver; then
85                 if check_who_locked $sliver; then
86                         echo "Connected"
87                 fi
88         else 
89                 echo "Disconnected"
90         fi
91         ;;
92
93     *)
94         echo "Wrong command"
95     ;;
96
97 esac
98
99
100 #sleep 1
101 echo "EOF"
102
103
104 exit 0
105