forked from juj/fbcp-ili9341
-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·175 lines (174 loc) · 5.96 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/usr/bin/env sh
# ###################################################################################
# File: img2bin.sh
# Project: img2bin - converts image into RGB565 binary or C/C++ data structure
# File Created: Wednesday, 1st February 2023 4:00:58 pm
# Author: sk
# Last Modified: Saturday, 4th February 2023 6:32:16 pm
# Modified By: Sergey Ko
# ###################################################################################
# CHANGELOG:
# ###################################################################################
echo "\033[2J"
TW=$(stty size | awk '{print $2}')
N=$(((TW/2)-23))
DR=$(cd $(dirname "$0") && pwd)
SN="fbcpX"
SS=""
AUTO=0
AI=0
PR="installation"
UNS=0
SERV=0
ARGS=$@
for n in $ARGS; do
if [ "$n" = "-y" ]; then
AUTO=1
elif [ "$n" = "-u" ]; then
PR="uninstall"
UNS=1
elif [ "$n" = "-s" ]; then
SERV=1
fi
done
BLD="$DR/build"
SRC="$DR/src"
BIN="/usr/local/bin"
ETC="/etc/fbcpx"
SVS="/etc/systemd/system"
echo
echo "\033[32m███████╗██████╗ ██████╗██████╗ ██╗ ██╗" | { perl -pe "s/^/' 'x$N/e"; }
echo "██╔════╝██╔══██╗██╔════╝██╔══██╗ ╚██╗██╔╝" | { perl -pe "s/^/' 'x$N/e"; }
echo "█████╗ ██████╔╝██║ ██████╔╝█████╗ ╚███╔╝ " | { perl -pe "s/^/' 'x$N/e"; }
echo "██╔══╝ ██╔══██╗██║ ██╔═══╝ ╚════╝ ██╔██╗ " | { perl -pe "s/^/' 'x$N/e"; }
echo "██║ ██████╔╝╚██████╗██║ ██╔╝ ██╗" | { perl -pe "s/^/' 'x$N/e"; }
echo "╚═╝ ╚═════╝ ╚═════╝╚═╝ ╚═╝ ╚═╝" | { perl -pe "s/^/' 'x$N/e"; }
echo " Display Driver for SPI LCDs" | { perl -pe "s/^/' 'x$N/e"; }
echo
printf "%0.s=" $(seq 1 $TW)
if [ "$(id -u)" -ne 0 ]; then
echo "\n"
echo " \033[1;31mPlease run as root\033[0m\033[32m" | { perl -pe "s/^/' 'x$N/e"; }
echo
printf "%0.s=" $(seq 1 $TW)
echo "\033[0m"
exit 1
fi
if [ $AUTO -ne 1 ]; then
echo "\n"
echo " The driver has been checked to work on the following systems:\n\
- Raspberry Pi 3 Model B Rev 1.2 with DietPi (v8.12 - 8.13.2)\n\
- Raspberry Pi Zero W with DietPi (v8.12 - 8.13.2)"
if [ -f "$BIN/fbcpx" ]; then
echo
echo " (i) fbcpX already installed on this system"
echo
AI=1
SS="$(systemctl is-active $SN)"
if [ $UNS -ne 1 ] && [ -f "$SVS/$SN.service" ]; then
SERV=1
fi
PR="reinstall/update"
fi
echo " Todo:"
if [ $UNS -ne 1 ]; then
echo " 1. build executable file"
echo " 2. install executable and configuration directory:\033[0m"
echo " - fbcpx \033[35m->\033[0m $BIN"
echo " - $SN.conf \033[35m->\033[0m $ETC"
if [ $SERV -eq 1 ]; then
echo " - $SN.service \033[35m->\033[0m $SVS"
echo " \033[32m3. activate service"
fi
else
echo " \033[32m1. stop/deactivate service"
echo " 2. remove installed files and directories"
echo " 3. clean build"
fi
echo
echo " Options:"
if [ $SERV -ne 1 ]; then
echo " -s : install service"
fi
echo " -y : skip this intro"
echo " -u : uninstall and clean"
echo
echo " \033[33moriginal repo.: https://github.com/juj/fbcp-ili9341\033[0m"
echo " \033[33mimage converter: https://github.com/way5/image-converter-for-embedded\033[0m"
echo "\033[32m"
printf "%0.s=" $(seq 1 $TW)
echo "\033[0m"
echo
echo "Press \033[1mENTER\033[0m to continue with \033[4;31m$PR\033[0m, or \033[1mCTRL+C\033[0m to exit..."
read rsn1
else
echo "\033[0m"
fi
if [ $UNS -ne 1 ]; then
if [ $AI -eq 1 ]; then
if [ "$SS" = "active" ]; then
systemctl stop $SN
fi
# do something with prev install
fi
## install
if [ $SERV -eq 1 ]; then
if [ ! -d "$SVS" ]; then
echo "\033[31m$SVS doesn't exists, check path\033[0m\n"
exit 0
fi
cp "$BLD/$SN.service" $SVS
fi
if [ ! -d "$ETC" ]; then
mkdir "$ETC"
fi
if [ ! -d "$BLD" ]; then
mkdir "$BLD"
fi
cp "$BLD/$SN.conf" $ETC
cmake -S "$SRC" -B "$BLD"
make -j 3 -C "$DR/build"
cp "$BLD/fbcpx" $BIN
chmod a+x "$BIN/fbcpx"
cp "$DR/splash/default.bin" "$ETC/splash.bin"
echo "\n\033[32m- using default splash screen bitmap\033[0m\n"
if [ $SERV -eq 1 ]; then
echo "\n\033[32m- initializing service\033[0m\n"
systemctl daemon-reload
systemctl enable $SN
systemctl start $SN
echo "\n\033[32m- operation status\033[0m\n"
systemctl status $SN
SS="$(systemctl is-active $SN)"
if [ "$SS" = "active" ]; then
echo "\n\033[32m- success\033[0m\n"
else
echo "\n\033[1;31m- failed to start service\033[0m\n"
fi
else
echo "\n\033[32m- success\033[0m\n"
fi
else
## removing
if [ $SERV -eq 1 ]; then
echo "\033[38;2;255;200;0m-s option has no effect, uninstalling...\033[0m"
fi
if [ -f "$SVS/$SN.service" ]; then
echo "\n\033[32m- disabling service\033[0m\n"
systemctl stop $SN > /dev/null 2>&1
SS="$(systemctl is-active $SN)"
if [ "$SS" = "active" ]; then
echo "\n\033[1;31m- failed to stop service\033[0m\n"
exit 1
fi
systemctl disable $SN
systemctl daemon-reload
fi
echo "\n\033[32m- cleanup\033[0m\n"
rm "$BIN/fbcpx" > /dev/null 2>&1
rm "$SVS/$SN.service" > /dev/null 2>&1
rm -rf "$ETC" > /dev/null 2>&1
make -C "$DR/build" clean
echo "\n\033[32m- success\033[0m\n"
fi
exit 0