raspiblitz/home.admin/config.scripts/network.wallet.sh
/rootzoll 334792abda
#2891 Prepare JAM install scripts for WebUI (#3545)
* webapi branches

* add thunderhub off

* webui JAM & joinmarket

* fix joinmarket menu

* comment output

* add debug

* remove user delete JAM

* pipe outputs

* add to fatpack

* pipe more debug

* dont remove app

* force https

* #3544 manual merge

* separate install and on option for joinmarket (#3544)

* fix call

* adapt api/webui branches

Co-authored-by: openoms <43343391+openoms@users.noreply.github.com>
2022-12-19 12:28:56 +01:00

74 lines
2.2 KiB
Bash
Executable file

#!/bin/bash
# command info
if [ $# -eq 0 ] || [ "$1" = "-h" ] || [ "$1" = "-help" ]; then
echo "config script to switch the Bitcoin Core wallet on or off"
echo "network.wallet.sh [status|on|off]"
exit 1
fi
source /mnt/hdd/raspiblitz.conf
source /home/admin/raspiblitz.info
# add disablewallet with default value (0) to bitcoin.conf if missing
if ! grep -Eq "^disablewallet=.*" /mnt/hdd/${network}/${network}.conf; then
echo "disablewallet=0" | sudo tee -a /mnt/hdd/${network}/${network}.conf >/dev/null
fi
# set variable ${disablewallet}
source <(grep -E "^disablewallet=.*" /mnt/hdd/${network}/${network}.conf)
###################
# STATUS
###################
if [ "$1" = "status" ]; then
echo "##### STATUS disablewallet"
echo "disablewallet=${disablewallet}"
exit 0
fi
###################
# switch on
###################
if [ "$1" = "1" ] || [ "$1" = "on" ]; then
# specify wallet.dat for mainnet to avoid error on testnet
sudo sed -i "s/^wallet=wallet.dat/main.wallet=wallet.dat/g" /mnt/hdd/${network}/${network}.conf
if ! grep -Eq "^${chain}.wallet=wallet.dat" /mnt/hdd/${network}/${network}.conf; then
echo "# Enable the multiwallet feature in ${network} core ${chain}net and specify wallet.dat"
echo "${chain}.wallet=wallet.dat" | sudo tee -a /mnt/hdd/${network}/${network}.conf >/dev/null
restartService=1
else
echo "# Multiwallet is active and wallet.dat is used."
restartService=0
fi
if [ ${disablewallet} == 1 ]; then
sudo sed -i "s/^disablewallet=.*/disablewallet=0/g" /mnt/hdd/${network}/${network}.conf
echo "# Switching the ${network} core wallet on"
restartService=1
else
echo "# The ${network} core wallet is already on"
fi
source <(/home/admin/_cache.sh get state)
if [ ${restartService} == 1 ] && [ ${state} != "recovering" ]; then
echo "# Restarting ${network}d"
sudo systemctl restart ${network}d
fi
exit 0
fi
###################
# switch off
###################
if [ "$1" = "0" ] || [ "$1" = "off" ]; then
sudo sed -i "s/^disablewallet=.*/disablewallet=1/g" /mnt/hdd/${network}/${network}.conf
sudo systemctl restart ${network}d
exit 0
fi
echo "FAIL - Unknown Parameter $1"
exit 1