-
Notifications
You must be signed in to change notification settings - Fork 2
/
mycroft_install.sh
292 lines (233 loc) · 9.42 KB
/
mycroft_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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#!/usr/bin/env bash
echo
echo 'Updating apt and installing wget, git, vim, unzip, htop'
echo
sleep 2
sudo apt-get update
sudo apt-get install -y wget git vim unzip htop
##########################################################################
sleep 2
echo
echo 'Starting Mycroft installation'
echo
sleep 2
cd ~/
git clone https://github.com/MycroftAI/mycroft-core.git
cd mycroft-core
bash dev_setup.sh
sudo mkdir /etc/mycroft
sudo mkdir /ramdisk
echo "tmpfs /ramdisk tmpfs rw,nodev,nosuid,size=20M 0 0" | sudo tee -a /etc/fstab > /dev/null
sed -i -e 's|"max_allowed_core_version": 19.2|"max_allowed_core_version": 19.2,\n "ipc_path": "/ramdisk/mycroft/ipc/"|' /home/pi/.mycroft/mycroft.conf
echo
echo 'Mycroft installation complete'
echo
##########################################################################
sleep 2
echo
echo 'Starting Pulseaudio installation'
echo
sleep 2
cd ~/
sudo apt-get install -y pulseaudio
if [ -f /etc/systemd/system/pulseaudio.service ]
then
sudo rm /etc/systemd/system/pulseaudio.service
fi
echo "[Unit]" | sudo tee -a /etc/systemd/system/pulseaudio.service > /dev/null
echo "Description=PulseAudio Daemon" | sudo tee -a /etc/systemd/system/pulseaudio.service > /dev/null
echo "" | sudo tee -a /etc/systemd/system/pulseaudio.service > /dev/null
echo "[Install]" | sudo tee -a /etc/systemd/system/pulseaudio.service > /dev/null
echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/pulseaudio.service > /dev/null
echo "" | sudo tee -a /etc/systemd/system/pulseaudio.service > /dev/null
echo "[Service]" | sudo tee -a /etc/systemd/system/pulseaudio.service > /dev/null
echo "Type=simple" | sudo tee -a /etc/systemd/system/pulseaudio.service > /dev/null
echo "PrivateTmp=true" | sudo tee -a /etc/systemd/system/pulseaudio.service > /dev/null
echo "ExecStart=/usr/bin/pulseaudio --system --realtime --disallow-exit --no-cpu-limit" | sudo tee -a /etc/systemd/system/pulseaudio.service > /dev/null
echo "load-module module-native-protocol-tcp auth-anonymous=1" | sudo tee -a /etc/pulse/system.pa > /dev/null
sudo chmod +x /etc/systemd/system/pulseaudio.service
sudo systemctl enable pulseaudio.service
sudo usermod -aG pulse pi
sudo usermod -aG pulse-access pi
sudo usermod -aG pulse root
sudo usermod -aG pulse-access root
echo
echo 'Pulseaudio installation complete'
echo
##########################################################################
sleep 2
echo "Do you want to install Spotifyd?"
echo -n "Choice [y/n]: "
while true; do
read -N1 -s key
case $key in
y)
echo
echo 'Starting Spotifyd installation'
echo
read -p "Enter Spotify Username: " username
read -s -p "Enter Spotify Password: " password
cd ~/
curl -s https://api.github.com/repos/Spotifyd/spotifyd/releases/latest | jq --raw-output '.assets[0] | .browser_download_url' | wget -i - -O spotifyd.zip
unzip spotifyd.zip
rm spotifyd.zip
if [ ! -d /home/pi/.spotifyd_cache ]
then
mkdir /home/pi/.spotifyd_cache
fi
if [ -f /etc/spotifyd.conf ]
then
sudo rm /etc/spotifyd.conf
fi
echo "[global]" | sudo tee -a /etc/spotifyd.conf > /dev/null
echo "username = "$username | sudo tee -a /etc/spotifyd.conf > /dev/null
echo "password = "$password | sudo tee -a /etc/spotifyd.conf > /dev/null
echo "mixer = PCM" | sudo tee -a /etc/spotifyd.conf > /dev/null
echo "volume-control = alsa # or alsa_linear, or softvol" | sudo tee -a /etc/spotifyd.conf > /dev/null
echo "device_name = mycroft # Cannot contain spaces" | sudo tee -a /etc/spotifyd.conf > /dev/null
echo "bitrate = 320 # 96|160|320" | sudo tee -a /etc/spotifyd.conf > /dev/null
echo "cache_path = /home/pi/.spotifyd_cache" | sudo tee -a /etc/spotifyd.conf > /dev/null
echo "volume-normalisation = false" | sudo tee -a /etc/spotifyd.conf > /dev/null
if [ -f /etc/systemd/system/spotifyd.service ]
then
sudo rm /etc/systemd/system/spotifyd.service
fi
echo "[Unit]" | sudo tee -a /etc/systemd/system/spotifyd.service > /dev/null
echo "Description=A spotify playing daemon" | sudo tee -a /etc/systemd/system/spotifyd.service > /dev/null
echo "Documentation=https://github.com/Spotifyd/spotifyd" | sudo tee -a /etc/systemd/system/spotifyd.service > /dev/null
echo "After=pulseaudio.service" | sudo tee -a /etc/systemd/system/spotifyd.service > /dev/null
echo "Wants=sound.target" | sudo tee -a /etc/systemd/system/spotifyd.service > /dev/null
echo "After=sound.target" | sudo tee -a /etc/systemd/system/spotifyd.service > /dev/null
echo "Wants=network-online.target" | sudo tee -a /etc/systemd/system/spotifyd.service > /dev/null
echo "After=network-online.target" | sudo tee -a /etc/systemd/system/spotifyd.service > /dev/null
echo "" | sudo tee -a /etc/systemd/system/spotifyd.service > /dev/null
echo "[Service]" | sudo tee -a /etc/systemd/system/spotifyd.service > /dev/null
echo "ExecStart=/home/pi/spotifyd --no-daemon" | sudo tee -a /etc/systemd/system/spotifyd.service > /dev/null
echo "Restart=always" | sudo tee -a /etc/systemd/system/spotifyd.service > /dev/null
echo "RestartSec=12" | sudo tee -a /etc/systemd/system/spotifyd.service > /dev/null
echo "[Install]" | sudo tee -a /etc/systemd/system/spotifyd.service > /dev/null
echo "WantedBy=default.target" | sudo tee -a /etc/systemd/system/spotifyd.service > /dev/null
sudo chmod +x /etc/systemd/system/spotifyd.service
sudo systemctl enable spotifyd.service
echo
echo 'Spotifyd installation complete'
echo
break
;;
n)
echo "Skipping Spotifyd installation"
break
;;
esac
done
##########################################################################
sleep 2
echo
echo 'Starting creation of mycroft service'
echo
if [ -f /etc/systemd/system/mycroft.service ]
then
sudo rm /etc/systemd/system/mycroft.service
fi
echo "[Unit]" | sudo tee -a /etc/systemd/system/mycroft.service > /dev/null
echo "Description=Mycroft personal AI" | sudo tee -a /etc/systemd/system/mycroft.service > /dev/null
echo "After=pulseaudio.service" | sudo tee -a /etc/systemd/system/mycroft.service > /dev/null
echo "After=network.target" | sudo tee -a /etc/systemd/system/mycroft.service > /dev/null
echo "" | sudo tee -a /etc/systemd/system/mycroft.service > /dev/null
echo "[Service]" | sudo tee -a /etc/systemd/system/mycroft.service > /dev/null
echo "User=pi" | sudo tee -a /etc/systemd/system/mycroft.service > /dev/null
echo "WorkingDirectory=/home/pi/mycroft-core" | sudo tee -a /etc/systemd/system/mycroft.service > /dev/null
echo "ExecStart=/home/pi/mycroft-core/start-mycroft.sh all" | sudo tee -a /etc/systemd/system/mycroft.service > /dev/null
echo "ExecStop=/home/pi/mycroft-core/stop-mycroft.sh" | sudo tee -a /etc/systemd/system/mycroft.service > /dev/null
echo "Type=forking" | sudo tee -a /etc/systemd/system/mycroft.service > /dev/null
echo "Restart=always" | sudo tee -a /etc/systemd/system/mycroft.service > /dev/null
echo "RestartSec=3" | sudo tee -a /etc/systemd/system/mycroft.service > /dev/null
echo "" | sudo tee -a /etc/systemd/system/mycroft.service > /dev/null
echo "[Install]" | sudo tee -a /etc/systemd/system/mycroft.service > /dev/null
echo "WantedBy=multi-user.target" | sudo tee -a /etc/systemd/system/mycroft.service > /dev/null
sudo chmod +x /etc/systemd/system/mycroft.service
sudo systemctl enable mycroft.service
echo
echo 'Creation of mycroft service complete'
echo
##########################################################################
sleep 2
echo "Do you want to install the Finished Booting skill?"
echo -n "Choice [y/n]: "
while true; do
read -N1 -s key
case $key in
y)
echo
echo 'Install Finished Booting skill'
echo
/home/pi/mycroft-core/bin/mycroft-msm install skill-finished-booting
echo
echo 'Finished Booting skill installed'
echo
break
;;
n)
echo
echo 'Skipping skill install'
echo
break
;;
esac
done
##########################################################################
sleep 2
echo "Do you want to install Respeaker Mic Array v2.0 Pixel Ring skill?"
echo -n "Choice [y/n]: "
while true; do
read -N1 -s key
case $key in
y)
echo
echo 'Install Respeaker Mic Array v2.0 Pixel Ring skill'
echo
if [ -f /etc/udev/rules.d/55-seeedusb-perms.rules ]
then
sudo rm /etc/udev/rules.d/55-seeedusb-perms.rules
fi
echo 'SUBSYSTEM=="usb", ATTR{idVendor}=="2886", ATTR{idProduct}=="0018", GROUP="plugdev", MODE="0666"' | sudo tee -a /etc/udev/rules.d/55-seeedusb-perms.rules > /dev/null
/home/pi/mycroft-core/bin/mycroft-msm install https://github.com/arraylabs/mycroft-respeaker-usb-pixel-ring.git
echo
echo 'Respeaker Mic Array v2.0 Pixel Ring skill installed'
echo
break
;;
n)
echo
echo 'Skipping skill install'
echo
break
;;
esac
done
##########################################################################
sleep 2
echo
echo 'Reboot is required for changes to take effect'
echo
echo "Do you want to reboot now?"
echo -n "Choice [y/n]: "
while true; do
read -N1 -s key
case $key in
y)
echo
echo 'Rebooting in 3 seconds'
echo
sleep 3
sudo reboot
break
;;
n)
echo
echo "Reboot skipped but still required for services to start and changes to take effect"
echo
break
;;
esac
done