From: Ian Kelling Date: Wed, 27 Dec 2023 21:13:02 +0000 (-0500) Subject: fixes X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=21bddd1d26a0349f3932f12c65fbc0775e855880;p=distro-setup fixes --- 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 diff --git a/distro-end b/distro-end index 2913ade..02e5a89 100755 --- a/distro-end +++ b/distro-end @@ -631,7 +631,7 @@ case $HOSTNAME in dnsb8 fi - s /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter -l 127.0.0.1 + sudo /c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter -l 127.0.0.1 # ex for exporter web-conf -p 9101 -f 9100 - apache2 ${HOSTNAME}ex.b8.nz <<'EOF' @@ -2216,18 +2216,14 @@ esac case $HOSTNAME in sy|kd) sudo install -m 0755 -o root -g root -t /usr/bin /a/opt/bitcoin-26.0/bin/* - sgo bitcoind + # Note: i leave it to system-status to start and stop bitcoin. # note: the bitcoin user & group are setup in fai sudo usermod -a -G bitcoin iank # todo: make bitcoin have a stable uid/gid - if [[ ! $(readlink -f /var/lib/bitcoind/wallets) == /q/wallets ]]; then - mkdir -p /var/lib/bitcoind - chown bitcoin:bitcoin /var/lib/bitcoind - # 710 comes from the upstream bitcoin unit file - chmod 710 /var/lib/bitcoind - s lnf /q/wallets /var/lib/bitcoind - sudo chown -h bitcoin:bitcoin /var/lib/bitcoind/wallets - fi + sudo mkdir -p /var/lib/bitcoind + sudo chown bitcoin:bitcoin /var/lib/bitcoind + # 710 comes from the upstream bitcoin unit file + sudo chmod 710 /var/lib/bitcoind # note, there exists # /a/bin/ds/disabled/bitcoin ;; diff --git a/filesystem/usr/local/bin/bitcoinoff b/filesystem/usr/local/bin/bitcoinoff index d952873..c4d9907 100755 --- a/filesystem/usr/local/bin/bitcoinoff +++ b/filesystem/usr/local/bin/bitcoinoff @@ -1,4 +1,7 @@ #!/bin/bash [[ $EUID == 0 ]] || exec sudo "${BASH_SOURCE[0]}" +if [[ -e /tmp/no-bitcoinoff ]]; then + exit 0 +fi systemctl stop bitcoind diff --git a/filesystem/usr/local/bin/bitcoinon b/filesystem/usr/local/bin/bitcoinon index d62e413..50f72b0 100755 --- a/filesystem/usr/local/bin/bitcoinon +++ b/filesystem/usr/local/bin/bitcoinon @@ -1,4 +1,7 @@ #!/bin/bash [[ $EUID == 0 ]] || exec sudo "${BASH_SOURCE[0]}" +if [[ -e /tmp/no-bitcoinon ]]; then + exit 0 +fi systemctl start bitcoind diff --git a/filesystem/usr/local/bin/myupgrade b/filesystem/usr/local/bin/myupgrade index f204796..7a6c562 100755 --- a/filesystem/usr/local/bin/myupgrade +++ b/filesystem/usr/local/bin/myupgrade @@ -29,6 +29,11 @@ d() { fi } myreboot() { + if [[ -e /tmp/myupgrade-noreboot ]]; then + e "would rebooted but /tmp/myupgrade-noreboot exists" + return + fi + for x in {30..1}; do echo "pid $$. unattended upgrade, rebooting in $((x*10)) seconds" | wall -n 2>/dev/null sleep 10 diff --git a/prof-tail b/prof-tail index abfa718..d605d37 100644 --- a/prof-tail +++ b/prof-tail @@ -1,6 +1,10 @@ #!/bin/bash set -e; . /usr/local/lib/bash-bear; set +e +# kill 0 doesn't seem to be documented in man bash, but it kills the +# background processes. +# https://unix.stackexchange.com/questions/67532/what-does-kill-0-do-actually/67552 +trap "kill 0" EXIT xmpp_users=( anoukr @@ -41,6 +45,6 @@ while true; do $logdir/rooms/*/$log_today 2>/dev/null \ | awk '$3 != "iank:"' | grep -i '\biank\b' | awk '{print $3; fflush()}' | sed 's/^/room /;s/@.*//' ||: + kill % sleep 1 - done diff --git a/system-status b/system-status index 7a87e6b..0e63964 100755 --- a/system-status +++ b/system-status @@ -462,7 +462,7 @@ main-loop() { case $bat in 100|9?) : - #bitcoinon & + bitcoinon & ;; esac fi