cleanup when done
[planetlab-umts-tools.git] / umtsd
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     start)
25         logger "Starting the umts connection for $sliver"
26         start_umts $sliver;
27         
28         if [[ $? != 0 ]] ; then
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 "Failed"
39         fi
40
41     ;;
42
43     add)
44         logger "Request to add a destination by $sliver for the UMTS connection";       
45         
46         if ! valid_dotted_quad "$rest"; then
47                 echo "Failed"
48         else
49                 add_destination "$rest" $sliver;
50                 if [[ $? == 0 ]] ; then
51                         echo "OK"
52                 else
53                         echo "Failed"
54                 fi
55         fi
56
57         ;;      
58
59     del)
60         logger "Request to del a destination by $sliver for the UMTS connection";
61         
62         if ! valid_dotted_quad "$rest"; then
63                 echo "Failed"
64         else
65                 del_destination "$rest" $sliver;
66                 if [[ $? == 0 ]] ; then
67                         echo "OK"
68                 else
69                         echo "Failed"
70                 fi
71         fi
72         ;;
73  
74     status)
75         if  status_umts $sliver; then
76                 if check_who_locked $sliver; then
77                         echo "Connected"
78                 fi
79         else 
80                 echo "Disconnected"
81         fi
82         ;;
83
84     *)
85         echo "Wrong command"
86     ;;
87
88 esac
89
90
91 sleep 1
92 echo "EOF"
93
94
95 exit 0
96