--- a/build/sbin/sync_mosatags Fri Apr 23 11:07:28 2010 +0200
+++ b/build/sbin/sync_mosatags Fri Apr 23 18:53:02 2010 +0200
@@ -1,4 +1,4 @@
-#!/bin/env bash
+#!/usr/bin/env bash
shopt -s extglob
@@ -25,7 +25,7 @@
sync_type='all'
server='dev'
-hg_user="$hg_anonymous_user:$hg_anonymous_password";
+hg_user="$hg_anonymous_user"
hg_operation='update'
debug=false
@@ -40,9 +40,10 @@
echo " -o <hg_operation>: one of update|archive"
echo " -l <hg_url>: the url of the hg repository"
echo " -u <user>: hg user"
+ echo " -p <password>: hg password"
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 " -e <export_path>: path prefix for export. The version will be"
+ echo " appended. ignored when hg operation is \"update\""
echo " -d: debug mode. display only environement"
}
@@ -56,14 +57,13 @@
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
+ if [[ "$hg_compare_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
@@ -93,14 +93,14 @@
echo "cleanup";
if [ -d "$export_path" && "$export_path" != "$clone_path" ]; then
echo "Delete export_path : $export_path"
- #rm -fr $export_path;
+ rm -fr $export_path;
echo "ok";
fi
}
sync_web() {
echo "===============";
- export_path_web="$export_path"/web/thdProject;
+ export_path_web="$export_path"/web/thdProject/;
server_ip_name=$server"_web_server";
server_ip=${!server_ip_name};
sync_user_name=${server}_sync_user;
@@ -130,11 +130,12 @@
P log/***
P data/***
EOT
- pushd "$export_path_web";
- echo "symfony unfreeze"
- php symfony unfreeze ;
- popd;
-
+ if [ "$hg_operation" == "update" ]; then
+ pushd "$export_path_web";
+ echo "symfony unfreeze"
+ php symfony unfreeze ;
+ popd;
+ fi
fi
}
@@ -142,15 +143,15 @@
sync_engine() {
echo "===============";
echo "sync engine";
- export_path_engine="$export_path"/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
+ echo rsync -Cvrlz --delete --filter=". -" "$export_path_engine" $sync_user@$server_ip:$engine_location
+ cat <<EOT | rsync -Cvrlz --delete --filter=". -" "$export_path_engine" $sync_user@$server_ip:$engine_location
- .hg
- .hg/***
P solr/solr/conf/solrconfig.xml
@@ -169,7 +170,7 @@
echo "hg_url : $hg_url";
echo "sync_type : $sync_type";
echo "server : $server";
- echo "clone_path : $clone_patth";
+ echo "clone_path : $clone_path";
echo "export_path : $export_path";
echo "debug : $debug";
}
@@ -253,6 +254,16 @@
exit
fi
;;
+
+ -p)
+ hg_password=$2
+ if ! { shift 2; }; then
+ echo "the -p option need an argument"
+ usage
+ exit
+ fi
+ ;;
+
-d)
debug=true
@@ -280,12 +291,20 @@
fi
if [ "$hg_user" == "anonymous" -o "$hg_user" == "anon" ]; then
- hg_user="$hg_anonymous_user:$hg_anonymous_password"
+ hg_user="$hg_anonymous_user"
+ hg_password="$hg_anonymous_password"
fi
-hg_url="$hg_server_protocol://$hg_user@$hg_server"
+
+if [ -z "$hg_password" ]; then
+ hg_url="$hg_server_protocol://$hg_user@$hg_server"
+ hg_compare_url="$hg_server_protocol://$hg_user@$hg_server"
+else
+ hg_url="$hg_server_protocol://$hg_user:$hg_password@$hg_server"
+ hg_compare_url="$hg_server_protocol://$hg_user:***@$hg_server"
+fi
if [ "$hg_operation" == "archive" ]; then
- export_path=~/tmp/mosatags_$version
+ export_path=${export_path_prefix}_$version
else
export_path="$clone_path"
fi
@@ -295,8 +314,6 @@
exit
fi
-echo "################"
-exit
checkout_sources
case "$sync_type" in