Merge with 4801799cbf33c0063fc1fbc2162e9bbf94d6a003
authorymh <ymh.work@gmail.com>
Thu, 22 Apr 2010 23:17:57 +0200
changeset 77 50db792f9151
parent 76 bd6f820fb7e1 (diff)
parent 74 4801799cbf33 (current diff)
child 78 a7b73ae25643
Merge with 4801799cbf33c0063fc1fbc2162e9bbf94d6a003
web/thdProject/apps/frontend/modules/editor/actions/addFilmSegmentAction.class.php
web/thdProject/apps/frontend/modules/editor/templates/indexSuccess.php
web/thdProject/apps/frontend/modules/reflex/templates/_tagNavigator.php
--- a/build/sbin/sync_mosatags	Tue Apr 20 19:55:36 2010 +0200
+++ b/build/sbin/sync_mosatags	Thu Apr 22 23:17:57 2010 +0200
@@ -1,27 +1,312 @@
-#!/bin/env bash
-
-prod_web_server=94.247.233.8
-prod_engine_server=94.247.233.9
-
-dev_web_server=
-dev_engine_server=
-
-prod_sync_user=mosatags
-env_sync_user=mosatags
-
-checkout_sources() {
-    hg clone
-    hg archive  
-
-}
-
-sync_web() {
-
-    #symphony freeze
-    #rsync
-}
-
-sync_engine() {
-    #rsync
-}
-
+#!/bin/env bash
+
+prod_web_server=94.247.233.8
+prod_engine_server=94.247.233.9
+
+dev_web_server=194.254.167.53
+dev_engine_server=194.254.167.54
+
+prod_sync_user=mosatags
+dev_sync_user=mosatags
+
+web_location=/srv/www/mosatags
+engine_location=/srv/tomcat/mosatags
+
+hg_server=www.iri.centrepompidou.fr/dev/hg/mosatags
+hg_server_protocol=https
+
+hg_anonymous_user=anonymous
+hg_anonymous_password=Ajee8eev
+
+clone_path=~/tmp/mosatags_clone
+export_path_prefix=~/tmp/mosatags_
+
+sync_type='all'
+server='dev'
+hg_user="$hg_anonymous_user:$hg_anonymous_password";
+hg_operation='update'
+debug=false
+
+usage() {
+    #-----0123456789012345678901234567890123456789012345678901234567890123456789
+    echo "Usage: $0 [option] version"
+    echo "  version: mosatags version"
+    echo "options:"
+    echo "  -h: help"
+    echo "  -t <type>: one of web|engine|all"
+    echo "  -s <server>: one of dev or prod"
+    echo "  -o <hg_operation>: one of update|archive"
+    echo "  -l <hg_url>: the url of the hg repository"
+    echo "  -u <user>: hg user"
+    echo "  -c <clone_path>: path for cloning the repository"
+    echo "  -e <clone_path>: path prefix for export. The version will be"
+    echo "                   appended. ignored when hg operation is \"update\""
+    echo "  -d: debug mode. display only environement"
+}
+
+checkout_sources() {
+    echo "===============";
+    echo "Checkout source";
+    
+    if [ -d "$clone_path" ]; then
+        pushd "$clone_path";
+
+        hg_clone_url=`hg paths|grep "^default"`;
+        hg_clone_url=${hg_clone_url##"default = "};
+        echo "Repository path = |$hg_clone_url|, must be |$hg_url|.";
+        if [[ "$hg_url" =~ "${hg_clone_url}" ]]; then
+            echo "Repository already exists pull"
+            hg pull -f || { echo "problem when pulling"; exit;}
+        else
+            echo "Repository bad url, deleting clone."
+            popd
+            rm -fr $clone_path
+            pushd "$clone_path"
+         fi
+    fi
+    if [ ! -d "$clone_path" ]; then
+        echo "Clone repository"
+        hg clone -U $hg_url "$clone_path" || { echo "problem when cloning"; exit;}
+        pushd "$clone_path"
+    fi
+    
+    if [ "$hg_operation" == "archive" ]; then
+        if [ -d "$export_path" ]; then
+            rm -fr $export_path
+        fi
+        echo "archive version $version in $export_path"
+        hg archive -r $version "$export_path" || { echo "problem when archiving"; exit;}
+    else
+        echo "force update $version in $export_path"
+        hg update -C -r $version
+    fi
+    
+    popd;
+    
+    echo "checkout done";
+}
+
+cleanup() {
+    echo "===============";
+    echo "cleanup";
+    if [ -d "$export_path" && "$export_path" != "$clone_path" ]; then
+        echo "Delete export_path : $export_path"
+        #rm -fr $export_path;
+        echo "ok";
+    fi
+}
+
+sync_web() {
+    echo "===============";
+    export_path_web="$export_path"/web/thdProject;
+    server_ip_name=$server"_web_server";
+    server_ip=${!server_ip_name};
+    sync_user_name=${server}_sync_user;
+    sync_user=${!sync_user_name}
+    echo "sync web from $export_path_web to $server_ip ($server_ip_name) with user $sync_user ($sync_user_name)";
+    if [ -d "$export_path_web" ]; then
+        pushd "$export_path_web";
+        if [ -d web/sf ]; then
+            echo "cleaning symfony folder";
+            rm -fr web/sf;
+        fi
+        php symfony freeze data/;
+        popd;
+        echo rsync -Cvrlz --delete --filter=". -" "$export_path_web" $sync_user@$server_ip:$web_location
+        cat <<EOT | rsync -Cvrlz --delete --filter=". -" "$export_path_web" $sync_user@$server_ip:$web_location
++ core
+- .hg
+- .hg/***
+P .htpasswd
+P .htaccess
+P plugins/iriSonyenginePlugin/config/sonyengine.yml
+P plugins/uvmcSolrSearchPlugin/config/solr.yml
+P config/databases.yml
+P apps/frontend/config/app.yml
+P apps/frontend/config/factories.yml
+P robots.txt
+P log/***
+P data/***
+EOT
+        pushd "$export_path_web";
+        echo "symfony unfreeze"
+        php symfony unfreeze ;
+        popd;
+
+    fi
+    
+}
+
+sync_engine() {
+    echo "===============";
+    echo "sync engine";
+    export_path_engine="$export_path"/engine;
+    server_ip_name=$server"_engine_server";
+    server_ip=${!server_ip_name};
+    sync_user_name=${server}_sync_user;
+    sync_user=${!sync_user_name};
+    echo "sync web from $export_path_engine to $server_ip ($server_ip_name) with user $sync_user ($sync_user_name)";
+    if [ -d "$export_path_engine" ]; then
+        echo rsync -Cvrlz --delete --filter=". -" "$export_path_engine" $syn_user@$server_ip:$engine_location
+        cat <<EOT | rsync -Cvrlz --delete --filter=". -" "$export_path_engine" $syn_user@$server_ip:$engine_location
+- .hg
+- .hg/***
+P solr/solr/conf/solrconfig.xml
+P solr/solr/data/***
+P solr/context.xml
+P sonyengine/context.xml
+P sonyengine/db/***
+EOT
+    fi
+}
+
+disp_env() {
+    echo "version      : $version";
+    echo "hg_operation : $hg_operation";
+    echo "hg_user      : $hg_user";
+    echo "hg_url       : $hg_url";
+    echo "sync_type    : $sync_type";
+    echo "server       : $server";
+    echo "clone_path   : $clone_path";
+    echo "export_path  : $export_path";
+}
+
+while [ $# -gt 0 ]
+do
+  case $1
+  in
+    -h)
+      usage;
+      exit;
+    ;;
+
+    -t)
+      sync_type=$2;
+      # check sync type value
+      if [[ "$sync_type" =~ @(web|engine|all) ]]; then
+        shift 2
+      else
+        echo "sync type given : $sync_type, must be one of web|engine|all"
+        usage
+        exit
+      fi  
+    ;;
+
+    -s)
+      server=$2
+      if [[ "$server" =~ @(prod|dev) ]]; then
+        shift 2
+      else
+        echo "server given : $server, must be one of prod|dev"
+        usage
+        exit
+      fi  
+    ;;
+
+    -o)
+      hg_operation=$2
+      if [[ "$hg_operation" =~ @(archive|update) ]]; then
+        shift 2
+      else
+        echo "hg operation given : $hg_operation, must be one of archive|update"
+        usage
+        exit
+      fi  
+    ;;
+
+    -l)
+      hg_url=$2
+      if ! { shift 2; }; then
+         echo "the -l option need an argument"
+         usage
+         exit
+      fi
+    ;;
+
+    -c)
+      clone_path=$2
+      if ! { shift 2; }; then
+         echo "the -c option need an argument"
+         usage
+         exit
+      fi
+    ;;
+
+    -e)
+      export_path_prefix=$2
+      if ! { shift 2; }; then
+         echo "the -e option need an argument"
+         usage
+         exit
+      fi
+    ;;
+
+
+    -u)
+      hg_user=$2
+      if ! { shift 2; }; then
+         echo "the -u option need an argument"
+         usage
+         exit
+      fi
+    ;;
+    
+    -d)
+      debug=true
+      shift 1
+    ;;
+
+    [0-9V]*|tip)
+      version=$1
+      shift 1
+    ;;
+
+    *)
+        echo "Unknown option $1"
+        usage;
+        exit;
+    ;;
+  
+  esac
+done
+
+if [ -z "$version" ]; 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";
+
+if [ "$hg_operation" == "archive" ]; then
+    export_path=~/tmp/mosatags_$version;
+else
+    export_path="$clone_path"
+fi
+
+disp_env
+exit
+checkout_sources;
+
+case "$sync_type" in
+    
+    "web")
+    sync_web;
+    ;;
+    
+    "engine")
+    sync_engine;
+    ;;
+    
+    "all")
+    sync_web;
+    sync_engine;
+    ;;
+
+esac
+
+
+cleanup;
--- a/engine/build/deploy.xml	Tue Apr 20 19:55:36 2010 +0200
+++ b/engine/build/deploy.xml	Thu Apr 22 23:17:57 2010 +0200
@@ -7,7 +7,7 @@
                    
      ymh                                                                
      ====================================================================== -->
-<project name="project" default="deploy_all" basedir="..">
+<project name="project" default="deploy_all" basedir="../..">
     <description>
             description
     </description>