Merge branch 'master' of github.com:pimoroni/enviroplus-python
[EVA-2020-02-2.git] / uninstall.sh
index ba44d0a3954b72e76c2eae613c20937227bb2db3..aaac11b280bdfc32ddb60df03aaa2a3ad55cd065 100755 (executable)
@@ -1,8 +1,9 @@
 #!/bin/bash
 
 #!/bin/bash
 
-PACKAGE="{{LIBNAME}}"
+LIBRARY_VERSION=`cat library/setup.py | grep version | awk -F"'" '{print $2}'`
+LIBRARY_NAME=`cat library/setup.py | grep name | awk -F"'" '{print $2}'`
 
 
-printf "{{LIBNAME:UC}} Python Library: Uninstaller\n\n"
+printf "$LIBRARY_NAME $LIBRARY_VERSION Python Library: Uninstaller\n\n"
 
 if [ $(id -u) -ne 0 ]; then
        printf "Script must be run as root. Try 'sudo ./uninstall.sh'\n"
 
 if [ $(id -u) -ne 0 ]; then
        printf "Script must be run as root. Try 'sudo ./uninstall.sh'\n"
@@ -12,13 +13,21 @@ fi
 cd library
 
 printf "Unnstalling for Python 2..\n"
 cd library
 
 printf "Unnstalling for Python 2..\n"
-pip uninstall $PACKAGE
+pip uninstall $LIBRARY_NAME
 
 if [ -f "/usr/bin/pip3" ]; then
        printf "Uninstalling for Python 3..\n"
 
 if [ -f "/usr/bin/pip3" ]; then
        printf "Uninstalling for Python 3..\n"
-       pip3 uninstall $PACKAGE
+       pip3 uninstall $LIBRARY_NAME
 fi
 
 cd ..
 
 fi
 
 cd ..
 
+printf "Disabling serial..\n"
+# Enable serial terminal over /dev/ttyAMA0
+raspi-config nonint do_serial 0
+# Disable serial port
+raspi-config nonint set_config_var enable_uart 0 /boot/config.txt
+# Switch serial port back to miniUART
+sed -i 's/^dtoverlay=pi3-miniuart-bt/#dtoverlay=pi3-miniuart-bt/' /boot/config.txt
+
 printf "Done!\n"
 printf "Done!\n"