option for disabling status for less distraction
[distro-setup] / brc2
diff --git a/brc2 b/brc2
index af4d8082aaa92268c4f0f9daa5e10e6501be15c5..5f0a5ff45f5ee11430b1d232c6fed78473686b2a 100644 (file)
--- a/brc2
+++ b/brc2
@@ -58,6 +58,13 @@ source /a/bin/log-quiet/logq-function
 source /a/bin/bash_unpublished/source-semi-priv
 source /a/bin/bash_unpublished/source-state
 
+if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
+  export MAIL_HOST_P=t
+else
+  export NOT_MAIL_HOST_P=t
+fi
+
+
 source /a/bin/log-quiet/logq-function
 
 # not used
@@ -1799,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
 
 
@@ -3100,6 +3167,7 @@ ngo() {
 otp() {
   oathtool --totp -b "$*" | xclip -selection clipboard
 }
+# run cmd and copy output
 j() {
   "$@" |& pee "xclip -r -selection clipboard" cat
 }
@@ -4187,6 +4255,13 @@ hssh-update() {
   fi
 }
 
+noi3bar() {
+  touch /tmp/noi3bar
+}
+i3bar() {
+  rm -fv /tmp/noi3bar
+}
+
 
 export BASEFILE_DIR=/a/bin/fai-basefiles