-
Notifications
You must be signed in to change notification settings - Fork 1
/
installer.sh
executable file
·192 lines (165 loc) · 4.01 KB
/
installer.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
#!/bin/bash
echo "+--------------------------------------------------------------+"
echo "| |"
echo "| WebRadio Installer v1.0 |"
echo "| |"
echo "| Copyright (C) 2012 by Michael Schwarz |"
echo "| |"
echo "+--------------------------------------------------------------+"
# user must be root
if [[ ${EUID} -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# update package sources
apt-get update
# install required software
if [ ! -f /usr/sbin/avahi-daemon ];
then
echo
echo "Installing avahi-daemon to access webradio as \"raspberrypi.local\""
echo
apt-get install avahi-daemon
fi
if [ ! -f /usr/bin/mpg123 ];
then
echo
echo "Installing mpg123"
echo
apt-get install mpg123
fi
if [ ! -f /usr/bin/id3v2 ];
then
echo
echo "Installing id3v2"
echo
apt-get install id3v2
fi
if [ ! -f /usr/share/usbmount/usbmount ];
then
echo
echo "Installing usbmount"
echo
apt-get install usbmount
fi
if [ ! -f /usr/sbin/lighttpd ];
then
echo
echo "Installing lighthttpd + php5"
echo
apt-get install lighttpd php5-cgi php5-mysql php5-curl php5-gd php5-cgi php5-cli php5-common
echo
echo "Create webserver directory"
echo
mkdir /var/www 2> /dev/null
chown pi:pi /var/www
rm /var/log/lighttpd/error.log
fi
if [ ! -f /usr/local/lib/libwiringPi.a ];
then
echo
echo "Installing wiringPi"
echo
cd tools/wiringPi/wiringPi
make clean 2>&1 > /dev/null
make 2>&1 > /dev/null
make install
cd ../../..
fi
if [ ! -f /usr/include/curl/curl.h ];
then
echo
echo "Installing libcurl"
echo
sudo apt-get install libcurl4-openssl-dev
fi
if [ ! -f /usr/include/libxml2/libxml/parser.h ];
then
echo
echo "Installing libxml2"
echo
sudo apt-get install libxml2-dev
fi
if [ ! -f /usr/include/alsa/asoundlib.h ];
then
echo
echo "Installing libasound2"
echo
apt-get install libasound2-dev
fi
# copy mobile page
echo
echo "Copy mobile page to webserver directory"
echo
cp -R mobile_page/* /var/www/ 2> /dev/null
chown pi:pi /var/www/*
# setup lighthttpd
echo
echo "Settings up lighttpd"
echo
mv /etc/lighttpd/lighttpd.conf /etc/lighttpd/lighthttpd.conf.old
cp lighttpd.conf /etc/lighttpd/lighttpd.conf
/etc/init.d/lighttpd restart
# delete old firmware
echo
echo "Delete old firmware"
echo
rm /home/pi/firmware 2> /dev/null
# build songcontrol
echo
echo "Build songcontrol"
echo
cd interfaces/songcontrol
make clean 2>&1 > /dev/null
make 2>&1 > /dev/null
cd ../..
# build firmware
echo
echo "Build firmware"
echo
cd software
make clean 2>&1 > /dev/null
make 2>&1 > /dev/null
cd ..
# copy file to home folder
echo
echo "Install firmware and songcontrol"
echo
cp interfaces/songcontrol/*.sh /home/pi/ 2> /dev/null
cp interfaces/songcontrol/usb_play /home/pi/ 2> /dev/null
cp interfaces/songcontrol/stream /home/pi/ 2> /dev/null
cp interfaces/songcontrol/play.conf /home/pi/ 2> /dev/null
cp interfaces/*.sh /home/pi 2> /dev/null
cp software/firmware /home/pi/ 2> /dev/null
# set root rights to firmware
echo
echo "Set rights for firmware"
echo
chown root /home/pi/firmware
chmod 4755 /home/pi/firmware
chmod +x /home/pi/*.sh
chown root /home/pi/wifi_connect.sh
chown root /home/pi/wifi_scan.sh
chmod 4755 /home/pi/wifi_connect.sh
chmod 4755 /home/pi/wifi_scan.sh
chmod 0777 song.txt
touch stations.txt
chmod 0777 stations.txt
chmod 0777 current_station.txt
# copy language files
echo
echo "Install language files"
echo
mkdir /home/pi/language 2> /dev/null
cp software/language/*.lng /home/pi/language/ 2> /dev/null
# copy default config
echo
echo "Write default configuration file"
echo
cp software/default.conf /home/pi/ 2> /dev/null
# done
echo "----------------------------------------------------------------"
echo " Installation completed"
echo
echo " To start, type \"cd /home/pi; ./firmware\""
echo "----------------------------------------------------------------"