X-Git-Url: https://iankelling.org/git/?p=distro-setup;a=blobdiff_plain;f=brc2;fp=brc2;h=32ac77a4219ff33b15dbe858ac7d05903c51f46b;hp=fbe19ebbcca468d00b2f2caa942466cd83bf88ec;hb=21bddd1d26a0349f3932f12c65fbc0775e855880;hpb=0f9a999aa601cd77343a3e08cf0c6c4f9f943813 diff --git a/brc2 b/brc2 index fbe19eb..32ac77a 100644 --- a/brc2 +++ b/brc2 @@ -1806,6 +1806,66 @@ satoshi() { # $1 satoshi in usd printf "$%.2f\n" "$(echo "scale=10; $price * $1"| bc -l)" fi } + +# Bitcoin holds open the wallet file. this causes problems for a +# secondary computer running bitcoin and receiving a backup. So, as a +# workaround, I intend to manually enable 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 + fi + m rm /var/lib/bitcoind/wallets + if $active; then + m ser start bitcoind + if ! $no_on; then + m rm /tmp/no-bitcoinon + fi + fi + fi +} #### end bitcoin related things