X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=brc2;h=5f0a5ff45f5ee11430b1d232c6fed78473686b2a;hb=5a6e794f459b3e83b6d665e05d0ab0c8bc6cdfbe;hp=3f62206fe633c812068b552d83d6d6d1e67120c5;hpb=0b452f8ac2191cec4b0ec05537320ddddb213d4f;p=distro-setup diff --git a/brc2 b/brc2 index 3f62206..5f0a5ff 100644 --- 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 @@ -439,22 +446,19 @@ astudio() { # Convert brains file path to url and vice versa # usage: brains [URL_OR_PATH] brains() { - _iki-convert '(/a)?/f/brains' brains.fsf.org/wiki "$@" + _iki-convert brains.fsf.org/wiki "$@" } glue() { - _iki-convert '(/a)?/f/gluestick' gluestick.office.fsf.org "$@" + _iki-convert gluestick.office.fsf.org "$@" } -# usage: $0 REPO_PATH [URL_OR_PATH] +# usage: see above _iki-convert() { - local url prefix path input err repo_dir dir url_dir url - repo_dir="$1" - prefix="$2" - shift 2 - err=false - if $err; then - return 1 - fi + local url url_prefix path input err repo_dir dir url_dir url name + url_prefix="$1" + name="${url_prefix%%.*}" + repo_dir="/f/$name" + shift if [[ $1 ]]; then input="$*" else @@ -462,7 +466,7 @@ _iki-convert() { fi case $input in http*) - path="$repo_dir/${input##http*://"$prefix"/}" + path="$repo_dir/${input##http*://"$url_prefix"/}" if [[ $path == */ ]]; then path=${path%/}.mdwn fi @@ -470,8 +474,8 @@ _iki-convert() { ;; *) path=$(fp "$input") - url_dir=$(echo "$path" | sed -r "s,^$repo_dir/,,") - url="https://$prefix/$url_dir" + url_dir=$(echo "$path" | sed -r "s,^(/a)?$repo_dir/,,") + url="https://$url_prefix/$url_dir" url="${url%.mdwn}/" j echo "$url" ;; @@ -744,7 +748,7 @@ mpvrpc-percent-pos() { # q quit # ret next # -beetag() { +beetag() { local last_genre_i fstring tag id char new_item char_i genre tag remove doplay i j random path local do_rare_genres read_wait help line lsout tmp ls_line skip_lookback local escape_char escaped_input expected_input skip_input_regex right_pad erasable_line seek_sec @@ -1802,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 @@ -2982,6 +3046,35 @@ prof-recent-local() { done } +prof-sort() { + case $HOSTNAME in + kd) + prof-recent-sort + ;; + *) + ssh b8.nz prof-recent-sort + ;; + esac +} + +prof-recent-sort() { + local d dates date files f + # consider making the day count passed by parameter. note: this works: $(date -d '2 day ago' +%Y_%m_%d) + dates=("$(date +%Y_%m_%d)" "$(date -d '1 day ago' +%Y_%m_%d)" ) + files=() + for d in /d/p/profanity/chatlogs/iank_at_fsf.org/!(rooms); do + for date in ${dates[@]}; do + f=$d/$date.log + if [[ -e $f ]]; then + files+=($f) + fi + done + done + for f in "${files[@]}"; do + sed "s/\$/ $f/" $f + done | sort +} + # usage: debvm DEBIAN_VERSION RAM_MB debvm() { @@ -3074,6 +3167,7 @@ ngo() { otp() { oathtool --totp -b "$*" | xclip -selection clipboard } +# run cmd and copy output j() { "$@" |& pee "xclip -r -selection clipboard" cat } @@ -4062,13 +4156,18 @@ fi # rg with respecting vcs ignore files rgv() { ret=0 + # settings that are turned off for pipes, keep them on. + # Found by searching for "terminal" in --help + # --heading + # -n + # # -. = search dotfiles # -z = search zipped files # -i = case insensitive # -M = max columns # --no-messages because of annoying errors on broken symlinks # --no-ignore-parent because i have /a/.git which ignores almost everything under it. - command rg -. -z --no-messages -i -M 900 --no-ignore-parent -g '!.git' -g '!auto-save-list' -g '!.savehist' "$@" || ret=$? + command rg -n --heading -. -z --no-messages -i -M 900 --no-ignore-parent -g '!.git' -g '!auto-save-list' -g '!.savehist' "$@" || ret=$? return $ret } @@ -4156,6 +4255,13 @@ hssh-update() { fi } +noi3bar() { + touch /tmp/noi3bar +} +i3bar() { + rm -fv /tmp/noi3bar +} + export BASEFILE_DIR=/a/bin/fai-basefiles