forked from kylejohnson/Patiobar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·68 lines (62 loc) · 1.71 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
#!/usr/bin/env bash
set -euo pipefail
tls_fingerprint=`openssl s_client -connect tuner.pandora.com:443 < /dev/null 2> /dev/null | openssl x509 -noout -fingerprint | tr -d ':' | cut -d'=' -f2`
event_command=${PWD}/eventcmd.sh
fifo=${PWD}/ctl
configdir=~/.config/pianobar
repo='https://github.com/kylejohnson/Patiobar.git'
if ! which npm &> /dev/null; then
echo "npm is not installed!"
echo "Installing NPM is beyond the scope of this installer as methods vary by distro, OS and preference."
echo "Note that NPM is usually installed with Node.js."
echo "https://nodejs.org/en/download/ is a decent place to start."
exit 1;
fi
# Don't clone if already in the repo
if [ ! -d .git ]; then
if git clone "${repo}"; then
cd Patiobar
else
echo "Could not clone ${repo}"
exit 1
fi
fi
# Don't run npm install if it has already ran
if [ ! -d node_modules ]; then
echo -n 'Running `npm install`... '
if npm install > /dev/null 2>&1; then
echo "success"
else
echo "failure"
fi
fi
# Don't create fifo if it already exists
if [ ! -p "${fifo}" ]; then
echo -n "Creating ${fifo} control file... "
if mkfifo "${fifo}" > /dev/null 2>&1; then
echo "success"
else
echo "failure"
fi
fi
echo -n "Creating default ~/.config/pianobar/config file... "
if mkdir -p "${configdir}"; then
if ! [ -f "${configdir}/config" ]; then
if cat << EOF >> "${configdir}/config"; then
user = [email protected]
password = password
#autostart_station = 123456
audio_quality = high
buffer_seconds = 0
event_command = ${event_command}
fifo = ${fifo}
tls_fingerprint = ${tls_fingerprint}
EOF
echo "success"
else
echo "failure"
fi
else
echo "${configdir}/config already exists"
fi
fi