7 ftok_path="/var/lib/brisk"
11 if [ -f $HOME/.brisk_install ]; then
12 . $HOME/.brisk_install
14 if [ "x$cookie_path" = "x" ]; then
20 echo "$1 [-W] [-n 3|5] [-d TRUE|FALSE] [-w web_dir] [-k <ftok_dir>] [-c <cookie_path>]"
22 echo " -W web files only"
23 echo " -n number of players - def. $n_players"
24 echo " -d activate dabug - def. $brisk_debug"
25 echo " -w dir where place the web tree - def. \"$web_path\""
26 echo " -k dir where place ftok files - def. \"$ftok_path\""
27 echo " -c cookie path - def. \"$cookie_path\""
31 function get_param () {
32 echo "X$2" | grep -q "^X$1\$"
48 while [ $# -gt 0 ]; do
51 -n*) n_players="`get_param "-n" "$1" "$2"`"; sh=$?;;
52 -d*) brisk_debug="`get_param "-d" "$1" "$2"`"; sh=$?;;
53 -w*) web_path="`get_param "-w" "$1" "$2"`"; sh=$?;;
54 -k*) ftok_path="`get_param "-k" "$1" "$2"`"; sh=$?;;
55 -c*) cookie_path="`get_param "-c" "$1" "$2"`"; sh=$?;;
57 -h) usage $0; exit 0;;
67 echo " web_path: \"$web_path\""
68 echo " ftok_path: \"$ftok_path\""
69 echo " n_players: $n_players"
74 if [ $web_only -eq 0 ]; then
75 if [ $n_players -ne 3 -a $n_players -ne 5 ]; then
76 echo "n_players ($n_players) out of range (3|5)"
78 elif [ ! -d $ftok_path ]; then
79 echo "ftok_path (\"$ftok_path\") not exists"
82 touch $ftok_path/spy.txt >/dev/null 2>&1
84 echo "ftok_path (\"$ftok_path\") write not allow."
89 # create the fs subtree to enable ftok-ing
90 touch ${ftok_path}/main
91 chmod 666 ${ftok_path}/main
94 install -m 644 web/*.{php,phh,css,js} ${web_path}
96 find . -name '.htaccess' -exec install -m 644 {} ${web_path}/{} \;
99 if [ $n_players -eq 5 ]; then
106 sed -i "s/PLAYERS_N *= *[0-9]\+/PLAYERS_N = $n_players/g" `find ${web_path} -type f -name '*.js' -exec grep -l 'PLAYERS_N *= *[0-9]\+' {} \;`
108 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]\+' {} \;`
110 # .ph[ph] substitutions
111 sed -i "s/define *( *PLAYERS_N, *[0-9]\+ *)/define(PLAYERS_N, $n_players)/g" `find ${web_path} -type f -name '*.ph*' -exec grep -l 'define *( *PLAYERS_N, *[0-9]\+ *)' {} \;`
113 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,[^)]*)' {} \;`
115 sed -i "s@define *( *BRISK_DEBUG,[^)]*)@define(BRISK_DEBUG, $brisk_debug)@g" ${web_path}/brisk.phh
117 sed -i "s@var \+xhr_rd_cookiepath \+= \+\"[^\"]*\";@var xhr_rd_cookiepath = \"$cookie_path\";@g" ${web_path}/xhr.js