2019-11-04 04:50:47 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-05-07 03:45:52 +00:00
|
|
|
TOTAL_RAM_GB=$(free --giga | grep Mem | awk '{print $2}')
|
2020-08-24 17:16:46 +00:00
|
|
|
|
2020-01-29 01:59:46 +00:00
|
|
|
# Setup default settings
|
|
|
|
if [ ! -f /mnt/hdd/mynode/settings/.btc_lnd_tor_enabled_defaulted ]; then
|
|
|
|
touch /mnt/hdd/mynode/settings/.btc_lnd_tor_enabled_defaulted
|
2022-03-20 21:27:41 +00:00
|
|
|
touch /mnt/hdd/mynode/settings/btc_lnd_tor_enabled
|
2020-01-29 01:59:46 +00:00
|
|
|
sync
|
|
|
|
fi
|
|
|
|
|
2019-11-04 04:50:47 +00:00
|
|
|
# Generate BTC Config
|
2019-11-05 01:34:19 +00:00
|
|
|
if [ -f /mnt/hdd/mynode/settings/bitcoin_custom.conf ]; then
|
2020-01-29 01:59:46 +00:00
|
|
|
# Use Custom Config
|
2019-11-05 01:34:19 +00:00
|
|
|
cp -f /mnt/hdd/mynode/settings/bitcoin_custom.conf /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
else
|
2020-01-29 01:59:46 +00:00
|
|
|
# Generate a default config
|
2019-11-05 01:34:19 +00:00
|
|
|
cp -f /usr/share/mynode/bitcoin.conf /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
2020-08-24 17:16:46 +00:00
|
|
|
sync
|
|
|
|
|
|
|
|
# Generate config based on RAM
|
|
|
|
if [ "$TOTAL_RAM_GB" -le "1" ]; then
|
|
|
|
sed -i "s/dbcache=.*/dbcache=225/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
sed -i "s/maxmempool=.*/maxmempool=50/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
elif [ "$TOTAL_RAM_GB" -le "2" ]; then
|
|
|
|
sed -i "s/dbcache=.*/dbcache=500/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
sed -i "s/maxmempool=.*/maxmempool=100/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
2020-10-29 04:01:58 +00:00
|
|
|
elif [ "$TOTAL_RAM_GB" -le "3" ]; then
|
|
|
|
sed -i "s/dbcache=.*/dbcache=700/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
sed -i "s/maxmempool=.*/maxmempool=150/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
2020-08-24 17:16:46 +00:00
|
|
|
elif [ "$TOTAL_RAM_GB" -le "4" ]; then
|
2021-03-03 01:46:43 +00:00
|
|
|
sed -i "s/dbcache=.*/dbcache=1000/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
2021-04-16 01:31:11 +00:00
|
|
|
sed -i "s/maxmempool=.*/maxmempool=250/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
2020-08-24 17:16:46 +00:00
|
|
|
elif [ "$TOTAL_RAM_GB" -le "6" ]; then
|
|
|
|
sed -i "s/dbcache=.*/dbcache=2000/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
sed -i "s/maxmempool=.*/maxmempool=400/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
elif [ "$TOTAL_RAM_GB" -le "8" ]; then
|
|
|
|
sed -i "s/dbcache=.*/dbcache=2500/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
sed -i "s/maxmempool=.*/maxmempool=500/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
2020-10-29 04:01:58 +00:00
|
|
|
elif [ "$TOTAL_RAM_GB" -le "12" ]; then
|
|
|
|
sed -i "s/dbcache=.*/dbcache=4000/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
sed -i "s/maxmempool=.*/maxmempool=800/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
elif [ "$TOTAL_RAM_GB" -le "16" ]; then
|
|
|
|
sed -i "s/dbcache=.*/dbcache=5000/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
sed -i "s/maxmempool=.*/maxmempool=800/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
2020-08-24 17:16:46 +00:00
|
|
|
else
|
|
|
|
echo "UNKNOWN RAM AMMOUNT: $TOTAL_RAM_GB"
|
|
|
|
sed -i "s/dbcache=.*/dbcache=500/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
sed -i "s/maxmempool=.*/maxmempool=50/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
fi
|
2020-01-29 01:59:46 +00:00
|
|
|
|
2022-03-20 21:27:41 +00:00
|
|
|
# Append Tor/IP section (check new file or old file, should be migrated to new)
|
2022-06-16 03:45:39 +00:00
|
|
|
if [ -f /mnt/hdd/mynode/settings/btc_lnd_tor_enabled ] || [ -f /home/bitcoin/.mynode/btc_lnd_tor_enabled ]; then
|
2020-01-29 01:59:46 +00:00
|
|
|
cat /usr/share/mynode/bitcoin_tor.conf >> /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
else
|
|
|
|
cat /usr/share/mynode/bitcoin_ipv4.conf >> /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
fi
|
2021-03-09 03:55:39 +00:00
|
|
|
|
|
|
|
# Append Mainnet/Testnet section
|
|
|
|
if [ -f /mnt/hdd/mynode/settings/.testnet_enabled ]; then
|
|
|
|
cat /usr/share/mynode/bitcoin_testnet.conf >> /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
fi
|
2021-11-17 05:43:12 +00:00
|
|
|
|
2022-02-11 05:52:28 +00:00
|
|
|
# Append BIP setting toggles
|
|
|
|
if [ -f /mnt/hdd/mynode/settings/.bip37_enabled ]; then
|
|
|
|
cat /usr/share/mynode/bitcoin_bip37.conf >> /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
fi
|
|
|
|
if [ -f /mnt/hdd/mynode/settings/.bip157_enabled ]; then
|
|
|
|
cat /usr/share/mynode/bitcoin_bip157.conf >> /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
fi
|
2021-11-17 05:43:12 +00:00
|
|
|
if [ -f /mnt/hdd/mynode/settings/.bip158_enabled ]; then
|
|
|
|
cat /usr/share/mynode/bitcoin_bip158.conf >> /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
fi
|
2019-11-05 01:34:19 +00:00
|
|
|
fi
|
2019-11-04 04:50:47 +00:00
|
|
|
|
|
|
|
PW=$(cat /mnt/hdd/mynode/settings/.btcrpcpw)
|
|
|
|
RPCAUTH=$(gen_rpcauth.py mynode $PW)
|
|
|
|
#sed -i "s/rpcpassword=.*/rpcpassword=$PW/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
sed -i "s/rpcauth=.*/$RPCAUTH/g" /mnt/hdd/mynode/bitcoin/bitcoin.conf
|
|
|
|
|
|
|
|
chown bitcoin:bitcoin /mnt/hdd/mynode/bitcoin/bitcoin.conf
|