6 CONFIG_FILE="$HOME/.curl-de-sac_install"
8 apache_conf="/etc/apache2/sites-available/default"
10 web_path="/home/nastasi/web/curl-de-sacccc"
11 # ftok_path="/home/nastasi/brisk-priv/ftok/brisk"
12 # proxy_path="/home/nastasi/brisk-priv/proxy/brisk"
14 # legal_path="/home/nastasi/brisk-priv/brisk"
15 # prefix_path="/brisk/"
16 # brisk_conf="brisk_spu.conf.pho"
25 echo "$1 chk - run lintian on all ph* files."
26 # echo "$1 pkg - build brisk packages."
27 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]"
28 # 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]"
29 echo "$1 [-w <web_dir>]"
31 echo " -f use this config file"
32 echo " -p save preferences in the file"
33 # echo " -W web files only"
34 # echo " -A apache_conf - def. $apache_conf"
35 # echo " -n number of players - def. $players_n"
36 # echo " -t number of tables - def. $tables_n"
37 # echo " -T number of auth-only tables - def. $tables_auth_n"
38 # echo " -G number of cert-only tables - def. $tables_cert_n"
39 # echo " -a authorization file name - def. \"$brisk_auth_conf\""
40 # echo " -d activate dabug - def. $brisk_debug"
41 echo " -w dir where place the web tree - def. \"$web_path\""
42 # echo " -k dir where place ftok files - def. \"$ftok_path\""
43 # echo " -l dir where save logs - def. \"$legal_path\""
44 # echo " -y dir where place proxy files - def. \"$proxy_path\""
45 # echo " -P prefix path - def. \"$prefix_path\""
46 # echo " -C config filename - def. \"$brisk_conf\""
47 # echo " -U unix socket path - def. \"$usock_path\""
48 # echo " -u system user to run brisk dae - def. \"$sys_user\""
49 echo " -x copy tests as normal php - def. \"$test_add\""
53 function get_param () {
54 echo "X$2" | grep -q "^X$1\$"
67 function searchetc() {
73 while [ "$pp" != "/" ]; do
74 if [ -d "$pp/$dname" ]; then
87 if [ "$1" = "chk" ]; then
92 for i in $(find -name '*.pho' -o -name '*.phh' -o -name '*.php'); do
96 taggit="$(git describe --tags | sed 's/^v//g')"
97 tagphp="$(grep "^\$G_curl_de_sac_version = " web/Obj/curl-de-sac.phh | sed 's/^[^"]\+"//g;s/".*//g')"
98 if [ "$taggit" != "$tagphp" ]; then
100 echo "WARNING: taggit: [$taggit] tagphp: [$tagphp]"
106 # before all check errors on the sources
109 if [ "$1" = "pkg" ]; then
110 if [ "$2" != "" ]; then
113 tag="$(git describe)"
115 nam1="curl-de-sac_${tag}.tgz"
116 echo "Build packages ${nam1}."
117 read -p "Proceed [y/n]: " a
118 if [ "$a" != "y" -a "$a" != "Y" ]; then
121 git archive --format=tar --prefix=brisk-${tag}/curl-de-sac/ $tag | gzip > ../$nam1
126 if [ -f "$CONFIG_FILE" ]; then
127 source "$CONFIG_FILE"
130 if [ "x$prefix_path" = "x" ]; then
131 prefix_path="$web_path"
135 while [ $# -gt 0 ]; do
136 # echo aa $1 xx $2 bb
139 # -A*) apache_conf="$(get_param "-A" "$1" "$2")"; sh=$?;;
140 -f*) conffile="$(get_param "-f" "$1" "$2")"; sh=$?;;
141 -p*) outconf="$(get_param "-p" "$1" "$2")"; sh=$?;;
142 # -n*) players_n="$(get_param "-n" "$1" "$2")"; sh=$?;;
143 # -t*) tables_n="$(get_param "-t" "$1" "$2")"; sh=$?;;
144 # -T*) tables_auth_n="$(get_param "-T" "$1" "$2")"; sh=$?;;
145 # -G*) tables_cert_n="$(get_param "-G" "$1" "$2")"; sh=$?;;
146 # -a*) brisk_auth_conf="$(get_param "-a" "$1" "$2")"; sh=$?;;
147 # -d*) brisk_debug="$(get_param "-d" "$1" "$2")"; sh=$?;;
148 -w*) web_path="$(get_param "-w" "$1" "$2")"; sh=$?;;
149 # -k*) ftok_path="$(get_param "-k" "$1" "$2")"; sh=$?;;
150 # -y*) proxy_path="$(get_param "-y" "$1" "$2")"; sh=$?;;
151 # -P*) prefix_path="$(get_param "-P" "$1" "$2")"; sh=$?;;
152 # -C*) brisk_conf="$(get_param "-C" "$1" "$2")"; sh=$?;;
153 # -l*) legal_path="$(get_param "-l" "$1" "$2")"; sh=$?;;
154 # -U*) usock_path="$(get_param "-U" "$1" "$2")"; sh=$?;;
155 # -u*) sys_user="$(get_param "-u" "$1" "$2")"; sh=$?;;
156 # system) action=system;;
157 # -W) web_only="TRUE";;
158 -x) test_add="TRUE";;
159 -h) usage $0; exit 0;;
160 *) usage $0; exit 1;;
162 if [ ! -z "$conffile" ]; then
163 if [ ! -f "$conffile" ]; then
164 echo "config file [$conffile] not found"
175 echo " outconf: \"$outconf\""
176 # echo " apache_conf:\"$apache_conf\""
177 # echo " players_n: $players_n"
178 # echo " tables_n: $tables_n"
179 # echo " tables_auth_n: $tables_auth_n"
180 # echo " tables_cert_n: $tables_cert_n"
181 # echo " brisk_auth_conf: \"$brisk_auth_conf\""
182 # echo " brisk_debug:\"$brisk_debug\""
183 echo " web_path: \"$web_path\""
184 # echo " ftok_path: \"$ftok_path\""
185 # echo " legal_path: \"$legal_path\""
186 # echo " proxy_path: \"$proxy_path\""
187 # echo " prefix_path:\"$prefix_path\""
188 # echo " brisk_conf: \"$brisk_conf\""
189 # echo " usock_path: \"$usock_path\""
190 # echo " sys_user: \"$sys_user\""
191 # echo " web_only: \"$web_only\""
192 # echo " test_add: \"$test_add\""
194 if [ ! -z "$outconf" ]; then
197 echo "# Produced automatically by curl-de-sac::INSTALL.sh"
199 # echo "apache_conf=$apache_conf"
200 # echo "players_n=$players_n"
201 # echo "tables_n=$tables_n"
202 # echo "tables_auth_n=$tables_auth_n"
203 # echo "tables_cert_n=$tables_cert_n"
204 # echo "brisk_auth_conf=\"$brisk_auth_conf\""
205 # echo "brisk_debug=\"$brisk_debug\""
206 echo "web_path=\"$web_path\""
207 # echo "ftok_path=\"$ftok_path\""
208 # echo "proxy_path=\"$proxy_path\""
209 # echo "legal_path=\"$legal_path\""
210 # echo "prefix_path=\"$prefix_path\""
211 # echo "brisk_conf=\"$brisk_conf\""
212 # echo "usock_path=\"$usock_path\""
213 # echo "sys_user=\"$sys_user\""
214 # echo "web_only=\"$web_only\""
215 # echo "test_add=\"$test_add\""
219 if [ "$action" = "system" -a 1 -eq 0 ]; then
220 scrname="$(echo "$prefix_path" | sed 's@^/@@g;s@/$@@g;s@/@_@g;')"
222 echo "script name: [$scrname]"
223 echo "brisk path: [$web_path]"
224 echo "private path: [$legal_path]"
225 echo "system user: [$sys_user]"
227 read -p "press enter to continue" sure
228 cp bin/brisk-init.sh brisk-init.sh.wrk
229 sed -i "s@^BPATH=.*@BPATH=\"${web_path}\"@g;s@^PPATH=.*@PPATH=\"${legal_path}\"@g;s@^SSUFF=.*@SSUFF=\"${scrname}\"@g;s@^BUSER=.*@BUSER=\"${sys_user}\"@g" brisk-init.sh.wrk
231 su -c "cp brisk-init.sh.wrk /etc/init.d/${scrname}"
236 echo "DON'T FORGET: after the first installation you MUST configure your run-levels accordingly"
238 echo "Example: su -c 'update-rc.d $scrname defaults'"
245 # check for etc path existence
246 dsta="$(dirname "$web_path")"
247 etc_path="$(searchetc "$dsta" Etc)"
248 if [ $? -ne 0 ]; then
249 echo "Etc directory not found"
258 # ftokk_path="${ftok_path}k"
261 if [ "$web_only" != "TRUE" ]; then
262 # here code una tantum
265 install -d ${web_path}
266 for i in $(find web -type d | grep '/' | sed 's/^....//g'); do
267 install -d ${web_path}/$i
270 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
271 install -m 644 "web/$i" "${web_path}/$i"
273 if [ "$test_add" = "TRUE" ]; then
274 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
275 install -m 644 "webtest/$i" "${web_path}/$i"
279 # # .js substitutions
280 # sed -i "s/PLAYERS_N *= *[0-9]\+/PLAYERS_N = $players_n/g" $(find ${web_path} -type f -name '*.js' -exec grep -l 'PLAYERS_N *= *[0-9]\+' {} \;)
282 # 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]\+' {} \;)
284 # # .ph[pho] substitutions
285 # 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]\+ *)" {} \;)
287 # 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]\+ *)" {} \;)
289 # sed -i "s@define *( *'FTOK_PATH',[^)]*)@define('FTOK_PATH', \"$ftok_path\")@g" $(find ${web_path} -type f -name '*.ph*' -exec grep -l "define *( *'FTOK_PATH',[^)]*)" {} \;)
291 # sed -i "s@define *( *'SITE_PREFIX',[^)]*)@define('SITE_PREFIX', \"$prefix_path\")@g;
292 # s@define *( *'SITE_PREFIX_LEN',[^)]*)@define('SITE_PREFIX_LEN', $prefix_path_len)@g" ${web_path}/Obj/sac-a-push.phh
294 # sed -i "s@define *( *'USOCK_PATH',[^)]*)@define('USOCK_PATH', \"$usock_path\")@g" ${web_path}/spush/brisk-spush.phh
296 # sed -i "s@define *( *'TABLES_N',[^)]*)@define('TABLES_N', $tables_n)@g;
297 # s@define *( *'TABLES_AUTH_N',[^)]*)@define('TABLES_AUTH_N', $tables_auth_n)@g;
298 # s@define *( *'TABLES_CERT_N',[^)]*)@define('TABLES_CERT_N', $tables_cert_n)@g;
299 # s@define *( *'BRISK_DEBUG',[^)]*)@define('BRISK_DEBUG', $brisk_debug)@g;
300 # s@define *( *'LEGAL_PATH',[^)]*)@define('LEGAL_PATH', \"$legal_path\")@g;
301 # s@define *( *'PROXY_PATH',[^)]*)@define('PROXY_PATH', \"$proxy_path\")@g;
302 # s@define *( *'BRISK_CONF',[^)]*)@define('BRISK_CONF', \"$brisk_conf\")@g;" ${web_path}/Obj/brisk.phh
304 # sed -i "s@define *( *'BRISK_AUTH_CONF',[^)]*)@define('BRISK_AUTH_CONF', \"$brisk_auth_conf\")@g" ${web_path}/Obj/auth.phh
306 # sed -i "s@var \+cookiepath \+= \+\"[^\"]*\";@var cookiepath = \"$prefix_path\";@g" ${web_path}/commons.js
308 # sed -i "s@\( \+cookiepath *: *\)\"[^\"]*\" *,@\1 \"$prefix_path\",@g" ${web_path}/xynt-streaming.js
310 # document_root="$(grep DocumentRoot "${apache_conf}" | grep -v '^[ ]*#' | awk '{ print $2 }')"
311 # sed -i "s@^\(\$DOCUMENT_ROOT *= *[\"']\)[^\"']*\([\"']\)@\1$document_root\2@g" ${web_path}/spush/*.ph*
313 # # config file installation or diff
314 # if [ -f "$etc_path/$brisk_conf" ]; then
315 # echo "Config file $etc_path/$brisk_conf exists."
316 # echo "=== Dump the diff. ==="
317 # # diff -u "$etc_path/$brisk_conf" "${web_path}""/Obj/brisk.conf-templ.pho"
318 # diff -u <(cat "$etc_path/$brisk_conf" | egrep -v '^//|^#' | grep '\$[a-zA-Z_ ]\+=' | sed 's/ \+= .*/ = /g' | sort | uniq) <(cat "${web_path}""/Obj/brisk.conf-templ.pho" | egrep -v '^//|^#' | grep '\$[a-zA-Z_ ]\+=' | sed 's/ \+= .*/ = /g' | sort | uniq )
319 # echo "=== End dump. ==="
321 # echo "Config file $etc_path/$brisk_conf not exists."
322 # echo "Install a template."
323 # cp "${web_path}""/Obj/brisk.conf-templ.pho" "$etc_path/$brisk_conf"
326 if [ -f WARNING.txt ]; then
327 echo ; echo " ==== WARNING ===="