store backend stuff in a backend/ subdir like for frontend
[planetlab-umts-tools.git] / backend / umtsd
diff --git a/backend/umtsd b/backend/umtsd
new file mode 100755 (executable)
index 0000000..4fbf773
--- /dev/null
@@ -0,0 +1,105 @@
+#!/bin/bash
+
+# Vsys backend
+
+
+sliver=$1
+
+. /usr/lib/umts_functions
+
+
+PATH=/bin:/usr/bin:/sbin:/usr/sbin 
+
+if [[ $sliver == "" ]]; then
+       echo "I need the first argument (the sliver name)";
+       exit 1
+fi
+
+read line
+
+command=`echo ${line%% *}`
+rest=`echo ${line#* }`
+
+case "$command" in
+    start)
+       logger "Starting the umts connection for $sliver"
+       
+       start_umts $sliver;
+       
+       if [[ $? != 0 ]] ; then
+               echo "Failed"
+       fi
+    ;;
+
+    stop)
+       logger "Stopping umts connection for $sliver"
+       stop_umts $sliver;
+
+       if [[ $? != 0 ]] ; then
+               echo "Failed"
+       fi
+
+    ;;
+
+    add)
+       logger "Request to add a destination by $sliver for the UMTS connection";       
+       
+       if ! check_sliceip; then
+          exit 1
+       fi
+       
+       if ! valid_dotted_quad "$rest"; then
+               echo "Failed"
+       else
+               add_destination "$rest" $sliver;
+               if [[ $? == 0 ]] ; then
+                       echo "OK"
+               else
+                       echo "Failed"
+               fi
+       fi
+
+       ;;      
+
+    del)
+       logger "Request to del a destination by $sliver for the UMTS connection";
+       
+       if ! check_sliceip; then
+          exit 1
+       fi
+       
+       if ! valid_dotted_quad "$rest"; then
+               echo "Failed"
+       else
+               del_destination "$rest" $sliver;
+               if [[ $? == 0 ]] ; then
+                       echo "OK"
+               else
+                       echo "Failed"
+               fi
+       fi
+       ;;
+    status)
+       if  status_umts $sliver; then
+               if check_who_locked $sliver; then
+                       echo "Connected"
+               fi
+       else 
+               echo "Disconnected"
+       fi
+       ;;
+
+    *)
+       echo "Wrong command"
+    ;;
+
+esac
+
+
+sleep 1
+echo "EOF"
+
+
+exit 0
+