forked from sunfounder/SunFounder_PiCar-S
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_dependencies
executable file
·109 lines (92 loc) · 2.44 KB
/
install_dependencies
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
#!/bin/bash
#Installation
repo_dir=`pwd`
is_installed_python_smbus=false
function if_continue(){
while :; do
echo -e "(yes/no) \c"
read input_item
if [ $input_item = "yes" ]; then
break
elif [ $input_item = "no" ]; then
return 0
else
echo -e "Input error, please try again."
fi
done
return 1
}
function end(){
print_result
echo -e "Exiting..."
exit
}
function print_result(){
echo -e "Installation result:"
echo -e "python-smbus \c"
if [ is_installed_python_smbus ]; then
echo -e "Success"
else
echo -e "Failed"
fi
}
# check if sudo is used
if [ "$(whoami)" != "root" ] ; then
echo -e "You must run setup.sh as root."
end
fi
sudo apt-get update
#sudo apt-get upgrade -y
###################################
# install python-smbus runtime #
###################################
echo -e "\n Installing python-smbus \n"
if sudo apt-get install python-smbus -y;then
echo -e " Successfully installed python-smbus \n"
is_installed_python_smbus=true
else
echo -e " Failed to installed python-smbus \n"
echo -e " Do you want to skip this? \c"
if_continue
if [ $? = 1 ] ; then
echo -e " Skipped django installation."
else
end
fi
fi
###################################
# Install RPi Car V2 Module
###################################
echo -e "Cloning repo \n"
cd ../
git clone --recursive https://github.com/sunfounder/SunFounder_PiCar.git
cd SunFounder_PiCar
echo -e " Installing PiCar module \n"
sudo python3 setup.py install
sudo python setup.py install
cd $repo_dir
echo -e "complete\n"
###################################
# Enable I2C1 #
###################################
# Add lines to /boot/config.txt
echo -e "Enalbe I2C \n"
egrep -v "^#|^$" /boot/config.txt > config.txt.temp # pick up all uncomment configrations
if grep -q 'dtparam=i2c_arm=on' config.txt.temp; then # whether i2c_arm in uncomment configrations or not
echo -e ' Seem i2c_arm parameter already set, skip this step \n'
else
echo -e ' dtparam=i2c_arm=on \n' >> /boot/config.txt
fi
rm config.txt.temp
echo -e "complete\n"
print_result
echo -e "The stuff you have change may need reboot to take effect."
echo -e "Do you want to reboot immediately? \c"
if_continue
if [ $? = 1 ]; then
echo -e "Rebooting..."
sudo reboot
else
echo -e "Exiting..."
exit
fi