view.tpl : use double quotes instead of simple in HTML
[ldapsaisie.git] / upgradeFromGit.sh
index 9355757..fcf89de 100755 (executable)
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 
 
 ROOT_DIR=$( cd `dirname $0`; pwd )
@@ -17,6 +17,16 @@ function msg() {
     echo $2 "$1" | tee -a "$LOG_FILE"
 }
 
+function check_file_or_symlink() {
+    [ -f "$1" ] && echo 0 && return 0
+    if [ -L "$1" ]
+    then
+        [ -r "$1" ] && echo 0 && return 0
+        rm -f "$1"
+    fi
+    echo 1 && return 1
+}
+
 cd $ROOT_DIR
 
 msg "-> Clean git repos : "
@@ -171,7 +181,7 @@ then
                do
                        f=`basename $i`
                        msg "\t\t\t- $f : " -en
-                       if [ -f $ROOT_DIR/public_html/templates/$THEME/$f ]
+                       if [ `check_file_or_symlink "$ROOT_DIR/public_html/templates/$THEME/$f"` -eq 0 ]
                        then
                                msg "present."
                        else
@@ -191,7 +201,7 @@ then
                do
                        f=`basename $i`
                        msg "\t\t\t- $f : " -en
-                       if [ -f $ROOT_DIR/public_html/images/$THEME/$f ]
+                       if [ `check_file_or_symlink "$ROOT_DIR/public_html/images/$THEME/$f"` -eq 0 ]
                        then
                                msg "present."
                        else
@@ -211,7 +221,7 @@ then
                do
                        f=`basename $i`
                        msg "\t\t\t- $f : " -en
-                       if [ -f $ROOT_DIR/public_html/css/$THEME/$f ]
+                       if [ `check_file_or_symlink "$ROOT_DIR/public_html/css/$THEME/$f"` -eq 0 ]
                        then
                                msg "present."
                        else
@@ -224,23 +234,37 @@ fi
 
 if [ $BUILD_DOC -eq 1 ]
 then
+       [ -n "$LAST_UPDATE_FILE" ] && [ "`$ROOT_DIR/checkDocExportsNecessity.sh`" == "" ] && echo "Export documentation is not necessary. Pass." && exit 
        msg "-> Do you want build the documentation (y/N) ? " -en
        read a
        if [ "$a" == "y" -o "$a" == "Y" ]
        then
-        msg "-> Build the doc : " -en
-               cd $ROOT_DIR/doc >> $LOG_FILE 2>&1 && make >> $LOG_FILE 2>&1 && cd - >> $LOG_FILE 2>&1
-               if [ $? -gt 0 ]
-               then
-                       msg "Error"
-                       exit 1
-               else
-                       msg "Ok"
-               fi
+               msg "-> Build the doc : " -en
+               cd $ROOT_DIR/doc
+               
+               make clean >> $LOG_FILE 2>&1
+               make >> $LOG_FILE 2>&1 &
+               
+               export P=$!
+               
+               trap exitwhell INT
+               
+               function exitwhell() {
+                       [ -n "$P" ] && kill -9 $P 2> /dev/null
+                       echo " -- INT -- "
+                       exit 1
+               }
+               
+               while [ -d /proc/$P ]
+               do
+                       echo -n .
+                       sleep 1
+               done
+               echo done.
 
-        if [ -n "$EXPORT_DOC_DIR" ]
-        then
-            $ROOT_DIR/buildDocExports.sh
-        fi
-    fi
+               if [ -n "$EXPORT_DOC_DIR" ]
+               then
+                   $ROOT_DIR/buildDocExports.sh
+               fi
+       fi
 fi