more robust sql scripts adding IF EXISTS to DROP TABLE statementes
[brisk.git] / INSTALL.sh
index 3c25449..7c4b75d 100755 (executable)
@@ -90,6 +90,7 @@ function searchetc() {
 #
 #  MAIN
 #
+declare -a nam
 if [ "$1" = "chk" ]; then
     set -e
     oldifs="$IFS"
@@ -100,7 +101,7 @@ if [ "$1" = "chk" ]; then
     done
 
     taggit="$(git describe --tags | sed 's/^v//g')"
-    tagphp="$(grep "^\$G_brisk_version = " web/Obj/brisk.phh | sed 's/^[^"]\+"//g;s/".*//g')"
+    tagphp="$(grep "^\$G_brisk_version = " web/Obj/brisk.phh | sed 's/^[^"]\+"//g;s/".*//g')" # ' emacs hell
     if [ "$taggit" != "$tagphp" ]; then
         echo
        echo "WARNING: taggit: [$taggit] tagphp: [$tagphp]"
@@ -111,16 +112,28 @@ fi
 
 # before all check errors on the sources
 $0 chk || exit 3
-
 if [ "$1" = "pkg" ]; then
     if [ "$2" != "" ]; then
         tag="$2"
     else
         tag="$(git describe)"
     fi
-    nam1="brisk_${tag}.tgz"
-    nam2="brisk-img_${tag}.tgz"
-    echo "Build packages ${nam1} and ${nam2}."
+    nam_idx=0
+    nam[$nam_idx]="brisk_${tag}.tgz"
+    nam_idx=$((nam_idx + 1))
+    nam[$nam_idx]="brisk-img_${tag}.tgz"
+
+    if [ -d ../curl-de-sac ]; then
+       nam_idx=$((nam_idx + 1))
+       nam[$nam_idx]="curl-de-sac_${tag}.tgz"
+    fi
+    pkg_list=""
+    sep=""
+    for i in ${nam[@]}; do
+        pkg_list="${pkg_list}${sep}${i}"
+        sep=", "
+    done
+    echo "Build packages ${pkg_list}."
     read -p "Proceed [y/n]: " a
     if [ "$a" != "y" -a  "$a" != "Y" ]; then
         exit 1
@@ -129,11 +142,17 @@ if [ "$1" = "pkg" ]; then
     cd ../brisk-img
     git archive --format=tar --prefix=brisk-${tag}/brisk-img/ $tag | gzip > ../$nam2
     cd -
+    if [ -d ../curl-de-sac ]; then
+        cd ../curl-de-sac
+        git archive --format=tar --prefix=brisk-${tag}/curl-de-sac/ $tag | gzip > ../$nam3
+        cd -
+    fi
     exit 0
 fi
 
 if [ -f "$CONFIG_FILE" ]; then
    source "$CONFIG_FILE"
+   conffile_in="$CONFIG_FILE"
 fi
 
 if [ "x$prefix_path" = "x" ]; then
@@ -175,6 +194,7 @@ while [ $# -gt 0 ]; do
            exit 1
         fi
         . "$conffile"
+        conffile_in="$conffile"
     fi
     shift $sh
 done
@@ -341,7 +361,7 @@ if [ "$web_only" = "FALSE" ]; then
 
 fi
 install -d ${web_path}__
-for i in $(find web -type d | sed 's/^....//g'); do
+for i in $(find web -type d | grep '/' | sed 's/^....//g'); do
     install -d ${web_path}__/$i 
 done
 
@@ -401,15 +421,20 @@ sed -i "s@\( \+cookiepath *: *\)\"[^\"]*\" *,@\1 \"$prefix_path\",@g" ${web_path
 document_root="$(grep DocumentRoot "${apache_conf}"  | grep -v '^[     ]*#' | awk '{ print $2 }')"
 sed -i "s@^\(\$DOCUMENT_ROOT *= *[\"']\)[^\"']*\([\"']\)@\1$document_root\2@g" ${web_path}__/spush/*.ph*
 
-if [ -d ${web_path} ]; then
-    mv ${web_path} ${web_path}.old
-fi
-
 if [ -d ../brisk-img ]; then
     cd ../brisk-img
     ./INSTALL.sh -w ${web_path}__
     cd - >/dev/null 2>&1
 fi
+if [ -d ../curl-de-sac ]; then
+    cd ../curl-de-sac
+    if [ ! -z "$conffile_in" ]; then
+        ./INSTALL.sh -f "$conffile_in" -w ${web_path}__
+    else
+        ./INSTALL.sh -w ${web_path}__
+    fi
+    cd - >/dev/null 2>&1
+fi
 
 # config file installation or diff
 if [ -f "$etc_path/$brisk_conf" ]; then
@@ -424,6 +449,10 @@ else
     cp  "${web_path}__""/Obj/brisk.conf-templ.pho" "$etc_path/$brisk_conf"
 fi
 
+if [ -d ${web_path} ]; then
+    mv ${web_path} ${web_path}.old
+fi
+
 mv ${web_path}__ ${web_path}
 if [ -d ${web_path}.old ]; then
     rm -rf ${web_path}.old