X-Git-Url: https://zdv2.bktei.com/gitweb/EVA-2020-02-2.git/blobdiff_plain/651e1c201721a5903d0136d937c234166232c8e3..db36c95ee3cb998b46a5601f07bbd7fa6b169e20:/install.sh?ds=inline diff --git a/install.sh b/install.sh index 13ce97a..5cde03b 100755 --- a/install.sh +++ b/install.sh @@ -1,6 +1,69 @@ #!/bin/bash -printf "{{LIBNAME:UC}} Python Library: Installer\n\n" +CONFIG=/boot/config.txt +DATESTAMP=`date "+%Y-%M-%d-%H-%M-%S"` +CONFIG_BACKUP=false + +CONFIG_VARS=`python - < /dev/null 2>&1 + if [ "$?" == "1" ]; then + PACKAGES+=("$PACKAGE") + fi + done + PACKAGES="${PACKAGES[@]}" + if ! [ "$PACKAGES" == "" ]; then + echo "Installing missing packages: $PACKAGES" + sudo apt update + sudo apt install -y $PACKAGES + fi +} + +eval $CONFIG_VARS + +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" @@ -10,13 +73,36 @@ fi cd library printf "Installing for Python 2..\n" +apt_pkg_install "${PY2_DEPS[@]}" python setup.py install if [ -f "/usr/bin/python3" ]; then printf "Installing for Python 3..\n" + apt_pkg_install "${PY3_DEPS[@]}" python3 setup.py install fi cd .. +for ((i = 0; i < ${#SETUP_CMDS[@]}; i++)); do + CMD="${SETUP_CMDS[$i]}" + # Attempt to catch anything that touches /boot/config.txt and trigger a backup + if [[ "$CMD" == *"raspi-config"* ]] || [[ "$CMD" == *"$CONFIG"* ]] || [[ "$CMD" == *"\$CONFIG"* ]]; then + do_config_backup + fi + eval $CMD +done + +for ((i = 0; i < ${#CONFIG_TXT[@]}; i++)); do + CONFIG_LINE="${CONFIG_TXT[$i]}" + if ! [ "$CONFIG_LINE" == "" ]; then + do_config_backup + printf "Adding $CONFIG_LINE to $CONFIG\n" + sed -i "s/^#$CONFIG_LINE/$CONFIG_LINE/" $CONFIG + if ! grep -q "^$CONFIG_LINE" $CONFIG; then + printf "$CONFIG_LINE\n" >> $CONFIG + fi + fi +done + printf "Done!\n"