3 LIBRARY_VERSION
=`cat library/setup.py | grep version | awk -F"'" '{print $2}'`
4 LIBRARY_NAME
=`cat library/setup.py | grep name | awk -F"'" '{print $2}'`
5 CONFIG
=/boot
/config.txt
6 DATESTAMP
=`date "+%Y-%M-%d-%H-%M-%S"`
8 printf "$LIBRARY_NAME $LIBRARY_VERSION Python Library: Installer\n\n"
10 if [ $
(id
-u) -ne 0 ]; then
11 printf "Script must be run as root. Try 'sudo ./install.sh'\n"
17 printf "Installing for Python 2..\n"
18 python setup.py
install
20 if [ -f "/usr/bin/python3" ]; then
21 printf "Installing for Python 3..\n"
22 python3 setup.py
install
27 printf "Backing up $CONFIG\n"
28 cp $CONFIG "config.preinstall-$DATESTAMP.txt"
30 printf "Setting up i2c and SPI..\n"
31 raspi-config nonint do_spi
0
32 raspi-config nonint do_i2c
0
34 printf "Setting up serial for PMS5003..\n"
35 # Disable serial terminal over /dev/ttyAMA0
36 raspi-config nonint do_serial
1
38 raspi-config nonint set_config_var enable_uart
1 $CONFIG
39 # Switch serial port to full UART for stability (may adversely affect bluetooth)
40 sed -i 's/^#dtoverlay=pi3-miniuart-bt/dtoverlay=pi3-miniuart-bt/' $CONFIG
41 if ! grep -q -E "^dtoverlay=pi3-miniuart-bt" $CONFIG; then
42 printf "dtoverlay=pi3-miniuart-bt\n" >> $CONFIG