-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_banana.sh
60 lines (55 loc) · 1.73 KB
/
setup_banana.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
#!/bin/bash
# file: setup_banana.sh
#
# This script will enable I2C and install i2c-tools on your Raspberry Pi
#
# You will need to have your Raspberry Pi connected to the Internet, and use “sudo sh setup-i2c.sh” to run this script.
#
# check if sudo is used
if [ "$(id -u)" != 0 ]; then
echo 'Sorry, you need to run this script with sudo'
exit 1
fi
# enable I2C on Raspberry Pi
echo '>>> Enable I2C'
if grep -q 'i2c-bcm2708' /etc/modules; then
echo 'Seems i2c-bcm2708 module already exists, skip this step.'
else
echo 'i2c-bcm2708' >> /etc/modules
fi
if grep -q 'i2c-dev' /etc/modules; then
echo 'Seems i2c-dev module already exists, skip this step.'
else
echo 'i2c-dev' >> /etc/modules
fi
if grep -q 'dtparam=i2c1=on' /boot/config.txt; then
echo 'Seems i2c1 parameter already set, skip this step.'
else
echo 'dtparam=i2c1=on' >> /boot/config.txt
fi
if grep -q 'dtparam=i2c_arm=on' /boot/config.txt; then
echo 'Seems i2c_arm parameter already set, skip this step.'
else
echo 'dtparam=i2c_arm=on' >> /boot/config.txt
fi
if [ -f /etc/modprobe.d/raspi-blacklist.conf ]; then
sed -i 's/^blacklist spi-bcm2708/#blacklist spi-bcm2708/' /etc/modprobe.d/raspi-blacklist.conf
sed -i 's/^blacklist i2c-bcm2708/#blacklist i2c-bcm2708/' /etc/modprobe.d/raspi-blacklist.conf
else
echo 'File raspi-blacklist.conf does not exist, skip this step.'
fi
# install i2c-tools
echo '>>> Install i2c-tools'
if hash i2cget 2>/dev/null; then
echo 'Seems i2c-tools is installed already, skip this step.'
else
apt-get install -y i2c-tools
fi
# install Adafruit MPR121 library
unzip Adafruit_Python_MPR121-master.zip
cd Adafruit_Python_MPR121-master
python setup.py install
# move the code and wav files
cd ..
mv *.wav /var/www
mv bananadrum.py /var/www