forked from ryanwa18/spotipi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·76 lines (61 loc) · 2.36 KB
/
setup.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
#!/bin/bash
echo "Installing spotipy library:"
pip install spotipy --upgrade
echo "Installing flask library:"
pip install flask --upgrade
echo "Installing Sense HAT library:"
sudo apt-get install sense-hat
echo "Installing Pillow library:"
sudo pip install pillow --upgrade
echo "Enter your Spotify Client ID:"
read spotify_client_id
echo "Enter your Spotify Client Secret:"
read spotify_client_secret
echo "Enter your Spotify Redirect URI:"
read spotify_redirect_uri
echo "Enter your spotify username:"
read spotify_username
echo "Enter the full path to your spotify token:"
read spotify_token_path
install_path=$(pwd)
echo "Removing spotipi service if it exists:"
sudo systemctl stop spotipi
sudo rm -rf /etc/systemd/system/spotipi.*
sudo systemctl daemon-reload
echo "...done"
echo "Removing spotipi-client service if it exists:"
sudo systemctl stop spotipi-client
sudo rm -rf /etc/systemd/system/spotipi-client.*
sudo systemctl daemon-reload
echo "...done"
echo "Creating spotipi service:"
sudo cp ./config/spotipi.service /etc/systemd/system/
sudo sed -i -e "/\[Service\]/a ExecStart=python ${install_path}/python/displayCoverArt.py ${spotify_username} ${spotify_token_path} < /dev/zero &> /dev/null &" /etc/systemd/system/spotipi.service
sudo mkdir /etc/systemd/system/spotipi.service.d
spotipi_env_path=/etc/systemd/system/spotipi.service.d/spotipi_env.conf
sudo touch $spotipi_env_path
sudo echo "[Service]" >> $spotipi_env_path
sudo echo "Environment=\"SPOTIPY_CLIENT_ID=${spotify_client_id}\"" >> $spotipi_env_path
sudo echo "Environment=\"SPOTIPY_CLIENT_SECRET=${spotify_client_secret}\"" >> $spotipi_env_path
sudo echo "Environment=\"SPOTIPY_REDIRECT_URI=${spotify_redirect_uri}\"" >> $spotipi_env_path
sudo systemctl daemon-reload
sudo systemctl start spotipi
sudo systemctl enable spotipi
echo "...done"
echo "Creating spotipi-client service:"
sudo cp ./config/spotipi-client.service /etc/systemd/system/
sudo sed -i -e "/\[Service\]/a ExecStart=python ${install_path}/python/client/app.py &" /etc/systemd/system/spotipi-client.service
sudo systemctl daemon-reload
sudo systemctl start spotipi-client
sudo systemctl enable spotipi-client
echo "...done"
echo -n "In order to finish setup a reboot is necessary..."
echo -n "REBOOT NOW? [y/N] "
read
if [[ ! "$REPLY" =~ ^(yes|y|Y)$ ]]; then
echo "Exiting without reboot."
exit 0
fi
echo "Reboot started..."
reboot
sleep infinity