-
Notifications
You must be signed in to change notification settings - Fork 87
/
install.sh
executable file
·175 lines (161 loc) · 7.02 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
#!/bin/bash
#
# Copyright (C) 2011-2020 Aratelia Limited - Juan A. Rubio and contributors
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Script that installs Tizonia's debian packages and their dependencies.
#
# NEWS banner is disabled until the time comes to re-enable it
# echo "============================== NEWS =================================="
# echo "Tizonia v0.22.0 has been released recently (2020/05/23)."
# echo "Debian packaging is in progress and new binaries will soon be available!"
# echo "Please bear with us while we finalize the release. Check back soon!."
# echo "======================================================================"
# exit 0
# Make sure the installation happens safely
if [[ "$(id -u)" -eq 0 ]]; then
if [[ ( -z "$1" ) || ( "$1" != "--safe" ) ]]; then
echo "WARNING: Running as root; installation aborted."
echo "Please add '--safe' to bypass this check and continue installing as root."
exit 1
else
echo "WARNING: Running as root with --safe option; installation continues..."
fi
fi
# Run the install actions in a subshell
(
RELIDS=$(cat /etc/*-release)
if echo "$RELIDS" | grep raspbian; then
DISTRO="raspbian"
if echo "$RELIDS" | grep buster; then
RELEASE="buster" ; PYVER=3 ; MOPRELEASE="buster"
elif echo "$RELIDS" | grep stretch; then
RELEASE="stretch"; PYVER=2 ; MOPRELEASE="stretch"
elif echo "$RELIDS" | grep jessie; then
RELEASE="jessie" ; PYVER=2 ; MOPRELEASE="jessie"
else
echo "Can't find a supported Raspbian distribution."
exit 1
fi
elif echo "$RELIDS" | grep stretch; then
DISTRO="debian" ; RELEASE="stretch" ; PYVER=2 ; MOPRELEASE="stretch"
elif echo "$RELIDS" | grep -E 'buster'; then
DISTRO="debian" ; RELEASE="buster" ; PYVER=3 ; MOPRELEASE="buster"
elif echo "$RELIDS" | grep -E 'bullseye|kali-rolling'; then
# NOTE: Kali Linux is based on Debian Testing, which is currently codenamed 'Bullseye'
DISTRO="debian" ; RELEASE="bullseye" ; PYVER=3 ; MOPRELEASE="buster"
elif echo "$RELIDS" | grep -E 'trusty|freya|qiana|rebecca|rafaela|rosa'; then
# NOTE: Elementary OS 'freya' is based on trusty
# NOTE: LinuxMint 'qiana' 'rebecca' 'rafaela' 'rosa' are all based on trusty
DISTRO="ubuntu" ; RELEASE="trusty" ; PYVER=2 ; MOPRELEASE="jessie"
elif echo "$RELIDS" | grep vivid; then
DISTRO="ubuntu" ; RELEASE="vivid" ; PYVER=2 ; MOPRELEASE="jessie"
elif echo "$RELIDS" | grep -E 'xenial|loki|sarah|serena|sonya|sylvia'; then
# NOTE: Elementary OS 'loki' is based on xenial
# NOTE: Linux Mint 'sarah', 'serena', 'sonya' and 'sylvia' are based on xenial
DISTRO="ubuntu" ; RELEASE="xenial" ; PYVER=2 ; MOPRELEASE="jessie"
elif echo "$RELIDS" | grep -E 'bionic|juno|hera|tara|tessa|tina|tricia'; then
# NOTE: Elementary OS 'juno', and 'hera' are based on bionic
# NOTE: Linux Mint 'tara', 'tessa', 'tina', and 'tricia' are based on bionic
# NOTE: Most of the time, binaries compiled on 18.04 will work on newer
# releases, meaning you can try adding newer releases to the bionic conditional
# (e.g. 'disco|bionic|juno|...'), to support installation on a newer system;
# however, do this 'at your own risk', as not all features will be guaranteed to work.
DISTRO="ubuntu" ; RELEASE="bionic" ; PYVER=3 ; MOPRELEASE="stretch"
elif echo "$RELIDS" | grep -E 'focal'; then
DISTRO="ubuntu" ; RELEASE="focal" ; PYVER=3 ; MOPRELEASE="buster"
else
echo "Can't find a supported Debian or Ubuntu-based distribution."
exit 1
fi
# Let's make sure these packages are already installed before trying to install
# anything else. Some of these packages are needed to make sure that Tizonia's
# Python dependencies are correctly installed from PIP.
sudo apt-get -y --force-yes install build-essential git curl apt-transport-https libffi-dev libssl-dev libxml2-dev libxslt1-dev
if [[ "$?" -ne 0 ]]; then
echo "Oops. Some important dependencies failed to install!."
echo "Please re-run the install script."
exit 1
fi
# Add Mopidy's APT archive
if [[ ! -f /etc/apt/sources.list.d/mopidy.list ]]; then
echo "Setting up Mopidy's APT archive for $DISTRO:$MOPRELEASE (to install 'libspotify')"
curl 'https://apt.mopidy.com/mopidy.gpg' | sudo apt-key add -
sudo curl https://apt.mopidy.com/$MOPRELEASE.list -o /etc/apt/sources.list.d/mopidy.list
fi
# Add Tizonia's APT archive
grep -q "dl.bintray.com/tizonia" /etc/apt/sources.list
if [[ "$?" -eq 1 ]]; then
echo "Setting up Tizonia's Bintray APT archive for $DISTRO:$RELEASE"
curl -k 'https://bintray.com/user/downloadSubjectPublicKey?username=tizonia' | sudo apt-key add -
printf "\n" | sudo tee -a /etc/apt/sources.list
echo "deb https://dl.bintray.com/tizonia/$DISTRO $RELEASE main" | sudo tee -a /etc/apt/sources.list
fi
# Resynchronize APT's package index files
sudo apt-get update
# Python dependencies (NOTE: using pip2 or pip3 depending on which Python
# version is required for the version of Tizonia being installed.
if [[ PYVER=3 ]]; then
sudo apt-get -y install python3-dev python3-pip \
&& sudo -H pip3 install --upgrade \
gmusicapi \
soundcloud \
youtube-dl \
pafy \
pycountry \
titlecase \
pychromecast \
plexapi \
spotipy \
fuzzywuzzy \
eventlet \
python-Levenshtein \
joblib
else
sudo apt-get -y install python-dev python-pip \
&& sudo -H pip2 install --upgrade \
gmusicapi \
soundcloud \
youtube-dl \
pafy \
pycountry \
titlecase \
pychromecast \
plexapi \
fuzzywuzzy \
eventlet \
python-Levenshtein \
&& sudo -H pip2 install git+https://github.com/plamere/spotipy.git --upgrade
fi
# Install 'libspotify'
if [[ "$?" -eq 0 ]]; then
sudo apt-get -y install libspotify12
fi
# Install Tizonia
if [[ "$?" -eq 0 ]]; then
sudo apt-get -y install tizonia-all
fi
# Simple test to verify that everything went well
TIZ_CONFIG_FILE="$HOME/.config/tizonia/tizonia.conf"
which tizonia > /dev/null
if [[ "$?" -eq 0 ]]; then
echo ; tizonia ; echo
printf "Tizonia is now installed.\n\n"
printf "Please add Spotify, Google Music, Soundcloud, and Plex credentials to : $TIZ_CONFIG_FILE\n"
else
echo "Oops. Something went wrong!"
exit 1
fi
) # end running in a subshell