Add option to reset RTL config

This commit is contained in:
Taylor Helsper 2021-12-17 23:18:25 -06:00
parent 48189cef99
commit 87502b2d3a
6 changed files with 75 additions and 31 deletions

View File

@ -9,6 +9,7 @@ After=bitcoin.service
[Service]
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStartPre=/usr/bin/wait_on_lnd.sh
ExecStartPre=+/usr/bin/mynode_pre_rtl.sh
WorkingDirectory=/opt/mynode/RTL
ExecStart=/usr/bin/node rtl

View File

@ -0,0 +1,46 @@
#!/bin/bash
source /usr/share/mynode/mynode_config.sh
set -x
set -e
# RTL config
sudo -u bitcoin mkdir -p /opt/mynode/RTL
sudo -u bitcoin mkdir -p /mnt/hdd/mynode/rtl
chown -R bitcoin:bitcoin /mnt/hdd/mynode/rtl
chown -R bitcoin:bitcoin /mnt/hdd/mynode/rtl_backup
# If local settings file is not a symlink, delete and setup symlink to HDD
if [ ! -L /opt/mynode/RTL/RTL-Config.json ]; then
rm -f /opt/mynode/RTL/RTL-Config.json
sudo -u bitcoin ln -s /mnt/hdd/mynode/rtl/RTL-Config.json /opt/mynode/RTL/RTL-Config.json
fi
# If config file on HDD does not exist, create it
if [ ! -f /mnt/hdd/mynode/rtl/RTL-Config.json ]; then
cp -f /usr/share/mynode/RTL-Config.json /mnt/hdd/mynode/rtl/RTL-Config.json
fi
# Force update of RTL config file (increment to force new update)
RTL_CONFIG_UPDATE_NUM=1
if [ ! -f /mnt/hdd/mynode/rtl/update_settings_$RTL_CONFIG_UPDATE_NUM ]; then
cp -f /usr/share/mynode/RTL-Config.json /mnt/hdd/mynode/rtl/RTL-Config.json
touch /mnt/hdd/mynode/rtl/update_settings_$RTL_CONFIG_UPDATE_NUM
fi
# Update RTL config file to use mynode pw
if [ -f /home/bitcoin/.mynode/.hashedpw ]; then
HASH=$(cat /home/bitcoin/.mynode/.hashedpw)
sed -i "s/\"multiPassHashed\":.*/\"multiPassHashed\": \"$HASH\",/g" /mnt/hdd/mynode/rtl/RTL-Config.json
fi
# Update for testnet
if [ -f /mnt/hdd/mynode/settings/.testnet_enabled ]; then
sed -i "s/mainnet/testnet/g" /mnt/hdd/mynode/rtl/RTL-Config.json || true
else
sed -i "s/testnet/mainnet/g" /mnt/hdd/mynode/rtl/RTL-Config.json || true
fi
sync
sleep 3s

View File

@ -379,36 +379,7 @@ if [ $IS_RASPI4 -eq 1 ]; then
fi
# RTL config
sudo -u bitcoin mkdir -p /opt/mynode/RTL
sudo -u bitcoin mkdir -p /mnt/hdd/mynode/rtl
chown -R bitcoin:bitcoin /mnt/hdd/mynode/rtl
chown -R bitcoin:bitcoin /mnt/hdd/mynode/rtl_backup
# If local settings file is not a symlink, delete and setup symlink to HDD
if [ ! -L /opt/mynode/RTL/RTL-Config.json ]; then
rm -f /opt/mynode/RTL/RTL-Config.json
sudo -u bitcoin ln -s /mnt/hdd/mynode/rtl/RTL-Config.json /opt/mynode/RTL/RTL-Config.json
fi
# If config file on HDD does not exist, create it
if [ ! -f /mnt/hdd/mynode/rtl/RTL-Config.json ]; then
cp -f /usr/share/mynode/RTL-Config.json /mnt/hdd/mynode/rtl/RTL-Config.json
fi
# Force update of RTL config file (increment to force new update)
RTL_CONFIG_UPDATE_NUM=1
if [ ! -f /mnt/hdd/mynode/rtl/update_settings_$RTL_CONFIG_UPDATE_NUM ]; then
cp -f /usr/share/mynode/RTL-Config.json /mnt/hdd/mynode/rtl/RTL-Config.json
touch /mnt/hdd/mynode/rtl/update_settings_$RTL_CONFIG_UPDATE_NUM
fi
# Update RTL config file to use mynode pw
if [ -f /home/bitcoin/.mynode/.hashedpw ]; then
HASH=$(cat /home/bitcoin/.mynode/.hashedpw)
sed -i "s/\"multiPassHashed\":.*/\"multiPassHashed\": \"$HASH\",/g" /mnt/hdd/mynode/rtl/RTL-Config.json
fi
# Update for testnet
if [ -f /mnt/hdd/mynode/settings/.testnet_enabled ]; then
sed -i "s/mainnet/testnet/g" /mnt/hdd/mynode/rtl/RTL-Config.json || true
else
sed -i "s/testnet/mainnet/g" /mnt/hdd/mynode/rtl/RTL-Config.json || true
fi
# Moved to mynode_pre_rtl.sh
# BTCPay Server Setup
mkdir -p /opt/mynode/btcpayserver

View File

@ -596,7 +596,7 @@ def set_flask_session_timeout(days, hours):
#==================================
# Uploader Functions
# Web Server Functions
#==================================
def restart_flask():
os.system("systemctl restart www")
@ -904,6 +904,12 @@ def reset_electrs():
delete_electrs_data()
restart_electrs()
#==================================
# RTL Functions
#==================================
def reset_rtl_config():
os.system("rm -rf /mnt/hdd/mynode/rtl/RTL-Config.json")
os.system("systemctl restart rtl")
#==================================
# Sphinx Relay Server Functions

View File

@ -545,6 +545,16 @@ def clear_mempool_cache_page():
flash("Mempool Cache Cleared", category="message")
return redirect("/settings")
@mynode_settings.route("/settings/reset-rtl-config")
def reset_rtl_config_page():
check_logged_in()
t = Timer(1.0, reset_rtl_config)
t.start()
flash("RTL Configuration Reset", category="message")
return redirect("/settings")
@mynode_settings.route("/settings/reset-specter-config")
def reset_specter_config_page():
check_logged_in()

View File

@ -822,7 +822,17 @@
This will regenerate your Electrum Server certificate.
<br/>
<a href="/settings/regen-electrs-certs" class="ui-button ui-widget ui-corner-all settings_button">Regenerate</a>
</div>
<div class="settings_block">
<a id="rtl"></a>
<div class="settings_block_header">Ride the Lightning</div>
<div class="settings_block_subheader">Reset RTL Configuration</div>
This will delete your RTL configuration and restart the application.
<br/>
<a href="/settings/reset-rtl-config" class="ui-button ui-widget ui-corner-all settings_button">Reset Configuration</a>
</div>