Add option to reset thunderhub config

This commit is contained in:
Taylor Helsper 2023-06-07 21:59:19 -05:00
parent d13504d9b3
commit dcbe995061
6 changed files with 67 additions and 26 deletions

View File

@ -9,6 +9,7 @@ After=lnd.service
[Service]
ExecStartPre=/usr/bin/is_not_shutting_down.sh
ExecStartPre=/usr/bin/wait_on_lnd.sh
ExecStartPre=+/usr/bin/service_scripts/pre_thunderhub.sh
Environment=PORT=3030
WorkingDirectory=/opt/mynode/thunderhub
ExecStart=/usr/bin/npm run start

View File

@ -428,32 +428,7 @@ fi
# Setup Thunderhub
mkdir -p /mnt/hdd/mynode/thunderhub/
if [ ! -f /mnt/hdd/mynode/thunderhub/.env.local ]; then
cp -f /usr/share/mynode/thunderhub.env /mnt/hdd/mynode/thunderhub/.env.local
fi
if [ ! -f /mnt/hdd/mynode/thunderhub/thub_config.yaml ]; then
cp -f /usr/share/mynode/thub_config.yaml /mnt/hdd/mynode/thunderhub/thub_config.yaml
fi
THUNDERHUB_CONFIG_UPDATE_NUM=1
if [ ! -f /mnt/hdd/mynode/thunderhub/update_settings_$THUNDERHUB_CONFIG_UPDATE_NUM ]; then
cp -f /usr/share/mynode/thunderhub.env /mnt/hdd/mynode/thunderhub/.env.local
cp -f /usr/share/mynode/thub_config.yaml /mnt/hdd/mynode/thunderhub/thub_config.yaml
touch /mnt/hdd/mynode/thunderhub/update_settings_$THUNDERHUB_CONFIG_UPDATE_NUM
fi
if [ -f /mnt/hdd/mynode/thunderhub/thub_config.yaml ]; then
if [ -f /home/bitcoin/.mynode/.hashedpw_bcrypt ]; then
HASH_BCRYPT=$(cat /home/bitcoin/.mynode/.hashedpw_bcrypt)
sed -i "s#masterPassword:.*#masterPassword: \"thunderhub-$HASH_BCRYPT\"#g" /mnt/hdd/mynode/thunderhub/thub_config.yaml
fi
if [ -f /mnt/hdd/mynode/settings/.testnet_enabled ]; then
sed -i "s/mainnet/testnet/g" /mnt/hdd/mynode/thunderhub/thub_config.yaml || true
else
sed -i "s/testnet/mainnet/g" /mnt/hdd/mynode/thunderhub/thub_config.yaml || true
fi
fi
chown -R bitcoin:bitcoin /mnt/hdd/mynode/thunderhub
# Moved to pre_thunderhub.sh
# Setup CKBunker
CKBUNKER_CONFIG_UPDATE_NUM=1

View File

@ -0,0 +1,37 @@
#!/bin/bash
source /usr/share/mynode/mynode_config.sh
set -x
set -e
# Thunderhub config
mkdir -p /mnt/hdd/mynode/thunderhub/
if [ ! -f /mnt/hdd/mynode/thunderhub/.env.local ]; then
cp -f /usr/share/mynode/thunderhub.env /mnt/hdd/mynode/thunderhub/.env.local
fi
if [ ! -f /mnt/hdd/mynode/thunderhub/thub_config.yaml ]; then
cp -f /usr/share/mynode/thub_config.yaml /mnt/hdd/mynode/thunderhub/thub_config.yaml
fi
THUNDERHUB_CONFIG_UPDATE_NUM=1
if [ ! -f /mnt/hdd/mynode/thunderhub/update_settings_$THUNDERHUB_CONFIG_UPDATE_NUM ]; then
cp -f /usr/share/mynode/thunderhub.env /mnt/hdd/mynode/thunderhub/.env.local
cp -f /usr/share/mynode/thub_config.yaml /mnt/hdd/mynode/thunderhub/thub_config.yaml
touch /mnt/hdd/mynode/thunderhub/update_settings_$THUNDERHUB_CONFIG_UPDATE_NUM
fi
if [ -f /mnt/hdd/mynode/thunderhub/thub_config.yaml ]; then
if [ -f /home/bitcoin/.mynode/.hashedpw_bcrypt ]; then
HASH_BCRYPT=$(cat /home/bitcoin/.mynode/.hashedpw_bcrypt)
sed -i "s#masterPassword:.*#masterPassword: \"thunderhub-$HASH_BCRYPT\"#g" /mnt/hdd/mynode/thunderhub/thub_config.yaml
fi
if [ -f /mnt/hdd/mynode/settings/.testnet_enabled ]; then
sed -i "s/mainnet/testnet/g" /mnt/hdd/mynode/thunderhub/thub_config.yaml || true
else
sed -i "s/testnet/mainnet/g" /mnt/hdd/mynode/thunderhub/thub_config.yaml || true
fi
fi
chown -R bitcoin:bitcoin /mnt/hdd/mynode/thunderhub
sync
sleep 3s

View File

@ -1160,6 +1160,13 @@ def reset_rtl_config():
os.system("rm -rf /mnt/hdd/mynode/rtl/RTL-Config.json")
os.system("systemctl restart rtl")
#==================================
# Thunderhub Functions
#==================================
def reset_thunderhub_config():
os.system("rm -rf /mnt/hdd/mynode/thunderhub/thub_config.yaml")
os.system("systemctl restart thunderhub")
#==================================
# Sphinx Relay Server Functions
#==================================

View File

@ -564,6 +564,16 @@ def reset_rtl_config_page():
flash("RTL Configuration Reset", category="message")
return redirect("/settings")
@mynode_settings.route("/settings/reset-thunderhub-config")
def reset_thunderhub_config_page():
check_logged_in()
t = Timer(1.0, reset_thunderhub_config)
t.start()
flash("Thunderhub Configuration Reset", category="message")
return redirect("/settings")
@mynode_settings.route("/settings/reset-specter-config")
def reset_specter_config_page():
check_logged_in()

View File

@ -1106,6 +1106,17 @@
</div>
<div class="settings_block">
<a id="thunderhub"></a>
<div class="settings_block_header">Thunderhub</div>
<div class="settings_block_subheader">Reset Thunderhub Configuration</div>
This will delete your Thunderhub configuration and restart the application.
<br/>
<a href="/settings/reset-thunderhub-config" class="ui-button ui-widget ui-corner-all settings_button">Reset Configuration</a>
</div>
<div class="settings_block">
<a id="btcrpcexplorer"></a>
<div class="settings_block_header">BTC RPC Explorer</div>