2018-12-02 19:52:01 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# command info
|
|
|
|
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
|
|
|
|
echo "small config script to switch WebGUI RideTheLightning on or off"
|
|
|
|
echo "bonus.rtl.sh [on|off]"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# check and load raspiblitz config
|
|
|
|
# to know which network is running
|
2019-02-02 23:49:04 +01:00
|
|
|
source /home/admin/raspiblitz.info
|
2018-12-03 17:24:17 +01:00
|
|
|
source /mnt/hdd/raspiblitz.conf
|
2018-12-02 19:52:01 +01:00
|
|
|
if [ ${#network} -eq 0 ]; then
|
|
|
|
echo "FAIL - missing /mnt/hdd/raspiblitz.conf"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-12-02 21:46:00 +01:00
|
|
|
# add default value to raspi config if needed
|
|
|
|
if [ ${#rtlWebinterface} -eq 0 ]; then
|
|
|
|
echo "rtlWebinterface=off" >> /mnt/hdd/raspiblitz.conf
|
|
|
|
fi
|
|
|
|
|
2018-12-02 19:52:01 +01:00
|
|
|
# stop services
|
|
|
|
echo "making sure services are not running"
|
|
|
|
sudo systemctl stop RTL 2>/dev/null
|
|
|
|
|
|
|
|
# switch on
|
2018-12-02 20:43:48 +01:00
|
|
|
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
|
2018-12-02 19:52:01 +01:00
|
|
|
echo "*** INSTALL RTL ***"
|
|
|
|
|
|
|
|
isInstalled=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service')
|
|
|
|
if [ ${isInstalled} -eq 0 ]; then
|
|
|
|
|
2019-11-24 13:12:55 +00:00
|
|
|
# check and install NodeJS
|
|
|
|
/home/admin/config.scripts/bonus.nodejs.sh
|
2019-03-13 18:13:49 +01:00
|
|
|
|
2019-01-14 21:58:03 +01:00
|
|
|
# download source code and set to tag release
|
2018-12-02 19:52:01 +01:00
|
|
|
echo "*** Get the RTL Source Code ***"
|
2019-07-31 00:03:14 +02:00
|
|
|
rm -r /home/admin/RTL 2>/dev/null
|
2019-07-30 23:57:24 +02:00
|
|
|
git clone https://github.com/ShahanaFarooqui/RTL.git /home/admin/RTL
|
2019-07-31 00:05:33 +02:00
|
|
|
cd /home/admin/RTL
|
2019-11-24 13:12:55 +00:00
|
|
|
git reset --hard v0.5.4
|
2019-03-13 18:13:49 +01:00
|
|
|
# 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 ""
|
2019-02-05 02:40:42 +01:00
|
|
|
|
2019-01-14 21:58:03 +01:00
|
|
|
|
|
|
|
# install
|
|
|
|
echo "*** Run: npm install ***"
|
2019-11-24 13:12:55 +00:00
|
|
|
export NG_CLI_ANALYTICS=false
|
2018-12-02 19:52:01 +01:00
|
|
|
npm install
|
|
|
|
cd ..
|
2019-03-13 18:13:49 +01:00
|
|
|
# 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
|
2018-12-02 19:52:01 +01:00
|
|
|
echo ""
|
|
|
|
|
2019-01-14 21:58:03 +01:00
|
|
|
# prepare RTL.conf file
|
|
|
|
echo "*** RTL.conf ***"
|
|
|
|
cp ./RTL/sample-RTL.conf ./RTL/RTL.conf
|
|
|
|
sudo sed -i "s/^macroonPath=.*/macroonPath=\/mnt\/hdd\/lnd\/data\/chain\/${network}\/${chain}net/g" ./RTL/RTL.conf
|
|
|
|
sudo sed -i "s/^lndConfigPath=.*/lndConfigPath=\/mnt\/hdd\/lnd\/lnd.conf/g" ./RTL/RTL.conf
|
|
|
|
sudo sed -i "s/^nodeAuthType=.*/nodeAuthType=DEFAULT/g" ./RTL/RTL.conf
|
|
|
|
sudo sed -i "s/^rtlPass=.*/rtlPass=/g" ./RTL/RTL.conf
|
|
|
|
echo ""
|
|
|
|
|
2018-12-02 19:52:01 +01:00
|
|
|
# open firewall
|
|
|
|
echo "*** Updating Firewall ***"
|
2019-12-04 08:13:21 +00:00
|
|
|
sudo ufw allow 3000 comment 'RTL'
|
2018-12-02 19:52:01 +01:00
|
|
|
sudo ufw --force enable
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
# install service
|
|
|
|
echo "*** Install RTL systemd for ${network} on ${chain} ***"
|
|
|
|
sudo cp /home/admin/assets/RTL.service /etc/systemd/system/RTL.service
|
|
|
|
sudo sed -i "s|chain/bitcoin/mainnet|chain/${network}/${chain}net|" /etc/systemd/system/RTL.service
|
|
|
|
sudo systemctl enable RTL
|
2019-11-24 13:12:55 +00:00
|
|
|
echo "OK - the RTL service is now enabled"
|
2019-03-13 18:13:49 +01:00
|
|
|
|
2018-12-02 19:52:01 +01:00
|
|
|
else
|
|
|
|
echo "RTL already installed."
|
|
|
|
fi
|
2019-11-24 13:12:55 +00:00
|
|
|
|
2019-03-13 18:13:49 +01:00
|
|
|
# setting value in raspi blitz config
|
|
|
|
sudo sed -i "s/^rtlWebinterface=.*/rtlWebinterface=on/g" /mnt/hdd/raspiblitz.conf
|
|
|
|
|
2019-11-24 13:12:55 +00:00
|
|
|
# Hidden Service for RTL if Tor is active
|
|
|
|
if [ "${runBehindTor}" = "on" ]; then
|
2019-12-04 10:09:14 +00:00
|
|
|
# correct old Hidden Service with port
|
|
|
|
sudo sed -i "s/^HiddenServicePort 3000 127.0.0.1:3000/HiddenServicePort 80 127.0.0.1:3000/g" /etc/tor/torrc
|
|
|
|
/home/admin/config.scripts/internet.hiddenservice.sh RTL 80 3000
|
|
|
|
|
2019-11-24 13:12:55 +00:00
|
|
|
TOR_ADDRESS=$(sudo cat /mnt/hdd/tor/RTL/hostname)
|
|
|
|
if [ -z "$TOR_ADDRESS" ]; then
|
|
|
|
echo "Waiting for the Hidden Service"
|
|
|
|
sleep 10
|
|
|
|
TOR_ADDRESS=$(sudo cat /mnt/hdd/tor/RTL/hostname)
|
|
|
|
if [ -z "$TOR_ADDRESS" ]; then
|
|
|
|
echo " FAIL - The Hidden Service address could not be found - Tor error?"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
echo ""
|
|
|
|
echo "***"
|
|
|
|
echo "The Tor Hidden Service address for RTL is:"
|
|
|
|
echo "$TOR_ADDRESS"
|
|
|
|
echo "***"
|
|
|
|
echo ""
|
|
|
|
fi
|
2018-12-02 19:52:01 +01:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# switch off
|
2018-12-02 20:43:48 +01:00
|
|
|
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
|
2018-12-02 19:52:01 +01:00
|
|
|
|
|
|
|
# setting value in raspi blitz config
|
|
|
|
sudo sed -i "s/^rtlWebinterface=.*/rtlWebinterface=off/g" /mnt/hdd/raspiblitz.conf
|
|
|
|
|
|
|
|
isInstalled=$(sudo ls /etc/systemd/system/RTL.service 2>/dev/null | grep -c 'RTL.service')
|
|
|
|
if [ ${isInstalled} -eq 1 ]; then
|
|
|
|
echo "*** REMOVING RTL ***"
|
|
|
|
sudo systemctl stop RTL
|
|
|
|
sudo systemctl disable RTL
|
|
|
|
sudo rm /etc/systemd/system/RTL.service
|
|
|
|
sudo rm -r /home/admin/RTL
|
|
|
|
echo "OK RTL removed."
|
|
|
|
else
|
|
|
|
echo "RTL is not installed."
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "needs reboot to activate new setting"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2019-11-24 13:12:55 +00:00
|
|
|
echo "FAIL - Unknown Parameter $1"
|
|
|
|
echo "may need reboot to run normal again"
|
2019-05-11 06:16:39 +01:00
|
|
|
exit 1
|