forked from DexterInd/GrovePi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
179 lines (165 loc) · 6.42 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
176
177
178
179
#! /bin/bash
echo -e "\E[32m"
echo " _____ _ ";
echo " | __ \ | | ";
echo " | | | | _____ _| |_ ___ _ __ ";
echo " | | | |/ _ \ \/ / __/ _ \ '__| ";
echo " | |__| | __/> <| || __/ | ";
echo " |_____/ \___/_/\_\\__\___|_| _ _ ";
echo " |_ _| | | | | (_) ";
echo " | | _ __ __| |_ _ ___| |_ _ __ _ ___ ___ ";
echo " | | | '_ \ / _\` | | | / __| __| '__| |/ _ \/ __|";
echo " _| |_| | | | (_| | |_| \__ \ |_| | | | __/\__ \ ";
echo " |_____|_| |_|\__,_|\__,_|___/\__|_| |_|\___||___/ ";
echo -e "\E[0m"
echo "Welcome to GrovePi Installer."
echo " "
echo "Requirements:"
echo "1) Must be connected to the internet"
echo "2) This script must be run as root user"
echo " "
echo "Steps:"
echo "1) Installs package dependencies:"
echo " - python-pip alternative Python package installer"
echo " - git fast, scalable, distributed revision control system"
echo " - libi2c-dev userspace I2C programming library development files"
echo " - python-serial pyserial - module encapsulating access for the serial port"
echo " - python-rpi.gpio Python GPIO module for Raspberry Pi"
echo " - i2c-tools This Python module allows SMBus access through the I2C /dev"
echo " - python-smbus Python bindings for Linux SMBus access through i2c-dev"
echo " - arduino AVR development board IDE and built-in libraries"
echo " - minicom friendly menu driven serial communication program"
echo "2) Installs wiringPi in GrovePi/Script"
echo "3) Removes I2C and SPI from modprobe blacklist /etc/modprobe.d/raspi-blacklist.conf"
echo "4) Adds I2C-dev, i2c-bcm2708 and spi-dev to /etc/modules"
echo "5) Installs gertboard avrdude_5.10-4_armhf.deb package"
echo "6) Runs gertboard setup"
echo " - configures avrdude"
echo " - downloads gertboard known boards and programmers"
echo " - replaces avrsetup with gertboards version"
echo " - in /etc/inittab comments out lines containing AMA0"
echo " - in /boot/cmdline.txt removes: console=ttyAMA0,115200 kgdboc=ttyAMA0,115200 console=tty1"
echo " - in /usr/share/arduino/hardware/arduino creates backup of boards.txt"
echo " - in /usr/share/arduino/hardware/arduino creates backup of programmers.txt"
echo " "
echo "Special thanks to Joe Sanford at Tufts University. This script was derived from his work. Thank you Joe!"
echo " "
echo "Raspberry Pi wil reboot after completion."
echo " "
echo -e "Press \E[32mENTER\E[0m to begin... or \E[91mctrl+c\E[0m to abort"
# read
sleep 5
echo " "
echo "Check for internet connectivity..."
echo "=================================="
wget -q --tries=2 --timeout=100 http://google.com
if [ $? -eq 0 ];then
echo "Connected"
else
echo "Unable to Connect, try again !!!"
exit 0
fi
echo " "
echo "Installing Dependencies"
echo "======================="
sudo apt-get install python-pip git libi2c-dev python-serial i2c-tools python-smbus arduino minicom python-dev
sudo apt-get purge python-rpi.gpio -y
sudo apt-get purge python3-rpi.gpio -y
sudo apt-get install python-rpi.gpio
sudo apt-get install python3-rpi.gpio
sudo pip install -U RPi.GPIO
echo "Dependencies installed"
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
echo "wiringPi Installed"
echo " "
echo "Removing blacklist from /etc/modprobe.d/raspi-blacklist.conf . . ."
echo "=================================================================="
if grep -q "#blacklist i2c-bcm2708" /etc/modprobe.d/raspi-blacklist.conf; then
echo "I2C already removed from blacklist"
else
sudo sed -i -e 's/blacklist i2c-bcm2708/#blacklist i2c-bcm2708/g' /etc/modprobe.d/raspi-blacklist.conf
echo "I2C removed from blacklist"
fi
if grep -q "#blacklist spi-bcm2708" /etc/modprobe.d/raspi-blacklist.conf; then
echo "SPI already removed from blacklist"
else
sudo sed -i -e 's/blacklist spi-bcm2708/#blacklist spi-bcm2708/g' /etc/modprobe.d/raspi-blacklist.conf
echo "SPI removed from blacklist"
fi
#Adding in /etc/modules
echo " "
echo "Adding I2C-dev and SPI-dev in /etc/modules . . ."
echo "================================================"
if grep -q "i2c-dev" /etc/modules; then
echo "I2C-dev already there"
else
echo i2c-dev >> /etc/modules
echo "I2C-dev added"
fi
if grep -q "i2c-bcm2708" /etc/modules; then
echo "i2c-bcm2708 already there"
else
echo i2c-bcm2708 >> /etc/modules
echo "i2c-bcm2708 added"
fi
if grep -q "spi-dev" /etc/modules; then
echo "spi-dev already there"
else
echo spi-dev >> /etc/modules
echo "spi-dev added"
fi
echo " "
echo "Making I2C changes in /boot/config.txt . . ."
echo "================================================"
echo dtparam=i2c1=on >> /boot/config.txt
echo dtparam=i2c_arm=on >> /boot/config.txt
sudo adduser pi i2c
sudo chmod +x /home/pi/Desktop/GrovePi/Software/Scratch/GrovePi_Scratch_Scripts/*.sh
#Adding ARDUINO setup files
echo " "
echo "Making changes to Arduino . . ."
echo "==============================="
cd /tmp
wget http://project-downloads.drogon.net/gertboard/avrdude_5.10-4_armhf.deb
sudo dpkg -i avrdude_5.10-4_armhf.deb
sudo chmod 4755 /usr/bin/avrdude
cd /tmp
wget http://project-downloads.drogon.net/gertboard/setup.sh
chmod +x setup.sh
sudo ./setup.sh
echo " "
echo "Install smbus for python"
sudo apt-get install python-smbus
echo " "
echo "Making libraries global . . ."
echo "============================="
sudo cp /home/pi/Desktop/GrovePi/Script/grove.pth /usr/lib/python2.7/dist-packages/grove.pth
echo " "
echo "Please restart to implement changes!"
echo " _____ ______ _____ _______ _____ _______ "
echo " | __ \| ____|/ ____|__ __|/\ | __ \__ __|"
echo " | |__) | |__ | (___ | | / \ | |__) | | | "
echo " | _ /| __| \___ \ | | / /\ \ | _ / | | "
echo " | | \ \| |____ ____) | | |/ ____ \| | \ \ | | "
echo " |_| \_\______|_____/ |_/_/ \_\_| \_\ |_| "
echo " "
echo "Please restart to implement changes!"
echo "To Restart type sudo reboot"
echo "To finish changes, we will reboot the Pi."
echo "Pi must reboot for changes and updates to take effect."
echo "If you need to abort the reboot, press Ctrl+C. Otherwise, reboot!"
echo "Rebooting in 5 seconds!"
sleep 1
echo "Rebooting in 4 seconds!"
sleep 1
echo "Rebooting in 3 seconds!"
sleep 1
echo "Rebooting in 2 seconds!"
sleep 1
echo "Rebooting in 1 seconds!"
sleep 1
echo "Rebooting now! Your Pi wake up with a freshly updated Raspberry Pi!"
sleep 1
sudo reboot