correct sync script
authorymh <ymh.work@gmail.com>
Fri, 23 Apr 2010 11:07:28 +0200
changeset 78 a7b73ae25643
parent 77 50db792f9151
child 79 03f5524aa3c0
correct sync script
build/sbin/sync_mosatags
--- a/build/sbin/sync_mosatags	Thu Apr 22 23:17:57 2010 +0200
+++ b/build/sbin/sync_mosatags	Fri Apr 23 11:07:28 2010 +0200
@@ -1,5 +1,7 @@
 #!/bin/env bash
 
+shopt -s extglob
+
 prod_web_server=94.247.233.8
 prod_engine_server=94.247.233.9
 
@@ -167,8 +169,9 @@
     echo "hg_url       : $hg_url";
     echo "sync_type    : $sync_type";
     echo "server       : $server";
-    echo "clone_path   : $clone_path";
+    echo "clone_path   : $clone_patth";
     echo "export_path  : $export_path";
+    echo "debug        : $debug";
 }
 
 while [ $# -gt 0 ]
@@ -183,7 +186,7 @@
     -t)
       sync_type=$2;
       # check sync type value
-      if [[ "$sync_type" =~ @(web|engine|all) ]]; then
+      if [[ "$sync_type" == @(web|engine|all) ]]; then
         shift 2
       else
         echo "sync type given : $sync_type, must be one of web|engine|all"
@@ -194,7 +197,7 @@
 
     -s)
       server=$2
-      if [[ "$server" =~ @(prod|dev) ]]; then
+      if [[ "$server" == @(prod|dev) ]]; then
         shift 2
       else
         echo "server given : $server, must be one of prod|dev"
@@ -205,7 +208,7 @@
 
     -o)
       hg_operation=$2
-      if [[ "$hg_operation" =~ @(archive|update) ]]; then
+      if [[ "$hg_operation" == @(archive|update) ]]; then
         shift 2
       else
         echo "hg operation given : $hg_operation, must be one of archive|update"
@@ -263,50 +266,55 @@
 
     *)
         echo "Unknown option $1"
-        usage;
-        exit;
+        usage
+        exit
     ;;
   
   esac
 done
 
-if [ -z "$version" ]; then
-    echo "No version";
-    usage;
-    exit;
-fi;
+if [ -z "$version" ] && ! $debug; then
+    echo "No version"
+    usage
+    exit
+fi
 
 if [ "$hg_user" == "anonymous" -o  "$hg_user" == "anon" ]; then
-    hg_user="$hg_anonymous_user:$hg_anonymous_password";
-fi;
-hg_url="$hg_server_protocol://$hg_user@$hg_server";
+    hg_user="$hg_anonymous_user:$hg_anonymous_password"
+fi
+hg_url="$hg_server_protocol://$hg_user@$hg_server"
 
 if [ "$hg_operation" == "archive" ]; then
-    export_path=~/tmp/mosatags_$version;
+    export_path=~/tmp/mosatags_$version
 else
     export_path="$clone_path"
 fi
 
 disp_env
+if $debug; then
+    exit
+fi
+
+echo "################"
 exit
-checkout_sources;
+checkout_sources
 
 case "$sync_type" in
     
     "web")
-    sync_web;
+    sync_web
     ;;
     
     "engine")
-    sync_engine;
+    sync_engine
     ;;
     
     "all")
-    sync_web;
-    sync_engine;
+    sync_web
+    sync_engine
     ;;
 
 esac
 
 
-cleanup;
+cleanup