forked from project-alice-assistant/HermesLedControl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·250 lines (214 loc) · 8.16 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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#!/usr/bin/env bash
if [[ "$EUID" -ne 0 ]]; then
echo "Please run as root"
exit
fi
VENV=venv
PYTHON=$(command -v python3.7)
if [[ -z "$PYTHON" ]]; then
PYTHON=$(command -v python3.6)
if [[ -z "$PYTHON" ]]; then
PYTHON=$(command -v python3.5)
if [[ -z "$PYTHON" ]]; then
echo "Please make sure to have python 3.5 at least"
exit
fi
fi
fi
if [[ -z "$1" ]]; then
echo "No version supplied"
exit
else
VERSION=$1
fi
USER=$(logname)
USERDIR='/home/'${USER}
echo "What assistant engine are you using?"
select engine in "projectalice" "rhasspy" "snips" "cancel"; do
case "$engine" in
cancel) exit;;
*) break;;
esac
done
if [[ "$engine" == 'rhasspy' ]]; then
defaultPath='/.config/rhasspy/profiles/en/profile.json'
else
defaultPath='/etc/snips.toml'
fi
pathToAssistantConfig="/etc/snips.toml"
echo "What's the path to your assistant config file?"
read -p "Path: (${defaultPath})" pathToAssistantConfig
echo "Path: $pathToAssistantConfig"
pathToAssistantConfig=${pathToAssistantConfig//\//\\/}
echo "What device do you wish to control with SLC?"
select device in "respeaker2Mics" "respeaker4MicArray" "respeakerMicArrayV2" "respeakerMicArrayV1" "neoPixelsSK6812RGBW" "neoPixelsWS2812RGB" "matrixvoice" "matrixcreator" "respeakerCoreV2" "respeaker6MicArray" "respeaker7MicArray" "googleAIY" "I'm using simple leds on GPIOs" "don't overwrite existing parameters" "cancel"; do
case "$device" in
"I'm using simple leds on GPIOs")
device=puregpio
break;;
cancel) exit;;
*) break;;
esac
done
if [[ "$device" != "don't overwrite existing parameters" ]]; then
echo "What pattern do you want to use?"
select pattern in "google" "alexa" "projectalice" "pgas" "custom" "kiboost" "cancel"; do
case "$pattern" in
cancel) exit;;
*) break;;
esac
done
defaultConfigurationPath=${USERDIR}'/.config/hermesLedControl'
echo "Where should the configuration be saved to?"
read -p "Path (${defaultConfigurationPath})" configurationPath
configurationPath=${configurationPath:-$defaultConfigurationPath}
configurationFile=${configurationPath}/configuration.yml
echo "Path: $configurationPath"
escapedConfigurationFile=${configurationFile//\//\\/}
fi
doaConfigValue="false"
if [[ "$device" == "respeaker4MicArray" || "$device" == "respeakerMicArrayV2" || "$device" == "respeakerMicArrayV1" || "$device" == "respeaker6MicArray" || "$device" == "respeakerCoreV2" ]]; then
echo "Your device supports Direction of Arrival (DoA). Do you want to enable DoA now?"
select enableDoA in "yes" "no" "install dependencies only" "cancel"; do
case "$enableDoA" in
"yes") doaConfigValue="true";&
"install dependencies only")
apt-get update
apt-get install -y libatlas-base-dev
pipNumpy="pip3 --no-cache-dir install numpy"
break;;
cancel) exit;;
*) break;;
esac
done
fi
systemctl is-active -q hermesledcontrol && systemctl stop hermesledcontrol
apt-get update
apt-get install -y git mosquitto mosquitto-clients portaudio19-dev python3-numpy
FVENV=${USERDIR}'/hermesLedControl_'${VERSION}'/'${VENV}
apt-get install -y python3-pip
if [[ -d "$FVENV" ]]; then
rm -rf ${FVENV}
fi
systemctl is-active -q pixel_ring_server && systemctl disable pixel_ring_server
chown -R ${USER} ${USERDIR}/hermesLedControl_${VERSION}
pip3 install virtualenv
sudo -u ${USER} bash <<EOF
virtualenv -p ${PYTHON} ${FVENV}
source ${FVENV}/bin/activate
pip3 --no-cache-dir install RPi.GPIO
pip3 --no-cache-dir install spidev
pip3 --no-cache-dir install gpiozero
pip3 --no-cache-dir install paho-mqtt
pip3 --no-cache-dir install toml
pip3 --no-cache-dir install pyyaml
${pipNumpy}
pip3 uninstall -y pixel_ring
EOF
pip3 uninstall -y pixel_ring
mkdir -p logs
chown ${USER} logs
if [[ "$device" != "don't overwrite existing parameters" && -f /etc/systemd/system/hermesledcontrol.service ]]; then
rm /etc/systemd/system/hermesledcontrol.service
fi
if [[ ! -f /etc/systemd/system/hermesledcontrol.service ]]; then
cp hermesledcontrol.service /etc/systemd/system
fi
if [[ "$device" != "don't overwrite existing parameters" && -f ${configurationFile} ]]; then
rm ${configurationFile}
fi
if [[ "$device" != "don't overwrite existing parameters" && ! -f ${configurationFile} ]]; then
mkdir -p ${configurationPath}
cp configuration.yml ${configurationPath}
chown ${USER} ${configurationFile}
sed -i -e "s/%ENGINE%/"${engine}"/" ${configurationFile}
sed -i -e "s/%PATHTOCONFIG%/"${pathToAssistantConfig}"/" ${configurationFile}
sed -i -e "s/%DEVICE%/"${device}"/" ${configurationFile}
sed -i -e "s/%PATTERN%/"${pattern}"/" ${configurationFile}
sed -i -e "s/%DOA%/"${doaConfigValue}"/" ${configurationFile}
fi
escaped=${USERDIR//\//\\/}
sed -i -e "s/%WORKING_DIR%/"${escaped}"\/hermesLedControl_"${VERSION}"/" /etc/systemd/system/hermesledcontrol.service
sed -i -e "s/%USER%/"${USER}"/" /etc/systemd/system/hermesledcontrol.service
if [[ "$device" != "don't overwrite existing parameters" ]]; then
sed -i -e "s/%EXECSTART%/"${escaped}"\/hermesLedControl_"${VERSION}"\/venv\/bin\/python3 main.py --hermesLedControlConfig="${escapedConfigurationFile}"/" /etc/systemd/system/hermesledcontrol.service
fi
if [[ -d "/var/lib/hermes/skills/snips-skill-respeaker" ]]; then
echo "snips-skill-respeaker detected, do you want to remove it? Leaving it be might result in weird behaviors..."
select answer in "yes" "no" "cancel"; do
case "$answer" in
yes)
rm -rf "/var/lib/snips/skills/snips-skill-respeaker"
systemctl restart snips-*
echo "Removed snips-skill-respeaker"
break;;
cancel) exit;;
*) break;;
esac
done
fi
echo "Do you need to install / configure your "${device}"? This is strongly suggested as it does turn off services that might conflict as well!"
select answer in "yes" "no" "cancel"; do
case "$answer" in
yes)
case "$device" in
matrixvoice)
./installers/matrixVoiceCreator.sh ${USER} ${FVENV}
break
;;
matrixcreator)
./installers/matrixVoiceCreator.sh ${USER} ${FVENV}
break
;;
respeaker2Mics)
./installers/respeakers.sh ${USER} ${FVENV}
break
;;
respeaker4MicArray)
./installers/respeakers.sh ${USER} ${FVENV}
break
;;
respeaker6MicArray)
./installers/respeakers.sh ${USER} ${FVENV}
break
;;
neoPixelsSK6812RGBW)
./installers/neopixels.sh ${USER} ${FVENV}
break
;;
neoPixelsWS2812RGB)
./installers/neopixels.sh ${USER} ${FVENV}
break
;;
respeakerMicArrayV2)
./installers/respeakerMicArrayV2.sh ${USER} ${FVENV}
break
;;
respeakerMicArrayV1)
./installers/respeakerMicArrayV1.sh ${USER} ${FVENV}
break
;;
respeakerCoreV2)
./installers/respeakerCoreV2.sh ${USER} ${FVENV}
break
;;
respeaker7MicArray)
./installers/respeaker7MicArray.sh ${USER} ${FVENV}
break
;;
*)
echo "No installation needed / Installation not yet supported"
break
;;
esac
break;;
cancel) exit;;
*) break;;
esac
done
chown -R ${USER} ${USERDIR}/hermesLedControl_${VERSION}
systemctl daemon-reload
systemctl enable hermesledcontrol
systemctl start hermesledcontrol
echo "Finished installing Hermes Led Control "${VERSION}
echo "You may want to copy over your custom led patterns to the new version"