forked from MLB-LED-Scoreboard/mlb-led-scoreboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·143 lines (124 loc) · 3.77 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#!/bin/bash
usage() {
cat <<USAGE
Usage: $0 [-a] [-c] [-m] [-p]
Options:
-c, --skip-config: Skip updating JSON configuration files.
-m, --skip-matrix: Skip building matrix driver dependency. Video display will default to emulator mode.
-p, --skip-python: Skip Python 3 installation. Requires manual Python 3 setup if not already installed.
-a, --skip-all: Skip all dependencies and config installation (equivalent to -c -p -m).
--emulator-only: Do not install dependencies under sudo. Skips building matrix dependencies (equivalent to -m)
USAGE
exit 1
}
SKIP_PYTHON=false
SKIP_CONFIG=false
SKIP_MATRIX=false
NO_SUDO=false
for arg in "$@"; do
case $arg in
-p | --skip-python)
SKIP_PYTHON=true
shift # Remove -p / --skip-python from `$@`
;;
-c | --skip-config)
SKIP_CONFIG=true
shift # Remove -c / --skip-config from `$@`
;;
-m | --skip-matrix)
SKIP_MATRIX=true
shift # Remove -m / --skip-matrix from `$@`
;;
-a | --skip-all)
SKIP_CONFIG=true
SKIP_MATRIX=true
SKIP_PYTHON=true
shift # Remove -a / --skip-all from `$@`
;;
--emulator-only)
SKIP_MATRIX=true
NO_SUDO=true
shift # remove --emulator-only from `$@`
;;
-h | --help)
usage # run usage function on help
;;
*)
usage # run usage function if wrong argument provided
;;
esac
done
if [ "$SKIP_PYTHON" = false ]; then
echo
echo "------------------------------------"
echo " Installing python 3..."
echo "------------------------------------"
echo
sudo apt-get update && sudo apt-get install -y \
python3-dev \
python3-pip \
python3-pillow \
python3-tk \
libxml2-dev \
libxslt-dev \
libsdl2-mixer-2.0-0 \
libsdl2-image-2.0-0 \
libsdl2-2.0-0 \
libsdl2-ttf-2.0-0 \
libopenjp2-7
fi
echo
echo "------------------------------------"
echo " Installing dependencies..."
echo "------------------------------------"
echo
if [ "$NO_SUDO" = false ]; then
sudo python3 -m pip install -r requirements.txt
else
python3 -m pip install -r requirements.txt
fi
if [ "$SKIP_MATRIX" = false ]; then
echo "Running rgbmatrix installation..."
mkdir submodules
cd submodules
git clone https://github.com/hzeller/rpi-rgb-led-matrix.git matrix
cd matrix
git pull
make build-python PYTHON=$(which python3)
sudo make install-python PYTHON=$(which python3)
cd ../..
fi
if [ "$SKIP_CONFIG" = true ]; then
echo
echo "------------------------------------"
echo " Skipping configuration updates"
echo "------------------------------------"
echo
else
if [ ! -f "./config.json" ]; then
cp config.json.example config.json
chmod 777 config.json
fi
# Yellow
printf "\e[33m"
echo
echo "==================================================================================="
echo " If you have custom configurations, colors, or coordinates, it's recommended to"
echo " update them with the latest options at this time."
echo
echo " This operation is automatic and will ensure you have up-to-date configuration."
echo
echo " This action will NOT override any custom configuration you already have unless"
echo " the option has been obsoleted and is no longer in use."
echo "==================================================================================="
echo
printf "\e[0m"
# End yellow
read -p "Would you like to do this now? [Y/n] " answer
echo
if [ "$answer" != "${answer#[Yy]}" ] ;then
python3 validate_config.py
fi
echo
fi
echo "Installation finished!"