aggiunto target package
[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/.brisk_install ]; then
11    . $HOME/.brisk_install
12 fi
13
14 function usage () {
15     echo
16     echo "$1 [-n 3|5] [-w web_dir] [-k <ftok_dir>] [-W]"
17     echo "  -h this help"
18     echo "  -n number of players - def. $n_players"
19     echo "  -w dir where place the web tree - def. \"$web_path\""
20     echo "  -k dir where place ftok files   - def. \"$ftok_path\""
21     echo "  -W install web files only"
22     echo
23 }
24
25 function get_param () {
26     echo "X$2" | grep -q "^X$1\$"
27     if [ $? -eq 0 ]; then
28         # echo "DECHE" >&2
29         echo "$3"
30         return 2
31     else
32         # echo "DELA" >&2
33         echo "$2" | cut -c 3-
34         return 1
35     fi
36     return 0
37 }
38
39 #
40 #  MAIN
41 #
42 if [ "$1" = "-p" -o "$1" = "--package" ]; then
43    cd ..
44    tar zcvf brisk-img.tgz `find brisk-img -name INSTALL.sh -o -name '*.png' -o -name '*.jpg' | grep -v imgsrc`
45    cd -
46    exit 0
47 fi
48
49 while [ $# -gt 0 ]; do
50     # echo aa $1 xx $2 bb
51     case $1 in
52         -n*) n_players="`get_param "-n" "$1" "$2"`"; sh=$?;;
53         -w*) web_path="`get_param "-w" "$1" "$2"`"; sh=$?;;
54         -k*) ftok_path="`get_param "-k" "$1" "$2"`"; sh=$?;;
55         -W) web_only=1;;
56         -h) usage $0; exit 0;;
57         *) usage $0; exit 1;;
58     esac
59     # echo "SH $sh"
60     shift $sh
61 done
62
63 #
64 #  Show parameters
65 #
66 echo "    web_path:  \"$web_path\""
67 echo "    ftok_path: \"$ftok_path\""
68 echo "    n_players:   $n_players"
69
70
71 install -d ${web_path}/img
72 install -m 644 `ls img/*.{jpg,png} | grep -v 'img/src_'` ${web_path}/img
73
74 exit 0