add new 'no border' card set and finalized sprite_main.sh script
[brisk-img.git] / INSTALL.sh
1 #!/bin/bash
2 #
3 # Defaults
4 #
5 n_players=3
6 ftok_path="/var/lib/brisk"
7 web_path="$HOME/brisk"
8 web_only=0
9
10 if [ -f $HOME/.trusty_install ]; then
11    . $HOME/.trusty_install
12 fi
13
14 function usage () {
15     echo
16     echo "$1 [-p|--package]"
17     echo "$1 [-n 3|5] [-w web_dir] [-k <ftok_dir>] [-W]"
18     echo "  -p build \"binary\" version of the package"
19     echo "  -h this help"
20     echo "  -n number of players - def. $n_players"
21     echo "  -w dir where place the web tree - def. \"$web_path\""
22     echo "  -k dir where place ftok files   - def. \"$ftok_path\""
23     echo "  -W install web files only"
24     echo
25 }
26
27 function get_param () {
28     echo "X$2" | grep -q "^X$1\$"
29     if [ $? -eq 0 ]; then
30         # echo "DECHE" >&2
31         echo "$3"
32         return 2
33     else
34         # echo "DELA" >&2
35         echo "$2" | cut -c 3-
36         return 1
37     fi
38     return 0
39 }
40
41 #
42 #  MAIN
43 #
44 if [ "$1" = "-p" -o "$1" = "--package" ]; then
45    cd ..
46    tar zcvf brisk-img.tgz `find brisk-img -name INSTALL.sh -o -name '*.png' -o -name '*.jpg' -o -name '*.gif' -o -name '.htaccess' | grep -v '/src_'`
47    cd -
48    exit 0
49 fi
50
51 while [ $# -gt 0 ]; do
52     # echo aa $1 xx $2 bb
53     case $1 in
54         -n*) n_players="`get_param "-n" "$1" "$2"`"; sh=$?;;
55         -w*) web_path="`get_param "-w" "$1" "$2"`"; sh=$?;;
56         -k*) ftok_path="`get_param "-k" "$1" "$2"`"; sh=$?;;
57         -W) web_only=1;;
58         -h) usage $0; exit 0;;
59         *) usage $0; exit 1;;
60     esac
61     # echo "SH $sh"
62     shift $sh
63 done
64
65 #
66 #  Show parameters
67 #
68 echo "    web_path:  \"$web_path\""
69 echo "    ftok_path: \"$ftok_path\""
70 echo "    n_players:   $n_players"
71
72
73 for i in `find -type d -name 'img'`; do
74     ii="`echo "$i" | cut -c 3- `"
75     install -d ${web_path}/$ii
76     install -m 644 `find $ii -name INSTALL.sh -o -name '*.png' -o -name '*.jpg' -o -name '*.gif' -o -name '.htaccess' | grep -v '/src_'` ${web_path}/$ii
77 done
78
79
80 exit 0