Add hook script capabilities

This commit is contained in:
Taylor Helsper 2021-12-03 12:29:55 -06:00
parent 91c072e959
commit 4fec221654
3 changed files with 20 additions and 4 deletions

View File

@ -9,6 +9,7 @@ source /usr/share/mynode/mynode_app_versions.sh
# NOTE: Background services will run before mynode service completes, so a drive MAY NOT be attached
COUNTER=0
BITCOIN_SYNCED=0
while true; do
@ -31,6 +32,16 @@ while true; do
fi
fi
# Custom startup hook - post-bitcoin-synced
if [ -f /usr/local/bin/mynode_hook_post_bitcoin_synced.sh ]; then
if [ $BITCOIN_SYNCED == 0 ] && [ -f $BITCOIN_SYNCED_FILE ]; then
/bin/bash /usr/local/bin/mynode_hook_post_bitcoin_synced.sh || true
BITCOIN_SYNCED=1
else
BITCOIN_SYNCED=0
fi
fi
# Increment counter and sleep 1 min
COUNTER=$((COUNTER+1))

View File

@ -136,6 +136,10 @@ fi
rm -f /tmp/repairing_drive
set -e
# Custom startup hook - pre-startup
if [ -f /usr/local/bin/mynode_hook_pre_startup.sh ]; then
/bin/bash /usr/local/bin/mynode_hook_pre_startup.sh || true
fi
# Mount HDD (normal boot, format if necessary)
while [ ! -f /mnt/hdd/.mynode ]
@ -790,9 +794,10 @@ if [ -f /usr/share/joininbox/menu.update.sh ] && [ -f /home/joinmarket/menu.upda
fi
chown bitcoin:bitcoin /mnt/hdd/mynode/settings/.lndpw || true
# Check for new versions
torify wget $LATEST_VERSION_URL --timeout=30 -O /usr/share/mynode/latest_version || true
torify wget $LATEST_BETA_VERSION_URL --timeout=30 -O /usr/share/mynode/latest_beta_version || true
# Custom startup hook - post-startup
if [ -f /usr/local/bin/mynode_hook_post_startup.sh ]; then
/bin/bash /usr/local/bin/mynode_hook_post_startup.sh || true
fi
# Update current state
if [ -f $QUICKSYNC_DIR/.quicksync_complete ]; then

View File

@ -110,7 +110,7 @@ def update_bitcoin_main_info_thread():
bitcoin_block_height = get_bitcoin_block_height()
mynode_block_height = get_mynode_block_height()
remaining = bitcoin_block_height - mynode_block_height
if remaining == 0 and bitcoin_block_height > 680000:
if remaining == 0 and bitcoin_block_height > 710000:
synced = True
if not os.path.isfile(BITCOIN_SYNCED_FILE):
open(BITCOIN_SYNCED_FILE, 'a').close() # touch file