From 3756531b0e425532b23a05d6d27ad2aa2fd358e9 Mon Sep 17 00:00:00 2001 From: Christian Rotzoll Date: Wed, 13 Mar 2019 18:13:49 +0100 Subject: [PATCH] #322 install checks on RTL --- home.admin/00settingsMenuServices.sh | 20 ++++++++++----- home.admin/config.scripts/bonus.rtl.sh | 35 ++++++++++++++++++++++---- 2 files changed, 44 insertions(+), 11 deletions(-) diff --git a/home.admin/00settingsMenuServices.sh b/home.admin/00settingsMenuServices.sh index 843f77b..51f592d 100644 --- a/home.admin/00settingsMenuServices.sh +++ b/home.admin/00settingsMenuServices.sh @@ -172,13 +172,21 @@ if [ "${rtlWebinterface}" != "${choice}" ]; then echo "RTL Webinterface Setting changed .." anychange=1 sudo /home/admin/config.scripts/bonus.rtl.sh ${choice} + errorOnInstall=$? if [ "${choice}" = "on" ]; then - localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') - l1="RTL web servcie will be ready AFTER NEXT REBOOT:" - l2="Try to open the following URL in your local webrowser" - l3="and login with your PASSWORD B." - l4="---> http://${localip}:3000" - dialog --title 'OK' --msgbox "${l1}\n${l2}\n${l3}\n${l4}" 11 65 + if [ ${errorOnInstall} -eq 0 ]; then + localip=$(ip addr | grep 'state UP' -A2 | tail -n1 | awk '{print $2}' | cut -f1 -d'/') + l1="RTL web servcie will be ready AFTER NEXT REBOOT:" + l2="Try to open the following URL in your local webrowser" + l3="and login with your PASSWORD B." + l4="---> http://${localip}:3000" + dialog --title 'OK' --msgbox "${l1}\n${l2}\n${l3}\n${l4}" 11 65 + else + l1="!!! FAIL on RTL install !!!" + l2="Try manual install on terminal after rebootwith:" + l3="sudo /home/admin/config.scripts/bonus.rtl.sh on" + dialog --title 'FAIL' --msgbox "${l1}\n${l2}\n${l3}" 10 65 + fi fi needsReboot=1 else diff --git a/home.admin/config.scripts/bonus.rtl.sh b/home.admin/config.scripts/bonus.rtl.sh index 26781e5..5e2b77d 100755 --- a/home.admin/config.scripts/bonus.rtl.sh +++ b/home.admin/config.scripts/bonus.rtl.sh @@ -29,9 +29,6 @@ sudo systemctl stop RTL 2>/dev/null if [ "$1" = "1" ] || [ "$1" = "on" ]; then echo "*** INSTALL RTL ***" - # setting value in raspi blitz config - sudo sed -i "s/^rtlWebinterface=.*/rtlWebinterface=on/g" /mnt/hdd/raspiblitz.conf - isInstalled=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service') if [ ${isInstalled} -eq 0 ]; then @@ -42,18 +39,42 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then sudo apt-get install -y nodejs echo "" + # check if nodeJS was installed + nodeJSInstalled=$(node -v | grep -c "v11.") + if [ nodeJSInstalled -eq 0 ]; then + echo "FAIL - Was not able to install nodeJS 11" + echo "ABORT - RTL install" + exit 1 + fi + # download source code and set to tag release echo "*** Get the RTL Source Code ***" git clone https://github.com/ShahanaFarooqui/RTL.git cd RTL - git reset --hard v0.2.1 - #git reset --hard v0.1.14-alpha + git reset --hard v0.2.15 + # check if node_modles exists now + if [ -d "/home/admin/RTL" ]; then + echo "OK - RTL code copy looks good" + else + echo "FAIL - code copy did not run correctly" + echo "ABORT - RTL install" + exit 1 + fi + echo "" # install echo "*** Run: npm install ***" npm install cd .. + # check if node_modles exists now + if [ -d "/home/admin/RTL/node_modules" ]; then + echo "OK - RTL install looks good" + else + echo "FAIL - npm install did not run correctly" + echo "ABORT - RTL install" + exit 1 + fi echo "" # prepare RTL.conf file @@ -77,10 +98,14 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then sudo sed -i "s|chain/bitcoin/mainnet|chain/${network}/${chain}net|" /etc/systemd/system/RTL.service sudo systemctl enable RTL echo "OK - RTL is now ACTIVE" + else echo "RTL already installed." fi + # setting value in raspi blitz config + sudo sed -i "s/^rtlWebinterface=.*/rtlWebinterface=on/g" /mnt/hdd/raspiblitz.conf + echo "needs reboot to activate new setting" exit 0 fi