-
-
Notifications
You must be signed in to change notification settings - Fork 41
/
install.sh
executable file
·221 lines (189 loc) · 7.46 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
#!/usr/bin/env bash
if [[ "$EUID" -ne 0 ]]; then
echo "Please run as root"
exit
fi
VENV=venv
PYTHON=$(command -v python3.9)
if [[ -z "$PYTHON" ]]; then
PYTHON=$(command -v python3.8)
if [[ -z "$PYTHON" ]]; then
PYTHON=$(command -v python3.7)
if [[ -z "$PYTHON" ]]; then
echo "Please make sure to have python 3.7 at least"
exit
fi
fi
fi
USER=$(logname)
USERDIR='/home/'${USER}
echo "What assistant engine are you using?"
select engine in "projectalice" "rhasspy" "cancel"; do
case "$engine" in
cancel) exit;;
*) break;;
esac
done
if [[ "$engine" == 'rhasspy' ]]; then
defaultPath='/.config/rhasspy/profiles/en/profile.json'
else
defaultPath="$USERDIR/ProjectAlice/config.json"
fi
pathToAssistantConfig=defaultPath
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" "matrixvoiceZMQ" "matrixcreatorZMQ" "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 "projectalice" "google" "alexa" "pgas" "kiboost" "fake-name" "custom" "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
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/'${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"
pip3 install virtualenv
pip3 uninstall -y pixel_ring
sudo -u "${USER}" bash <<EOF
virtualenv -p ${PYTHON} ${FVENV}
source ${FVENV}/bin/activate
pip install https://www.piwheels.org/simple/numpy/numpy-1.21.4-cp39-cp39-linux_armv7l.whl
pip install -r requirements.txt --no-cache-dir
EOF
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/" /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\/venv\/bin\/python main.py --hermesLedControlConfig=${escapedConfigurationFile}/" /etc/systemd/system/hermesledcontrol.service
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)
matrixcreator)
./installers/matrixVoiceCreator.sh "${USER}" "${FVENV}"
break
;;
matrixvoiceZMQ)
matrixcreatorZMQ)
./installers/matrixCore.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"
systemctl daemon-reload
systemctl enable hermesledcontrol
systemctl start hermesledcontrol
echo "Finished installing Hermes Led Control"
echo "You may want to copy over your custom led patterns to the new version"