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