update README.PI for new (simpler) requirements
[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         
27         start_umts $sliver;
28         
29         if [[ $? != 0 ]] ; then
30                 echo "Failed"
31         fi
32     ;;
33
34     stop)
35         logger "Stopping umts connection for $sliver"
36         stop_umts $sliver;
37
38         if [[ $? != 0 ]] ; then
39                 echo "Failed"
40         fi
41
42     ;;
43
44     add)
45         logger "Request to add a destination by $sliver for the UMTS connection";       
46         
47         if ! check_sliceip; then
48            exit 1
49         fi
50         
51         if ! valid_dotted_quad "$rest"; then
52                 echo "Failed"
53         else
54                 add_destination "$rest" $sliver;
55                 if [[ $? == 0 ]] ; then
56                         echo "OK"
57                 else
58                         echo "Failed"
59                 fi
60         fi
61
62         ;;      
63
64     del)
65         logger "Request to del a destination by $sliver for the UMTS connection";
66         
67         if ! check_sliceip; then
68            exit 1
69         fi
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