From d272f7364fe5c5fe6ed69fc531023f32f9753e26 Mon Sep 17 00:00:00 2001 From: Taylor Helsper Date: Thu, 16 Jan 2020 22:22:31 -0600 Subject: [PATCH] Improve enable/disable restoration --- rootfs/standard/usr/bin/mynode_startup.sh | 16 ++++++++++++++-- .../standard/usr/share/mynode/mynode_config.sh | 2 ++ rootfs/standard/var/www/mynode/config.py | 2 ++ .../var/www/mynode/enable_disable_functions.py | 6 ++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/rootfs/standard/usr/bin/mynode_startup.sh b/rootfs/standard/usr/bin/mynode_startup.sh index b8008daa..a89a86d7 100755 --- a/rootfs/standard/usr/bin/mynode_startup.sh +++ b/rootfs/standard/usr/bin/mynode_startup.sh @@ -15,7 +15,7 @@ if [ ! -h /etc/resolv.conf ]; then rm -f /etc/resolv.conf touch /etc/resolvconf/run/resolv.conf ln -s /etc/resolvconf/run/resolv.conf /etc/resolv.conf - + sync reboot sleep 10s @@ -45,7 +45,7 @@ if [ ! -f /var/lib/mynode/.expanded_rootfs ]; then fi fi -# Verify we are in a clean state (only raspi uses HDD swap) +# Verify we are in a clean state if [ $IS_RASPI -eq 1 ] || [ $IS_ROCKPRO64 -eq 1 ]; then dphys-swapfile swapoff || true dphys-swapfile uninstall || true @@ -290,6 +290,18 @@ if [ -f $BTCRPCEXPLORER_ENABLED_FILE ]; then STARTUP_MODIFIED=1 fi fi +if [ -f $MEMPOOLSPACE_ENABLED_FILE ]; then + if systemctl status mempoolspace | grep "disabled;"; then + systemctl enable mempoolspace + STARTUP_MODIFIED=1 + fi +fi +if [ -f $BTCPAYSERVER_ENABLED_FILE ]; then + if systemctl status btcpayserver | grep "disabled;"; then + systemctl enable btcpayserver + STARTUP_MODIFIED=1 + fi +fi if [ -f $VPN_ENABLED_FILE ]; then if systemctl status vpn | grep "disabled;"; then systemctl enable vpn diff --git a/rootfs/standard/usr/share/mynode/mynode_config.sh b/rootfs/standard/usr/share/mynode/mynode_config.sh index bbd61a10..b0e19e69 100644 --- a/rootfs/standard/usr/share/mynode/mynode_config.sh +++ b/rootfs/standard/usr/share/mynode/mynode_config.sh @@ -67,6 +67,8 @@ ELECTRS_ENABLED_FILE="/mnt/hdd/mynode/.mynode_electrs_enabled" LNDHUB_ENABLED_FILE="/mnt/hdd/mynode/.mynode_lndhub_enabled" BTCRPCEXPLORER_ENABLED_FILE="/mnt/hdd/mynode/.mynode_btcrpceplorer_enabled" VPN_ENABLED_FILE="/mnt/hdd/mynode/.mynode_vpn_enabled" +MEMPOOLSPACE_ENABLED_FILE="/mnt/hdd/mynode/.mynode_mempoolspace_enabled" +BTCPAYSERVER_ENABLED_FILE="/mnt/hdd/mynode/.mynode_btcpayserver_enabled" BITCOIN_SYNCED_FILE="/mnt/hdd/mynode/.mynode_bitcoind_synced" QUICKSYNC_COMPLETE_FILE="$QUICKSYNC_DIR/.quicksync_complete" diff --git a/rootfs/standard/var/www/mynode/config.py b/rootfs/standard/var/www/mynode/config.py index 0795f649..f291c539 100644 --- a/rootfs/standard/var/www/mynode/config.py +++ b/rootfs/standard/var/www/mynode/config.py @@ -25,3 +25,5 @@ LNDHUB_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_lndhub_enabled" BTCRPCEXPLORER_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_btcrpceplorer_enabled" VPN_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_vpn_enabled" NETDATA_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_netdata_enabled" +MEMPOOLSPACE_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_mempoolspace_enabled" +BTCPAYSERVER_ENABLED_FILE = "/mnt/hdd/mynode/.mynode_btcpayserver_enabled" diff --git a/rootfs/standard/var/www/mynode/enable_disable_functions.py b/rootfs/standard/var/www/mynode/enable_disable_functions.py index cf06e912..e87ad2d8 100644 --- a/rootfs/standard/var/www/mynode/enable_disable_functions.py +++ b/rootfs/standard/var/www/mynode/enable_disable_functions.py @@ -65,8 +65,11 @@ def is_mempoolspace_enabled(): def enable_mempoolspace(): os.system("systemctl enable mempoolspace --no-pager") os.system("systemctl start mempoolspace --no-pager") + open(MEMPOOLSPACE_ENABLED_FILE, 'a').close() # touch file def disable_mempoolspace(): + if os.path.isfile(MEMPOOLSPACE_ENABLED_FILE): + os.remove(MEMPOOLSPACE_ENABLED_FILE) os.system("systemctl stop mempoolspace --no-pager") os.system("systemctl disable mempoolspace --no-pager") @@ -77,8 +80,11 @@ def is_btcpayserver_enabled(): def enable_btcpayserver(): os.system("systemctl enable btcpayserver --no-pager") os.system("systemctl start btcpayserver --no-pager") + open(BTCPAYSERVER_ENABLED_FILE, 'a').close() # touch file def disable_btcpayserver(): + if os.path.isfile(BTCPAYSERVER_ENABLED_FILE): + os.remove(BTCPAYSERVER_ENABLED_FILE) os.system("systemctl stop btcpayserver --no-pager") os.system("systemctl disable btcpayserver --no-pager")