forked from pimoroni/enviroplus-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·45 lines (34 loc) · 1.21 KB
/
install.sh
File metadata and controls
executable file
·45 lines (34 loc) · 1.21 KB
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
#!/bin/bash
LIBRARY_VERSION=`cat library/setup.py | grep version | awk -F"'" '{print $2}'`
LIBRARY_NAME=`cat library/setup.py | grep name | awk -F"'" '{print $2}'`
CONFIG=/boot/config.txt
DATESTAMP=`date "+%Y-%M-%d-%H-%M-%S"`
printf "$LIBRARY_NAME $LIBRARY_VERSION Python Library: Installer\n\n"
if [ $(id -u) -ne 0 ]; then
printf "Script must be run as root. Try 'sudo ./install.sh'\n"
exit 1
fi
cd library
printf "Installing for Python 2..\n"
python setup.py install
if [ -f "/usr/bin/python3" ]; then
printf "Installing for Python 3..\n"
python3 setup.py install
fi
cd ..
printf "Backing up $CONFIG\n"
cp $CONFIG "config.preinstall-$DATESTAMP.txt"
printf "Setting up i2c and SPI..\n"
raspi-config nonint do_spi 0
raspi-config nonint do_i2c 0
printf "Setting up serial for PMS5003..\n"
# Disable serial terminal over /dev/ttyAMA0
raspi-config nonint do_serial 1
# Enable serial port
raspi-config nonint set_config_var enable_uart 1 $CONFIG
# Switch serial port to full UART for stability (may adversely affect bluetooth)
sed -i 's/^#dtoverlay=pi3-miniuart-bt/dtoverlay=pi3-miniuart-bt/' $CONFIG
if ! grep -q -E "^dtoverlay=pi3-miniuart-bt" $CONFIG; then
printf "dtoverlay=pi3-miniuart-bt\n" >> $CONFIG
fi
printf "Done!\n"