-
Notifications
You must be signed in to change notification settings - Fork 1
/
install.sh
executable file
·157 lines (123 loc) · 4.74 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
#!/usr/bin/bash
DIR_PWD=$(pwd)
DIR_ENV=$HOME/python-apps
DIR_APP=$DIR_ENV/oceaneyes
chmod +x $DIR_PWD/*.sh
chmod +x $DIR_PWD/*.py
echo -e "[i] Please make sure that your known SkyTune Radios are connected to the same network as this server"
echo -e " - And that they are turned on so they can be detected!\n\n"
while true; do
read -p "[Q] Radios on and ready to continue? (y/n)" yn
case $yn in
[Yy]* ) echo "" ; break;;
[Nn]* ) exit; break;;
* ) echo "Please answer yes or no.";;
esac
done
# Deal with YouTube Downloading
# yt-dlp: The minimum recommended Python version has been raised to 3.8
#rm -f /usr/bin/yt-dlp
#sudo mv -f /usr/bin/yt-dlp /usr/bin/yt-dlp.bckup
# Detect Raspberry Pi ARM
ARC=$(uname -m)
if [[ "${ARC}" == "aarch64" ]]; then
# RPI
sudo wget -O /usr/bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/download/2023.09.24/yt-dlp_linux_aarch64
sudo chmod a+x /usr/bin/yt-dlp
else
# X86
sudo wget -nc -O /usr/bin/yt-dlp https://github.com/yt-dlp/yt-dlp/releases/latest/download/yt-dlp_linux
sudo chmod a+x /usr/bin/yt-dlp
fi
sudo apt install -y python3-dev
sudo apt install -y portaudio19-dev
sudo apt install -y wget vlc ffmpeg icecast2
sudo sed -i 's|<port>8000</port>|<port>3345</port>|g' /etc/icecast2/icecast.xml
sudo sed -i 's|hackme|<port>rdo</port>|g' /etc/icecast2/icecast.xml
sudo /etc/init.d/icecast2 restart
# VENV - Setup
VER_PYT=$(python3 --version | cut -d " " -f2 | cut -d "." -f1-2 | cut -d "" -f1)
if (( $(echo "$VER_PYT == 3.9" | bc -l ) )); then
sudo apt install -y python3.9-venv
else
sudo apt install -y python3-venv
fi
mkdir -p $DIR_ENV && cd $DIR_ENV
# VENV - OceanEyes
python3 -m venv oceaneyes
source $DIR_APP/bin/activate
# VENV - Install requirements
mkdir -p $DIR_APP/app
cd $DIR_APP
cp $DIR_PWD/*.sh $DIR_APP/app
cp $DIR_PWD/*.db $DIR_APP/app
cp $DIR_PWD/*.py $DIR_APP/app
cp $DIR_PWD/export-rpp.json $DIR_APP/app
cp $DIR_PWD/requirements.txt ./
#pip install -r requirements.txt
$DIR_APP/bin/pip3 install -r $DIR_APP/requirements.txt
echo -e "\n\n[i] Installed requirements in the venv ..."
$DIR_APP/bin/pip list && echo -e "\n\n"
mv -f $DIR_APP/app/run.sh $DIR_APP
rm -f $DIR_APP/app/install.sh
# TODO: Support other init systems
install_service () {
echo -e "\n\n[i] Installing service, in systemd use 'sudo systemctl disable oe.service' to stop it running on boot ..."
echo -e "[i] To see the status of the service use 'watch systemctl status oe.service'"
cp $DIR_PWD/oe.service $DIR_PWD/oe.service.tmp
sed -i "s|~/|$HOME/|g" $DIR_PWD/oe.service.tmp
cp $DIR_PWD/oe.start $DIR_APP
cp $DIR_PWD/oe.stop $DIR_APP
cp $DIR_PWD/oe.status $DIR_APP
sudo mv $DIR_PWD/oe.service.tmp /lib/systemd/system/oe.service
sudo systemctl daemon-reload
sudo systemctl enable oe.service
sudo systemctl start oe.service
echo -e "\n[i] An automated scan will take about 5 to 10 minutes to complete, please wait for this to complete."
# watch systemctl status oe.service
gnome-terminal -e "watch systemctl status oe.service" &
while true
do
sleep 5
if [ -f $HOME/.oceaneyes ]; then
firefox http://$(hostname -I | awk '{print $1}'):1929/docs &
break
rm $HOME/.oceaneyes
fi
done
}
install_startup () {
echo -e "\n\n"
echo -e "[i] To run go to ~/python-apps/oceaneyes"
echo -e "$ ./run.sh\n\n"
echo -e "[i] OR to manually start the server in a python venv follow these steps:\n"
echo "$ cd ~/python-apps/oceaneyes"
echo "$ source bin/activate oceaneyes"
echo "$ cd app"
echo "$ ../bin/python3 main.py"
echo -e "\n\n"
echo -e "[i] To re/scan for radios on the network, make sure all your known devices are switched on ..."
echo -e "$ cd ~/python-apps/oceaneyes/app"
echo -e "$ ./scan.py"
cd $DIR_APP/app
$DIR_APP/app/scan.py
cd $DIR_PWD
}
while true; do
read -p "[Q] Run Oceaneyes as a service? (y/n)" yn
case $yn in
[Yy]* ) install_service; break;;
[Nn]* ) install_startup; break;;
* ) echo "Please answer yes or no.";;
esac
done
echo -e "\n\n[i] While the server is starting, turn on your internet radio device then open a browser tab to http://yourip:1929/v1/device/scan"
echo "[i] Scanning for devices may take about 5 minutes"
echo "[i] When done ..."
echo "[i] - Try setting your active radio device index in a browser tab: http://yourip:1929/v1/1/activate"
echo "[i] - Try seeing if the status of your device is online: http://yourip:1929/v1/1/status"
echo "[i] - Try seeing what online radio station is currently playing on your device: http://yourip:1929/v1/1/playing"
echo "[i] - To play preset 16 copy to a browser tab: http://yourip:1929/v1/1/fav/play/16"
echo "[i] - To back up the non-skytune URL's on your device: http://yourip:1929/v1/1/fav/backup'"
echo -e "\n\n"
echo -e "\n[i] To test the rest of the API go to http://yourip:1929/docs\n\n"