line for LP test
[curl-de-sac.git] / INSTALL.sh
index e8310bd..e6e869d 100755 (executable)
@@ -1,5 +1,5 @@
 #!/bin/bash
-set -x
+#set -x
 #
 # Defaults
 #
@@ -8,6 +8,10 @@ CONFIG_FILE="$HOME/.curl-de-sac_install"
 apache_conf="/etc/apache2/sites-available/default"
 # brisk_debug="0xffff"
 web_path="/home/nastasi/web/curl-de-sacccc"
+web_url="http://localhost/curl-de-sac"
+tor_chk_url="http://localhost/curl-de-sac/test/tor_mock.php"
+proxy_chk_url="http://localhost/curl-de-sac/test/proxy_mock.php"
+dbg_level=998
 # ftok_path="/home/nastasi/brisk-priv/ftok/brisk"
 # proxy_path="/home/nastasi/brisk-priv/proxy/brisk"
 # sys_user="www-data"
@@ -24,7 +28,7 @@ function usage () {
 
     echo "$1 chk                          - run lintian on all ph* files."
 #    echo "$1 pkg                          - build brisk packages."
-    echo "$1 [-w <web_dir>] [-f <conffile>] [-p <outconf>]" # [-W] [-n 3|5] [-t <(n>=4)>] [-T <auth_tab>] [-G <cert_tab>] [-A <apache-conf>] [-a <auth_file_name>] [-U <usock_path>] [-u <sys_user>] [-d <TRUE|FALSE>] [-k <ftok_dir>] [-l <legal_path>] [-y <proxy_path>] [-P <prefix_path>] [-x]"
+    echo "$1 [-w <web_dir>] [-f <conffile>] [-p <outconf>] [-t <tor_chk_url>] [-P <proxy_chk_url>]"  # [-W] [-n 3|5] [-t <(n>=4)>] [-T <auth_tab>] [-G <cert_tab>] [-A <apache-conf>] [-a <auth_file_name>] [-U <usock_path>] [-u <sys_user>] [-d <TRUE|FALSE>] [-k <ftok_dir>] [-l <legal_path>] [-y <proxy_path>] [-P <prefix_path>] [-x]"
 #    echo "$1 [-W] [-n 3|5] [-t <(n>=4)>] [-T <auth_tab>] [-G <cert_tab>] [-A <apache-conf>] [-a <auth_file_name>] [-f <conffile>] [-p <outconf>] [-U <usock_path>] [-u <sys_user>] [-d <TRUE|FALSE>] [-w <web_dir>] [-k <ftok_dir>] [-l <legal_path>] [-y <proxy_path>] [-P <prefix_path>] [-x]"
     echo "$1 [-w <web_dir>]"
     echo "  -h this help"
@@ -37,8 +41,11 @@ function usage () {
     # echo "  -T number of auth-only tables   - def. $tables_auth_n"
     # echo "  -G number of cert-only tables   - def. $tables_cert_n"
     # echo "  -a authorization file name      - def. \"$brisk_auth_conf\""
-    # echo "  -d activate dabug               - def. $brisk_debug"
-    echo "  -w dir where place the web tree - def. \"$web_path\""
+    echo "  -d set debug level                - def. $dbg_level"
+    echo "  -w dir where place the web tree   - def. \"$web_path\""
+    echo "  -U web url to retrieve test pages - def. \"$web_url\""
+    echo "  -t tor chk url                    - def. \"$tor_chk_url\""
+    echo "  -P proxy chk url                  - def. \"$proxy_chk_url\""
     # echo "  -k dir where place ftok files   - def. \"$ftok_path\""
     # echo "  -l dir where save logs          - def. \"$legal_path\""
     # echo "  -y dir where place proxy files  - def. \"$proxy_path\""
@@ -46,7 +53,7 @@ function usage () {
     # echo "  -C config filename              - def. \"$brisk_conf\""
     # echo "  -U unix socket path             - def. \"$usock_path\""
     # echo "  -u system user to run brisk dae - def. \"$sys_user\""
-    # echo "  -x copy tests as normal php     - def. \"$test_add\""
+    echo "  -x copy tests as normal php       - def. \"$test_add\""
     echo
 }
 
@@ -144,8 +151,11 @@ while [ $# -gt 0 ]; do
 #        -T*) tables_auth_n="$(get_param "-T" "$1" "$2")"; sh=$?;;
 #        -G*) tables_cert_n="$(get_param "-G" "$1" "$2")"; sh=$?;;
 #        -a*) brisk_auth_conf="$(get_param "-a" "$1" "$2")"; sh=$?;;
-#        -d*) brisk_debug="$(get_param "-d" "$1" "$2")"; sh=$?;;
+        -d*) dbg_level="$(get_param "-d" "$1" "$2")"; sh=$?;;
         -w*) web_path="$(get_param "-w" "$1" "$2")"; sh=$?;;
+        -U*) web_url="$(get_param "-U" "$1" "$2")" ; sh=$?;;
+        -t*) tor_chk_url="$(get_param "-t" "$1" "$2")" ; sh=$?;;
+        -P*) proxy_chk_url="$(get_param "-P" "$1" "$2")" ; sh=$?;;
 #        -k*) ftok_path="$(get_param "-k" "$1" "$2")"; sh=$?;;
 #        -y*) proxy_path="$(get_param "-y" "$1" "$2")"; sh=$?;;
 #        -P*) prefix_path="$(get_param "-P" "$1" "$2")"; sh=$?;;
@@ -154,7 +164,7 @@ while [ $# -gt 0 ]; do
 #        -U*) usock_path="$(get_param "-U" "$1" "$2")"; sh=$?;;
 #        -u*) sys_user="$(get_param "-u" "$1" "$2")"; sh=$?;;
 #        system) action=system;;
-        -W) web_only="TRUE";;
+#        -W) web_only="TRUE";;
         -x) test_add="TRUE";;
         -h) usage $0; exit 0;;
        *) usage $0; exit 1;;
@@ -179,8 +189,12 @@ echo "    outconf:    \"$outconf\""
 # echo "    tables_auth_n: $tables_auth_n"
 # echo "    tables_cert_n: $tables_cert_n"
 # echo "    brisk_auth_conf: \"$brisk_auth_conf\""
-# echo "    brisk_debug:\"$brisk_debug\""
+echo "    dbg_level:  $dbg_level"
 echo "    web_path:   \"$web_path\""
+echo "    web_url:    \"$web_url\""
+echo "    tor_chk_url:    \"$tor_chk_url\""
+echo "    proxy_chk_url:    \"$proxy_chk_url\""
+
 # echo "    ftok_path:  \"$ftok_path\""
 # echo "    legal_path: \"$legal_path\""
 # echo "    proxy_path: \"$proxy_path\""
@@ -202,8 +216,11 @@ if [ ! -z "$outconf" ]; then
     # echo "tables_auth_n=$tables_auth_n"
     # echo "tables_cert_n=$tables_cert_n"
     # echo "brisk_auth_conf=\"$brisk_auth_conf\""
-    # echo "brisk_debug=\"$brisk_debug\""
+    echo "dbg_level=$dbg_level"
     echo "web_path=\"$web_path\""
+    echo "web_url=\"$web_url\""
+    echo "tor_chk_url=\"$tor_chk_url\""
+    echo "proxy_chk_url=\"$proxy_chk_url\""
     # echo "ftok_path=\"$ftok_path\""
     # echo "proxy_path=\"$proxy_path\""
     # echo "legal_path=\"$legal_path\""
@@ -212,11 +229,12 @@ if [ ! -z "$outconf" ]; then
     # echo "usock_path=\"$usock_path\""
     # echo "sys_user=\"$sys_user\""
     # echo "web_only=\"$web_only\""
-    echo "test_add=\"$test_add\""
+    echo "test_add=\"$test_add\""
   ) > "$outconf"
 fi
 
-if [ "$action" = "system" -a 1 -eq 0 ]; then
+if [ 1 -eq 0 -a "$action" = "system" ]; then
+    # no used
     scrname="$(echo "$prefix_path" | sed 's@^/@@g;s@/$@@g;s@/@_@g;')"
     echo
     echo "script name:  [$scrname]"
@@ -263,16 +281,23 @@ if [ "$web_only" != "TRUE" ]; 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
 
-for i in $(find web -name '.htaccess' -o -name '*.php' -o -name '*.phh' -o -name '*.pho' -o -name '*.css' -o -name '*.js' -o -name '*.mp3' -o -name '*.swf' -o -name 'terms-of-service*' | sed 's/^....//g'); do
+for i in $(find web -name '.htaccess' -o -name '*.php' -o -name '*.phh' -o -name '*.pho' -o -name '*.html' -o -name '*.css' -o -name '*.js' -o -name '*.mp3' -o -name '*.swf' -o -name 'terms-of-service*' | sed 's/^....//g'); do
     install -m 644 "web/$i" "${web_path}/$i"
 done
 if [ "$test_add" = "TRUE" ]; then
-    for i in $(find webtest -name '.htaccess' -o -name '*.php' -o -name '*.phh' -o -name '*.pho' -o -name '*.css' -o -name '*.js' -o -name '*.mp3' -o -name '*.swf' -o -name 'terms-of-service*' | sed 's/^........//g'); do
-        install -m 644 "webtest/$i" "${web_path}/$i"
+    for i in $(find webtest -type d | grep '/' | sed 's/^........//g'); do
+        install -d ${web_path}/test/$i
+    done
+
+    for i in $(find webtest -name '.htaccess' -o -name '*.phh' -o -name '*.pho' -o -name '*.html' -o -name '*.css' -o -name '*.js' -o -name '*.mp3' -o -name '*.swf' -o -name 'terms-of-service*' | sed 's/^........//g'); do
+        install -m 644 "webtest/$i" "${web_path}/test/$i"
+    done
+    for i in $(find webtest -name '*.php' | sed 's/^........//g'); do
+        install -m 755 "webtest/$i" "${web_path}/test/$i"
     done
 fi
 
@@ -282,7 +307,10 @@ fi
 # sed -i "s/^var G_send_time *= *[0-9]\+/var G_send_time = $send_time/g" $(find ${web_path} -type f -name '*.js' -exec grep -l '^var G_send_time *= *[0-9]\+' {} \;)
 
 # # .ph[pho] substitutions
-# sed -i "s/define *( *'PLAYERS_N', *[0-9]\+ *)/define('PLAYERS_N', $players_n)/g" $(find ${web_path} -type f -name '*.ph*' -exec grep -l "define *( *'PLAYERS_N', *[0-9]\+ *)" {} \;)
+sed -i "s@^define *( *'WEB_URL', *'[^']\+' *)@define('WEB_URL', '$web_url')@g;\
+s@define *( *'DBG_LEVEL', *[0-9]\+ *)@define('DBG_LEVEL', $dbg_level)@g;\
+s@define *( *'TOR_CHK_URL', *'[^']\+' *)@define('TOR_CHK_URL', '$tor_chk_url')@g;\
+s@define *( *'PROXY_CHK_URL', *'[^']\+' *)@define('PROXY_CHK_URL', '$proxy_chk_url')@g" $(find ${web_path} -type f -name '*.ph*')
 
 # sed -i "s/define *( *'BIN5_PLAYERS_N', *[0-9]\+ *)/define('BIN5_PLAYERS_N', $players_n)/g" $(find ${web_path} -type f -name '*.ph*' -exec grep -l "define *( *'BIN5_PLAYERS_N', *[0-9]\+ *)" {} \;)