diff --git a/rootfs/standard/etc/systemd/system/electrs.service b/rootfs/standard/etc/systemd/system/electrs.service index d3ae8049..c5c286ce 100644 --- a/rootfs/standard/etc/systemd/system/electrs.service +++ b/rootfs/standard/etc/systemd/system/electrs.service @@ -11,6 +11,7 @@ Type=simple KillMode=process ExecStartPre=/usr/bin/is_not_shutting_down.sh ExecStartPre=/usr/bin/wait_on_bitcoin.sh +ExecStartPre=+/usr/bin/service_scripts/pre_electrs.sh ExecStart=/usr/bin/electrs --conf=/mnt/hdd/mynode/electrs/electrs.toml User=bitcoin Group=bitcoin diff --git a/rootfs/standard/usr/bin/mynode_startup.sh b/rootfs/standard/usr/bin/mynode_startup.sh index 3e826a23..89afb673 100755 --- a/rootfs/standard/usr/bin/mynode_startup.sh +++ b/rootfs/standard/usr/bin/mynode_startup.sh @@ -380,32 +380,7 @@ fi # Setup electrs -cp -f /usr/share/mynode/electrs.toml /mnt/hdd/mynode/electrs/electrs.toml -# Update for testnet -if [ -f /mnt/hdd/mynode/settings/.testnet_enabled ]; then - sed -i "s/bitcoin/testnet/g" /mnt/hdd/mynode/electrs/electrs.toml || true -else - sed -i "s/testnet/bitcoin/g" /mnt/hdd/mynode/electrs/electrs.toml || true -fi -# Remove old electrs data (pre-v9) -rm -rf /mnt/hdd/mynode/electrs/mainnet -# Use correct binary on RP4 (32 bit/64bit) -if [ $IS_RASPI4 -eq 1 ]; then - ELECTRS_DST=/usr/bin/electrs - ELECTRS_SRC=/usr/bin/electrs_arm32 - if [ $IS_RASPI4_ARM64 -eq 1 ]; then - ELECTRS_SRC=/usr/bin/electrs_arm64 - fi - if [ ! -f $ELECTRS_DST ]; then - cp -f $ELECTRS_SRC $ELECTRS_DST - else - MD5_1=$(md5sum $ELECTRS_DST | cut -d' ' -f 1) - MD5_2=$(md5sum $ELECTRS_SRC | cut -d' ' -f 1) - if [ "${MD5_1}" != "{$MD5_2}" ]; then - cp -f $ELECTRS_SRC $ELECTRS_DST - fi - fi -fi +# Moved to pre_electrs.sh # RTL config # Moved to pre_rtl.sh diff --git a/rootfs/standard/usr/bin/service_scripts/pre_electrs.sh b/rootfs/standard/usr/bin/service_scripts/pre_electrs.sh new file mode 100755 index 00000000..8a1f38db --- /dev/null +++ b/rootfs/standard/usr/bin/service_scripts/pre_electrs.sh @@ -0,0 +1,53 @@ +#!/bin/bash + +source /usr/share/mynode/mynode_config.sh + +set -x +set -e + +# Setup electrs +cp -f /usr/share/mynode/electrs.toml /mnt/hdd/mynode/electrs/electrs.toml + +# Update for testnet +if [ -f /mnt/hdd/mynode/settings/.testnet_enabled ]; then + sed -i "s/bitcoin/testnet/g" /mnt/hdd/mynode/electrs/electrs.toml || true +else + sed -i "s/testnet/bitcoin/g" /mnt/hdd/mynode/electrs/electrs.toml || true +fi + +# Update for tx limit +INDEX_LOOKUP_LIMIT=201 +if [ $IS_X86 = 1 ]; then + INDEX_LOOKUP_LIMIT=1001 +fi +if [ -f /mnt/hdd/mynode/electrs/index_lookup_limit ]; then + INDEX_LOOKUP_LIMIT=$(cat /mnt/hdd/mynode/electrs/index_lookup_limit) +fi +sed -i "s/index_lookup_limit =.*/index_lookup_limit = $INDEX_LOOKUP_LIMIT/g" /mnt/hdd/mynode/electrs/electrs.toml || true + + +# Remove old electrs data (pre-v9) +rm -rf /mnt/hdd/mynode/electrs/mainnet + +# Use correct binary on RP4 (32 bit/64bit) +if [ $IS_RASPI4 -eq 1 ]; then + ELECTRS_DST=/usr/bin/electrs + ELECTRS_SRC=/usr/bin/electrs_arm32 + if [ $IS_RASPI4_ARM64 -eq 1 ]; then + ELECTRS_SRC=/usr/bin/electrs_arm64 + fi + if [ ! -f $ELECTRS_DST ]; then + cp -f $ELECTRS_SRC $ELECTRS_DST + else + MD5_1=$(md5sum $ELECTRS_DST | cut -d' ' -f 1) + MD5_2=$(md5sum $ELECTRS_SRC | cut -d' ' -f 1) + if [ "${MD5_1}" != "{$MD5_2}" ]; then + cp -f $ELECTRS_SRC $ELECTRS_DST + fi + fi +fi + +chown -R bitcoin:bitcoin /mnt/hdd/mynode/electrs + +sync +sleep 3s \ No newline at end of file