-
Notifications
You must be signed in to change notification settings - Fork 85
/
Copy pathinstall.sh
executable file
·370 lines (337 loc) · 8.8 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
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
#!/bin/bash
# Prompt User for Installation
currentDir=$(
cd $(dirname "$0")
pwd
)
SSPARI_PATH=$currentDir
export SSPARI_PATH
SSPARI_BACKUP_PATH="$SSPARI_PATH/backup_files"
export SSPARI_BACKUP_PATH
touch "$SSPARI_BACKUP_PATH/files"
if [ $SUDO_USER ];
then
user=$SUDO_USER;echo
else
echo "Must be run as root user!!"
exit 1
fi
cd "$currentDir"
chmod -R 777 .
# Set up file-based logging
exec 1> >(tee install.log)
source functions.sh
source dependencies.sh
restore_originals
# Add Environment Variables, used for uninstallation
HOME_PROF="/home/$user/.profile"
save_original $HOME_PROF
echo "export SSPARI_PATH=$SSPARI_PATH" >> "/home/$user/.profile"
echo "export SSPARI_BACKUP_PATH=$SSPARI_PATH/backup_files" >> "/home/$user/.profile"
log "Select Your Install Options"
# Begins Logging
installlog "1. Install the Raspberry Pi Audio Receiver Car Installation"
installlog "2. Install the Raspberry Pi Audio Receiver Home Installation"
installlog "3. Install the Raspberry Pi Network Without Internet Installation (For teaching!)"
installlog "4. Install the Bluetooth Only Installation"
installlog "5. Install the Snapcast Installation (BETA), choose from Snapcast Server, Client, or Both (Requires Minor Configuration)"
installlog "6. Install a Custom Raspberry Pi Audio Receiver"
Install="0"
while true
do
read -p "Which installation would you like to choose? (1/2/3/4/5/6) : " Install
case "$Install" in
1)
# Car Installation - Previously Raspberry Pi Audio Receiver Install Car Install
AirPlay="y"
Bluetooth="y"
AP="y"
Kodi="y"
Lirc="y"
SoundCardInstall="y"
GMedia="n"
SNAPCAST="n"
break
;;
2)
# Home Installation - Previously Raspberry Pi Audio Receiver Install
AirPlay="y"
Bluetooth="y"
AP="n"
Kodi="y"
Lirc="y"
SoundCardInstall="y"
GMedia="y"
SNAPCAST="n"
break
;;
3)
# Access Point Install - Previously Network Without Internet
AirPlay="n"
Bluetooth="n"
AP="y"
Kodi="n"
Lirc="n"
GMedia="n"
SNAPCAST="n"
break
;;
4)
AirPlay="n"
Bluetooth="y"
AP="n"
Kodi="n"
Lirc="n"
GMedia="n"
SNAPCAST="n"
SoundCardInstall="n"
break
;;
5)
# Custom Install - Allows Users to Choose Installation of various features.
# Further allowing the use of this project with other ideas aside from Audio Receivers.
AirPlay="y"
Bluetooth="y"
AP="n"
Kodi="n"
Lirc="n"
GMedia="n"
SNAPCAST="y"
SoundCardInstall="y"
break
;;
6)
SNAPCAST="n"
YesNo "Do you want to install SnapCast? (y/n): " && SNAPCAST="y"
# Prompts the User to use AirPlay for Streaming (aka shairport-sync)
AirPlay="n"
YesNo "Do you want AirPlay Enabled? (y/n) : " && AirPlay="y"
# Prompts the User to use Bluetooth for Streaming (aka A2DP)
Bluetooth="n"
YesNo "Do you want Bluetooth A2DP Enabled? (y/n) : " && Bluetooth="y"
# Prompts the User to use the Raspberry Pi as an Access Point to create a network
# (needed for AirPlay when no existing network exists)
AP="n"
YesNo "Do you want to setup as an Access Point? (Necessary for AirPlay, in location without a Wireless Network) (y/n) : " && AP="y"
# Prompts the User to use Kodi as a GUI for a Media Center
Kodi="n"
YesNo "Do you want Kodi installed? (y/n) : " && Kodi="y"
# Prompts the User to use Lirc for Infrared Remote Support
# (matricom IR remote already setup for use with Kodi)
Lirc="n"
YesNo "Do you want to use infrared remotes? (y/n) : " && Lirc="y"
SoundCardInstall="n"
YesNo "Do you want to use a Sound Card? (y/n) : " && SoundCardInstall="y"
GMedia="n"
YesNo "Do you want to setup device as a UPnP Renderer? (y/n) : " && GMedia="y"
break
;;
*)
echo "Please choose a valid choice"
esac
done
if [ "$SNAPCAST" = "y" ]
then
while true
do
read -p "Would you like to install SnapCast as a Server(s), Client(c), or both (b)?: (s/c/b) " SNAPCAST
case "$SNAPCAST" in
[bB]*) SNAPCAST="b"; break;
;;
[cC]*) SNAPCAST="c"; break;
;;
[sS]*) SNAPCAST="s"; break;
;;
*) echo "Please enter a valid choice";
;;
esac
done
while true
do
read -p "Would you like to install Librespot (Warning: No Longer Maintained, install time: long) (y/n): " LIBRESPOT
case "$LIBRESPOT" in
[yY]*) LIBRESPOT="y"; break;
;;
[nN]*) LIBRESPOT="n"; break;
;;
*) echo "Please enter a valid choice";
;;
esac
done
fi
# Prompts the User to check whether or not to use individual names for the chosen devices
SameName="n"
YesNo "Do you want all the Devices to use the same name? (y/n) : " && SameName="y"
if [ "$SameName" = "y" ]
then
# Asks for All Devices Identical Name
read -p "Device name: " MYNAME
APName=$MYNAME
BluetoothName=$MYNAME
AirPlayName=$MYNAME
GMediaName=$MYNAME
SNAPNAME=$MYNAME
elif [ "$SameName" = "n" ]
then
# Asks for Bluetooth Device Name
if [ "$Bluetooth" = "y" ]
then
read -p "Bluetooth Device Name: " BluetoothName
fi
# Asks for AirPlay Device Name
if [ "$AirPlay" = "y" ]
then
read -p "AirPlay Device Name: " AirPlayName
fi
# Asks for Access Point Device Name
if [ "$AP" = "y" ]
then
read -p "Access Point Device Name: " APName
fi
if [ "$GMedia" = "y" ]
then
read -p "UPnP Device Name: " GMediaName
fi
if [ "$SNAPCAST" != "n" ]
then
read -p "Snapcast Device Name: " SNAPNAME
fi
fi
if [ "$AP" = "y" ]
then
# Asks for the Access Point Password
read -p "Device WiFi Password: " WIFIPASS
fi
if [ "$AirPlay" = "y" ]
then
AirPlaySecured="n"
AirPlayPass=""
# Asks user if AirPlay password should be set
YesNo "Do you want to use an AirPlay password? (y/n) : " && AirPlaySecured="y"
# Prompts user for AirPlay password
if [ "$AirPlaySecured" = "y" ]
then
read -p "Device AirPlay password: " AirPlayPass
fi
fi
if [ "$SoundCardInstall" = "y" ]
then
installlog "0. No Sound Card"
installlog "1. HifiBerry DAC Light"
installlog "2. HifiBerry DAC Standard/Pro"
installlog "3. HifiBerry Digi+"
installlog "4. Hifiberry Amp+"
installlog "5. Pi-IQaudIO DAC"
installlog "6. Pi-IQaudIO DAC+, Pi-IQaudIO DACZero, Pi-IQaudIO DAC PRO"
installlog "7. Pi-IQaudIO DigiAMP"
installlog "8. Pi-IQaudIO Digi+"
installlog "9. USB Sound Card"
installlog "10. JustBoom DAC and AMP Cards"
installlog "11. JustBoom Digi Cards"
SoundCard="SoundCard"
while true
do
read -p "Which Sound Card are you using? (0/1/2/3/4/5/6/7/8/9/10/11) : " SoundCard
case "$SoundCard" in
[0-9]|10|11)
break
;;
*)
echo "Please enter a valid choice"
;;
esac
done
else
SoundCard="0"
fi
chmod +x ./*.sh
# Updates and Upgrades the Raspberry Pi
log "Updating via Apt-Get"
apt-get update -y &> /dev/null
log "Upgrading via Apt-Get"
apt-get upgrade -y &> /dev/null
# If Bluetooth is Chosen, it installs Bluetooth Dependencies and issues commands for proper configuration
if [ "$Bluetooth" = "y" ]
then
export BluetoothName
run ./bt_pa_install.sh
VOL_USER=`cat /etc/os-release | grep VOLUMIO_ARCH | sed "s/VOLUMIO_ARCH=//"`
if [ "$VOL_USER" = "\"arm\"" ]
then
export VOL_USER
apt-get purge bluez -y
for _dep in ${VOLUMIO_DEPS[@]}; do
apt_install $_dep;
done
#exc usermod -aG "sudo" $user
vol_groups=`groups $user | sed "s/$user : //"`
sed -i "s/$user ALL=(ALL) ALL/$user ALL=(ALL) NOPASSWD: ALL/" /etc/sudoers
run su ${user} -c ./bt_pa_config.sh
sudo usermod -G "" $user
sed -i "s/$user ALL=(ALL) NOPASSWD: ALL/$user ALL=(ALL) ALL/" /etc/sudoers
for _dep in ${vol_groups[@]}; do sudo usermod -aG "$_dep" volumio; done
else
run su ${user} -c ./bt_pa_config.sh
#for _dep in ${vol_groups[@]}; do usermod -aG "$_dep" $user; done
fi
fi
if [ "$SoundCardInstall" = "y" ]
then
export SoundCard
run ./sound_card_install.sh
fi
# If AirPlay is Chosen, it installs AirPlay Dependencies and issues commands for proper configuration
if [ "$AirPlay" = "y" ]
then
export SoundCard
export AirPlayPass
export AirPlayName
export AirPlay
run ./airplay_install.sh
run ./airplay_config.sh
fi
# If Kodi is Chosen, it installs Kodi Dependencies and issues commands for proper configuration
if [ "$Kodi" = "y" ]
then
run ./kodi_install.sh
run ./kodi_config.sh
fi
# If Lirc is Chosen, it installs Lirc Dependencies and issues commands for proper configuration
if [ "$Lirc" = "y" ]
then
run ./lirc_install.sh
run ./lirc_config.sh
fi
# If GMedia is Chosen, it installs GMedia Dependencies and issues commands for proper configuration
if [ "$GMedia" = "y" ]
then
export GMediaName
run ./gmrender_install.sh
fi
if [ "$SNAPCAST" = "y" ]
then
export SNAPCAST
export SNAPNAME
export AirPlay
export LIBRESPOT
run su ${user} -c ./snapcast_install.sh
fi
# If Access Point is Chosen, it installs AP Dependencies and issues commands for proper configuration
if [ "$AP" = "y" ]
then
export APName
export WIFIPASS
run ./ap_install.sh
run ./ap_config.sh
fi
run cat << EOT > install_choices
Bluetooth = $Bluetooth
AirPlay = $AirPlay
AP = $AP
Kodi = $Kodi
Lirc = $Lirc
SoundCardInstall = $SoundCardInstall
GMedia = $GMedia
Snapcast = $SNAPCAST
EOT
log You should now reboot