RTL: fix loop HTTPS and macaroon auth (#1876)

This commit is contained in:
openoms
2020-12-21 16:37:29 +00:00
committed by rootzoll
parent f590c856ef
commit 10a36361ed
2 changed files with 49 additions and 26 deletions

View File

@@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# https://github.com/lightninglabs/loop/releases- # https://github.com/lightninglabs/loop/releases-
pinnedVersion="v0.11.1-beta" pinnedVersion="v0.11.2-beta"
# command info # command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then

View File

@@ -1,9 +1,12 @@
#!/bin/bash #!/bin/bash
pinnedVersion="v0.9.3"
# command info # command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "small config script to switch WebGUI RideTheLightning on or off" echo "# config script to switch the RideTheLightning WebGUI on, off or update"
echo "bonus.rtl.sh [on|off|menu]" echo "# bonus.rtl.sh [on|off|update<commit>|menu]"
echo "# installs the version $pinnedVersion by default"
exit 1 exit 1
fi fi
@@ -82,6 +85,14 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sudo ln -s "/mnt/hdd/app-data/lnd/" "/home/rtl/.lnd" # and create symlink sudo ln -s "/mnt/hdd/app-data/lnd/" "/home/rtl/.lnd" # and create symlink
fi fi
echo "# add the rtl user to the loop group"
sudo /usr/sbin/usermod --append --groups loop rtl
echo "# symlink the loop.macaroon"
if ! [[ -L "/home/rtl/.loop" ]]; then
sudo rm -rf "/home/rtl/.loop" # not a symlink.. delete it silently
sudo ln -s "/home/loop/.loop/" "/home/rtl/.loop" # and create symlink
fi
# download source code and set to tag release # download source code and set to tag release
echo "*** Get the RTL Source Code ***" echo "*** Get the RTL Source Code ***"
rm -rf /home/admin/RTL 2>/dev/null rm -rf /home/admin/RTL 2>/dev/null
@@ -89,7 +100,7 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
sudo -u rtl git clone https://github.com/ShahanaFarooqui/RTL.git /home/rtl/RTL sudo -u rtl git clone https://github.com/ShahanaFarooqui/RTL.git /home/rtl/RTL
cd /home/rtl/RTL cd /home/rtl/RTL
# check https://github.com/Ride-The-Lightning/RTL/releases/ # check https://github.com/Ride-The-Lightning/RTL/releases/
sudo -u rtl git reset --hard v0.9.3 sudo -u rtl git reset --hard $pinnedVersion
# from https://github.com/Ride-The-Lightning/RTL/commits/master # from https://github.com/Ride-The-Lightning/RTL/commits/master
# git checkout 917feebfa4fb583360c140e817c266649307ef72 # git checkout 917feebfa4fb583360c140e817c266649307ef72
if [ -d "/home/rtl/RTL" ]; then if [ -d "/home/rtl/RTL" ]; then
@@ -128,11 +139,13 @@ if [ "$1" = "1" ] || [ "$1" = "on" ]; then
var data = require('/home/rtl/RTL/sample-RTL-Config.json'); var data = require('/home/rtl/RTL/sample-RTL-Config.json');
//Manipulate data //Manipulate data
data.nodes[0].lnNode = '$hostname' data.nodes[0].lnNode = '$hostname'
data.nodes[0].Authentication.macaroonPath = '/home/rtl/.lnd/data/chain/${network}/${chain}net/'; data.nodes[0].Authentication.macaroonPath = '/home/rtl/.lnd/data/chain/${network}/${chain}net/'
data.nodes[0].Authentication.swapMacaroonPath = '/home/rtl/.loop/${chain}net/'
data.nodes[0].Authentication.configPath = '/home/rtl/.lnd/lnd.conf'; data.nodes[0].Authentication.configPath = '/home/rtl/.lnd/lnd.conf';
data.multiPass = '$PASSWORD_B'; data.multiPass = '$PASSWORD_B';
data.nodes[0].Settings.userPersona = 'OPERATOR' data.nodes[0].Settings.userPersona = 'OPERATOR'
data.nodes[0].Settings.channelBackupPath = '/home/rtl/RTL-SCB-backup-$hostname' data.nodes[0].Settings.channelBackupPath = '/home/rtl/RTL-SCB-backup-$hostname'
data.nodes[0].Settings.swapServerUrl = 'https://localhost:8081'
//Output data //Output data
console.log(JSON.stringify(data, null, 2)); console.log(JSON.stringify(data, null, 2));
EOF EOF
@@ -250,30 +263,40 @@ fi
if [ "$1" = "update" ]; then if [ "$1" = "update" ]; then
echo "# UPDATING RTL" echo "# UPDATING RTL"
cd /home/rtl/RTL cd /home/rtl/RTL
# from https://github.com/apotdevin/thunderhub/blob/master/scripts/updateToLatest.sh updateOption="$2"
# fetch latest master if [ ${#updateOption} -eq 0 ]; then
sudo -u rtl git fetch # from https://github.com/apotdevin/thunderhub/blob/master/scripts/updateToLatest.sh
# unset $1 # fetch latest master
set -- sudo -u rtl git fetch
UPSTREAM=${1:-'@{u}'} # unset $1
LOCAL=$(git rev-parse @) set --
REMOTE=$(git rev-parse "$UPSTREAM") UPSTREAM=${1:-'@{u}'}
if [ $LOCAL = $REMOTE ]; then LOCAL=$(git rev-parse @)
TAG=$(git tag | sort -V | tail -1) REMOTE=$(git rev-parse "$UPSTREAM")
echo "# You are up-to-date on version" $TAG if [ $LOCAL = $REMOTE ]; then
else TAG=$(git tag | sort -V | tail -1)
echo "# Pulling latest changes..." echo "# You are up-to-date on version" $TAG
else
echo "# Pulling latest changes..."
sudo -u rtl git pull -p
echo "# Reset to the latest release tag"
TAG=$(git tag | sort -V | tail -1)
sudo -u rtl git reset --hard $TAG
echo "# updating to the latest"
# https://github.com/Ride-The-Lightning/RTL#or-update-existing-dependencies
sudo -u rtl npm install --only=prod
echo "# Updated to version" $TAG
fi
elif [ "$updateOption" = "commit" ]; then
echo "# updating to the latest commit in https://github.com/Ride-The-Lightning/RTL"
sudo -u rtl git pull -p sudo -u rtl git pull -p
echo "# Reset to the latest release tag"
TAG=$(git tag | sort -V | tail -1)
sudo -u rtl git reset --hard $TAG
# https://github.com/Ride-The-Lightning/RTL#or-update-existing-dependencies
sudo -u rtl npm install --only=prod sudo -u rtl npm install --only=prod
echo "# Updated to version" $TAG currentRTLcommit=$(cd /home/rtl/RTL; git describe --tags)
echo "# Updated RTL to $currentRTLcommit"
else
echo "# unknown option: $updateOption"
fi fi
echo
echo "# Updated to the latest in https://github.com/Ride-The-Lightning/RTL/releases"
echo ""
echo "# Starting the RTL service ... " echo "# Starting the RTL service ... "
sudo systemctl start RTL sudo systemctl start RTL
exit 0 exit 0