fix of tiny bug inside my_xmd5 function
authorpatrick nsukami <ndkpatt@gmail.com>
Tue, 16 Sep 2014 12:57:58 +0000 (12:57 +0000)
committerpatrick nsukami <ndkpatt@gmail.com>
Tue, 16 Sep 2014 12:57:58 +0000 (12:57 +0000)
.bash_function

index c88a028..fc1ead4 100644 (file)
@@ -1,6 +1,21 @@
 #!/bin/sh
 # my weird function file
 
+my_err() {
+    echo "[$(date + '%Y-%m-%dT%H:%M:%S%z')]: $@ >&2"
+}
+
+my_test() {
+    echo 'test';
+}
+
+my_test2(){
+    if my_test; then
+        my_err "unable to my_test"
+        exit "${E_DID_NOTHING}"
+    fi
+}
+
 my_pretty_print_json() {
     python -m json.tool
 }
@@ -129,6 +144,7 @@ my_uploadfile() {
     local password=$4;
 
     echo "upload of '$filename' to '$ftp_url' by '$user' ..."
+    #curl -T $filename ftp://dev.africafilms.tv/movies/ --user dev.africafilms.tv:dev/aftv/DAK2602
     curl -T $filename $ftp_url --user $user:$password
 }
 
@@ -150,7 +166,7 @@ my_find_string2() {
 }
 # extract md5 hash from a string
 my_xmd5() {
-    local $string=$1;
+    local string=$1;
 
     echo "md5 hash of '$string' is: "
     echo -n "$sring" | md5sum;
@@ -158,14 +174,14 @@ my_xmd5() {
 
 # Creates an archive (*.tar.gz) from given directory.
 my_maketar() {
-    local $directory=$1;
+    local directory=$1;
 
     tar cvzf "${directory%%/}.tar.gz"  "${directory%%/}/";
 }
 
 # Create a ZIP archive of a file or folder.
 my_makezip() {
-    local $file=$1;
+    local file=$1;
 
     zip -r "${file%%/}.zip" "$file";
 }
@@ -228,6 +244,15 @@ my_df() {
     done
 }
 
+# create_vm(){
+#     debootstrap --verbose \
+#   --variant=minbase \
+#   --arch=i386 --include ifupdown,locales,libui-dialog-perl,dialog,dhcp3-client,netbase,net-tools,iproute,openssh-server \
+#   sid /var/lib/lxc/sid http://ftp.debian.org/debian
+
+# }
+
+
 my_add_todo(){
     local rememberfile="$HOME/.remember"
     # if the file not exists, touch it
@@ -275,3 +300,96 @@ my_create_list(){
     local listname=$1;
     declare -a $listname;
 }
+
+# sensonet
+
+sensonet_create_event() {
+    curl -i -X "POST" -k -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Accept: application/json" -d "name=$1" http://projects.emerginov.orange.sn/sensonet/resources/events/"$2"
+}
+
+sensonet_update_event() {
+    curl -i -X "PUT" -k -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Accept: application/json" -d "name=$1" http://projects.emerginov.orange.sn/sensonet/resources/events/"$2"
+}
+
+sensonet_events() {
+    [[ $# -eq 0 ]] && curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/events/ || \
+    curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/events/"$1"
+}
+
+sensonet_del_event() {
+    curl -i -X "DELETE" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/events/"$1"
+}
+
+sensonet_create_sensor() {
+    curl -i -X "POST" -k -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Accept: application/json" -d "description=$1" http://projects.emerginov.orange.sn/sensonet/resources/sensors/"$2"
+}
+
+sensonet_update_sensor() {
+     curl -i -X "PUT" -k -H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" -H "Accept: application/json" -d "description=$1" http://projects.emerginov.orange.sn/sensonet/resources/sensors/"$2"
+}
+
+sensonet_del_sensor() {
+    curl -i -X "DELETE" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/sensors/"$1"
+}
+
+sensonet_sensors() {
+    [[ $# -eq 0 ]] &&  curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/sensors/ || \
+    curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/sensors/"$1"
+}
+
+sensonet_create_network(){
+    curl -i -X "POST" -k -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -d "name=$1" http://projects.emerginov.orange.sn/sensonet/resources/networks/"$2"
+}
+
+sensonet_update_network(){
+    curl -i -X "PUT" -k -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -d "name=$1" http://projects.emerginov.orange.sn/sensonet/resources/networks/"$2"
+}
+
+sensonet_del_network(){
+    curl -i -X "DELETE" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/networks/"$1"
+}
+
+sensonet_networks(){
+    [[ $# -eq 0 ]] &&  curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/networks/ || \
+    curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/networks/"$1"
+}
+
+sensonet_network_probes() {
+     curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/networks/"$1"/probes
+}
+
+sensonet_create_probe() {
+    curl -i -X "POST" -k -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" \
+    -d "name=${1}&latitude=0.0&longitude=0.0&monitorMe=1&sleepingTime=0&networkId=univlab" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${2}"
+}
+
+sensonet_update_probe() {
+    curl -i -X "PUT" -k -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" \
+    -d "name=${1}&latitude=48.0&longitude=-1.0&monitorMe=1&sleepingTime=0" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${2}"
+}
+
+sensonet_probes() {
+    [[ $# -eq 0 ]] && curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/ || \
+    curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"
+}
+
+sensonet_del_probe() {
+    curl -i -X "DELETE" -k -H -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${2}"
+}
+
+sensonet_probe_neighborhood(){
+    curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"/neighborhood
+}
+
+sensonet_probe_set_sleeping_time(){
+    curl -i -X "POST" -k -H "Content-Type: application/x-www-form-urlencoded" -H "Accept: application/json" -d "duration=${2}" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"/sleepingtime
+}
+
+sensonet_probe_sensors(){
+    [[ $# -eq 1 ]] && curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"/sensors || \
+        curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"/sensors/"${2}"
+}
+
+sensonet_probe_sensor_values(){
+     curl -i -X "GET" -k -H "Accept: application/json" http://projects.emerginov.orange.sn/sensonet/resources/probes/%2B221"${1}"/sensors/"${2}"/values
+}