+
+# Bitcoin holds open the wallet file. this causes problems for a
+# secondary computer running bitcoin and receiving a backup (as of
+# 2023). However, in 2024-02, I ran a backup where a receiving machine
+# had the wallet enabled and there was no error, so I don't know if this
+# is still an issue or likely it is an inconsistent behavior.
+#
+# As a workaround, this function is for enabling the wallet when I want
+# to use it and leave it disabled otherwise.
+walleton() {
+ local active
+ active=false
+ no_on=true
+ if [[ ! $(readlink -f /var/lib/bitcoind/wallets) == /q/wallets ]]; then
+ if systemctl --quiet is-active bitcoind; then
+ if [[ -e /tmp/no-bitcoinon ]]; then
+ no_on=true
+ else
+ if [[ $EUID == 0 ]]; then
+ m install -T -o iank -g iank /dev/null /tmp/no-bitcoinon
+ else
+ m touch /tmp/no-bitcoinon
+ fi
+ fi
+ active=true
+ m ser stop bitcoind
+ fi
+ m s ln -s /q/wallets /var/lib/bitcoind
+ sudo chown -h bitcoin:bitcoin /var/lib/bitcoind/wallets
+ if $active; then
+ m ser start bitcoind
+ if ! $no_on; then
+ m rm /tmp/no-bitcoinon
+ fi
+ fi
+ fi
+}
+walletoff() {
+ local active
+ active=false
+ no_on=true
+ if [[ $(readlink -f /var/lib/bitcoind/wallets) == /q/wallets ]]; then
+ if systemctl --quiet is-active bitcoind; then
+ if [[ -e /tmp/no-bitcoinon ]]; then
+ no_on=true
+ else
+ if [[ $EUID == 0 ]]; then
+ m install -T -o iank -g iank /dev/null /tmp/no-bitcoinon
+ else
+ m touch /tmp/no-bitcoinon
+ fi
+ fi
+ active=true
+ m ser stop bitcoind
+ else
+ echo note: bitcoind not active
+ fi
+ m rm /var/lib/bitcoind/wallets
+ if $active; then
+ # note, starting bitcoin always fails, but it actually
+ # succeeds. But this is strangely not consistent.
+ m ser start bitcoind
+ if ! $no_on; then
+ m rm /tmp/no-bitcoinon
+ fi
+ fi
+ fi
+}