forked from beagleboard/librobotcontrol
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·149 lines (123 loc) · 4.41 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
#!/bin/bash
# Bash script to install supporting software for the Robotics Cape
# This is specifically for Debian Jessie
################################################################################
# Variables collected here for convenience
################################################################################
KERNEL="$(uname -r)"
DEBIAN="$(cat /etc/debian_version)"
MODEL="$(cat /proc/device-tree/model)"
DOGTAG="$(cat /etc/dogtag)"
echo " "
echo "Detected Linux kernel: $KERNEL"
echo "Detected Debian version: $DEBIAN"
echo "Detected Model: $MODEL"
echo "Detected $DOGTAG"
echo " "
echo " "
# kernel version check
MINDEBIAN=8.6
MINKERNEL="4.4.32"
function version_lt() { test "$(echo "$@" | tr " " "\n" | sort -rV | head -n 1)" != "$1"; }
################################################################################
# Sanity Checks
################################################################################
# make sure the user is root
if [ `whoami` != 'root' ]; then
echo "You must be root to install this."
exit 1
fi
# make sure the release is really jessie
if ! grep -q "8." /etc/debian_version ; then
echo "ERROR: This is not Debian Jessie."
echo "Flash the latest Jessie image to your BBB"
echo "or use the Wheezy branch of this installer."
exit 1
fi
# check that the remoteproc driver is there
if modprobe -n remoteproc | grep -q "not found" ; then
echo "ERROR: remoteproc module not found"
echo "Use a standard TI kernel with remoteproc instead."
exit 1
fi
# debian version check
if version_lt $DEBIAN $MINDEBIAN; then
echo "WARNING: Debian version $MINDEBIAN or newer is required"
exit 1
fi
# kernel version check
if version_lt $KERNEL $MINKERNEL; then
echo "WARNING: Kernel $MINKERNEL or newer is required for full functionality"
echo "Motor 1, PINMUX, and PRU functions will not work as-is"
echo "You may still continue the installation"
echo " "
fi
# make sure the user really wants to install
echo "This script will install all Robotics Cape supporting software"
read -r -p "Continue? [y/n] " response
case $response in
[yY]) echo " " ;;
*) echo "cancelled"; exit;;
esac
echo " "
################################################################################
# Compile and install library, examples, and services
# This works for Black and Blue
################################################################################
find . -exec touch {} \;
bash debian/preinst
make clean
make install
ldconfig
###############################################################################
# Normally the package manager would call postinst here, but we don't want
# to invoke debconf when installing from source, so we re-implement the
# postinst script here
##############################################################################
# enable services
echo "systemctl daemon-reload"
systemctl daemon-reload
echo "Enabling roboticscape Service"
systemctl enable roboticscape
# don't enable battery_monitor on BB Green Wireless
if [ ! "$MODEL" == "TI AM335x BeagleBone Green Wireless" ]; then
echo "Enabling rc_battery_monitor Service"
systemctl enable rc_battery_monitor
echo "Starting rc_battery_monitor Service"
systemctl start rc_battery_monitor
fi
echo "Configuring Device Tree"
bash /usr/bin/configure_robotics_dt.sh
#################################################
# Prompt user for desired startup program
#################################################
echo " "
echo "Which program should run on boot?"
echo "Select 'rc_blink' if you are unsure."
echo "Select 'rc_balance' for BeagleMiP"
echo "Select 'none' to start nothing on boot"
echo "Select 'existing' to keep current configuration."
echo "type 1-4 then enter"
select bfn in "rc_blink" "rc_balance" "none" "existing"; do
case $bfn in
rc_blink ) PROG="rc_blink"; break;;
rc_balance ) PROG="rc_balance"; break;;
none ) PROG="rc_bare_minimum"; break;;
existing ) PROG="existing"; break;;
esac
done
# now make a link to the right program
# if 'none' was selected then leave default as bare_minimum (does nothing)
if [ "$PROG" == "rc_blink" ]; then
ln -s -f /usr/bin/rc_blink /etc/roboticscape/link_to_startup_program
elif [ "$PROG" == "rc_balance" ]; then
ln -s -f /usr/bin/rc_balance /etc/roboticscape/link_to_startup_program
elif [ "$PROG" == "none" ]; then
ln -s -f /usr/bin/rc_bare_minimum /etc/roboticscape/link_to_startup_program
fi
echo " "
echo " "
echo " "
echo "Robotics Cape package installation complete."
echo "Please reboot now."
echo " "