forked from mccdaq/daqhats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·79 lines (63 loc) · 1.45 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
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root, i.e 'sudo ./install.sh'" 1>&2
exit 1
fi
# Build / install the C library and headers
echo "Building and installing library"
echo
make -C lib all
make -C lib install
make -C lib clean
echo
# Build / install tools
echo "Building and installing tools"
echo
make -C tools all
make -C tools install
make -C tools clean
echo
# Build examples
echo "Building examples"
echo
make -C examples/c all
echo
# Read HAT EEPROMs to /etc/mcc/hats
echo "Reading DAQ HAT EEPROMs"
echo
daqhats_read_eeproms
echo
echo "Installing library for Python 3"
dpkg-query -l python3-pip &> /dev/null
if [ "$?" != "0" ]; then
apt-get -qy install python3-pip
fi
pip3 install . --upgrade
echo
# Install the Python package
install_py2=0
if [ $(which python | wc -l) -ne 0 ]; then
if [[ $1 == "-y" ]]; then
install_py2=1
else
echo -n "Do you want to install support for Python 2? [y/n] "
read input
if [ "$input" == "y" ]; then
install_py2=1
fi
fi
fi
if [ "$install_py2" == 1 ]; then
echo "Installing library for Python 2"
dpkg-query -l python-pip &> /dev/null
if [ "$?" != "0" ]; then
apt-get -qy install python-pip
fi
pip2 install . --upgrade
fi
echo
# Turn SPI on (needed for some MCC 118s that had incorrectly programmed EEPROMs)
if [ $(raspi-config nonint get_spi) -eq 1 ]; then
raspi-config nonint do_spi 0
fi
echo "Install complete"