fixes
[distro-setup] / brc2
diff --git a/brc2 b/brc2
index fbe19ebbcca468d00b2f2caa942466cd83bf88ec..32ac77a4219ff33b15dbe858ac7d05903c51f46b 100644 (file)
--- 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