# but meh. dunno why, but just " *" does glob expansion, so use [ ] to avoid it.
HISTIGNORE='pass *:otp *:oathtool *:histrm *'
+# note: duplicated in /a/bin/ds/filesystem/etc/profile.d/environment.sh
+umask 022
+
#### if (in
export SSH_CONFIG_FILE_OVERRIDE=/root/.ssh/confighome
+
+
# emacs has a different default search path than the info command. This
-# adds the info defaults to emacs, but not the reverse, because I dun
+# adds the info defaults to emacs. This is commented because after
+# various upgrades this is no longer a problem: for the directories that
+# exist on my system, emacs already includes the ones that info
+# searches.
+#
+# but not the reverse, because I dun
# care much about the cli. The search path is only on the cli if you run
# "info xxx", or in emacs if you run '(info xxx)', so not that
-# important, but might as well fix it.
+# important and i don't bother fixing it.
+
+# # info info says this path is what was compiled, and its not documented
+# # anywhere. Through source grepping, i found it in files.h of the info
+# # source in trisquel flidas.
+# #
+# # Trailing : means for emacs to add its own stuff on to the end.
+# #
+# # A problem with this is that directories which are not readable breaks info. And of course, this hard coding is not nice.
+# # I removed PATH from the start, because I've never seen an info file in PATH. And removed ".", because I can just specify the full file name in that case.
+# #
+# # https://raw.githubusercontent.com/debian-tex/texinfo/master/info/filesys.h
+# #
+
+# # note: to split up the var like this, do:
+# # IFS=:; printf '%s\n' $INFOPATH
+
+# dirs=(
+# /usr/local/info
+# /usr/info
+# /usr/local/lib/info
+# /usr/lib/info
+# /usr/local/gnu/info
+# /usr/local/gnu/lib/info
+# /usr/gnu/info
+# /usr/gnu/lib/info
+# /opt/gnu/info
+# /usr/share/info
+# /usr/share/lib/info
+# /usr/local/share/info
+# /usr/local/share/lib/info
+# /usr/gnu/lib/emacs/info
+# /usr/local/gnu/lib/emacs/info
+# /usr/local/lib/emacs/info
+# /usr/local/emacs/info
+# )
+
+# for d in ${dirs[@]}; do
+# if [[ -r $d ]]; then
+# INFOPATH="$d:$INFOPATH"
+# fi
+# done
+# unset d dirs
+
+
+# note: guix bash config does this automatically.
+if [[ $INFOPATH != *: ]]; then
+ INFOPATH="$INFOPATH:"
+fi
-# info info says this path is what was compiled, and its not documented
-# anywhere. Through source grepping, i found it in filesys.h of the info
-# source in trisquel flidas.
+# info parameter expansion
+#
+# info cheat sheet:
+# H: see keybinds
+# / search, {, }: next/prev match
+# ctrl/alt-v scroll forward/backward within this node
+# l: go to previous node
#
-# Traling : means for emacs to add its own stuff on to the end.
+info-pe() {
+ info bash 'Basic Shell Features' 'Shell Expansions' 'Shell Parameter Expansion'
+}
-export INFOPATH=$PATH:/usr/local/info:/usr/info:/usr/local/lib/info:/usr/lib/info:/usr/local/gnu/info:/usr/local/gnu/lib/info:/usr/gnu/info:/usr/gnu/lib/info:/opt/gnu/info:/usr/share/info:/usr/share/lib/info:/usr/local/share/info:/usr/local/share/lib/info:/usr/gnu/lib/emacs/info:/usr/local/gnu/lib/emacs/info:/usr/local/lib/emacs/info:/usr/local/emacs/info:.:
# for openwrt system that has no stty, this is easier than
# guarding every time i use it.
(( ret == 0 )) || return $ret
}
ccomp time jdo
+
+# standard date as used in logs
+datelog() {
+ date +%Y-%m-%d "$@"
+}
+
+# date in log appropriate format
+dtl() {
+ date "+%F %T" "$@"
+}
+
+# ts formatted
+tsf() {
+ command ts "%F %T" "$@"
+}
+
+# ts log. log command to log file.
+# usage: tsl LOG_PATH_PREFIX COMMAND...
+# example: tsl /root/command
+# log file will be like /root/command-2024-02-10.log
+tsl() {
+ local log_prefix log_path appending ret
+ if (( $# < 2 )); then
+ echo "tsl: error: expected >= 2 arguments, got $#" >&2
+ return 1
+ fi
+ log_prefix="$1"
+ if [[ $log_prefix == */* && ! -d ${log_prefix%*/} ]]; then
+ echo "tsl: error: expected directory at ${log_prefix%*/}" >&2
+ return 1
+ fi
+ log_path=$log_prefix-$(date +%Y-%m-%d).log
+ appending=false
+ if [[ -s $log_path ]]; then
+ appending=true
+ fi
+ shift
+ printf "%s\n" "CWD: $PWD, log: $log_path, running $*" | ts "%F %T" | tee -a "$log_path"
+ ret=0
+ "$@" |& ts "%F %T" | tee -a "$log_path" || ret=$?
+ printf "%s\n" "exit code $ret from command: $*" | ts "%F %T" | tee -a "$log_path"
+ if $appending; then
+ printf "%s\n" "note: this log file contains logs before those of previous command" | ts "%F %T" | tee -a "$log_path"
+ fi
+}
+
+disk-info() {
+ local cmds cmd
+ mapfile -t cmds <<'EOF'
+tail -n +1 /proc/mdstat /etc/mdadm/mdadm.conf /etc/fstab /etc/crypttab
+lsblk
+blkid
+ls -la /dev/disk/by-id
+EOF
+
+ for cmd in "${cmds[@]}"; do
+ cat <<EOF
+### $cmd
+
+\`\`\`
+EOF
+ $cmd
+ cat <<'EOF'
+
+```
+
+EOF
+ done
+}
+
#### end fsf section
cp "$my_f_tempdir"/* "$target"
}
-_khfix_common() {
- local host ip port file key
+_khfix-common() {
+ local host ip port file key tmp
read -r host ip port < <(timeout -s 9 2 ssh -oBatchMode=yes -oControlMaster=no -oControlPath=/ -v $1 |& sed -rn "s/debug1: Connecting to ([^ ]+) \[([^\]*)] port ([0-9]+).*/\1 \2 \3/p" ||: )
file=$(readlink -f ~/.ssh/known_hosts)
if [[ ! $ip ]]; then
host_entry=$host
fi
if [[ $host != "$ip" ]]; then
- key=$(ssh-keygen -F "$host_entry" -f $file | sed -r 's/^.*([^ ]+ +[^ ]+) *$/\1/')
+ tmp=$(mktemp)
+ ssh-keygen -F "$host_entry" -f $file >$tmp || [[ $? == 1 ]] # 1 when it doesnt exist in the file
+ if [[ -s $tmp ]]; then
+ key=$(sed -r 's/^.*([^ ]+ +[^ ]+) *$/\1/' $tmp)
+ fi
+ rm $tmp
if [[ $key ]]; then
grep -Fv "$key" "$file" | sponge "$file"
fi
+ key=
fi
- key=$(ssh-keygen -F "$ip_entry" -f $file | sed -r 's/^.*([^ ]+ +[^ ]+) *$/\1/')
+ tmp=$(mktemp)
+ ssh-keygen -F "$ip_entry" -f $file >$tmp || [[ $? == 1 ]]
+ if [[ -s $tmp ]]; then
+ key=$(sed -r 's/^.*([^ ]+ +[^ ]+) *$/\1/' $tmp)
+ fi
+ rm $tmp
if [[ $key ]]; then
grep -Fv "$key" "$file" | sponge "$file"
fi
ll ~/.ssh/known_hosts
- rootsshsync
}
-khfix() { # known hosts fix
- _khfix_common "$@" || return 1
+khfix-r() { # known hosts fix + root
+ _khfix-common "$@" || return 1
ssh $1 :
+ rootsshsync
}
-khcopy() {
- _khfix_common "$@"
- ssh-copy-id $1
+khfix() {
+ _khfix-common "$@" || return 1
+ ssh $1 :
}
# copy path into clipboard
hrcat() { local f; for f; do [[ -f $f ]] || continue; hr; echo "$f"; cat "$f"; done }
+# example usage:
+# github-release-dl restic/restic restic_ _linux_amd64.bz2
+# gets a url like:
+# https://github.com/restic/restic/releases/download/v0.16.3/restic_0.16.3_linux_amd64.bz2
+github-release-dl() {
+ local github_path file_prefix file_suffix latest_prefix version redir_path
+ github_path=$1
+ file_prefix=$2
+ file_suffix=$3
+ if (( $# != 3 )); then
+ echo "$0: error, expected 3 arguments" >&2
+ return 1
+ fi
+ redir_path="https://github.com/$github_path/releases/latest/download/"
+ latest_prefix=$(curl -s -I "$redir_path" | awk 'tolower($1) == "location:" {print $2}')
+ # it has a trailing /r at the end. just kill any whitespace.
+ latest_prefix="${latest_prefix//[$'\t\r\n ']}"
+ if [[ ! $latest_prefix ]]; then
+ echo "failed to find latest path. Tried to find case insensitive 'location:' in the curl output:"
+ m curl -s -I "$redir_path"
+ return 1
+ fi
+ version="${latest_prefix##*/}"
+ version="${version#v}"
+ m wget -- "$latest_prefix/$file_prefix$version$file_suffix"
+}
+
+# examples.
+# go-github-install restic/restic restic_ _linux_amd64.bz2
+# go-github-install restic/rest-server rest-server_ _linux_amd64.tar.gz
+
+# common pattern among go binaries on github
+go-github-install() {
+ local tmpd targetf tmp files src
+ tmpd=$(mktemp -d)
+ cd $tmpd
+ file_prefix=$2
+ file_suffix=$3
+ tmp="${file_prefix##*[[:alnum:]]}"
+ targetf="${file_prefix%$tmp}"
+ echo targetf: $targetf
+ github-release-dl "$@"
+ files=(./*)
+ case $file_suffix in
+ *.bz2)
+ bunzip2 -- ./*
+ ;;
+ *.tar.gz|*.tgz)
+ tar -vxzf ./*
+ ;;
+ esac
+ rm -f -- "${files[@]}"
+ files=(./*)
+ # Here we detect and handle 2 cases: either we extracted a single
+ # binary which we have to rename or a folder with a binary named
+ # $targetf in it which is all we care about.
+ if (( ${#files[@]} == 1 )) && [[ -f ${files[0]} ]]; then
+ chmod +x ./*
+ mv -- ./* /usr/local/bin/$targetf
+ else
+ files=(./*/$targetf)
+ if [[ -f $targetf ]]; then
+ src=$targetf
+ elif [[ -f ${files[0]} ]]; then
+ src="${files[0]}"
+ fi
+ chmod +x "$src"
+ mv -- "$src" /usr/local/bin
+ fi
+ cd - >/dev/null
+ rm -rf $tmpd
+}
+## 2024: I'm using gh instead of hub, but leaving this just in case.
+## I tried the github cli tool (gh) and it seems easier than
+## I remember hub.
+##
+## hub predated github's 2020 official cli tool gh.
+## more info at
+## https://raw.githubusercontent.com/cli/cli/trunk/docs/gh-vs-hub.md
# get latest hub and run it
# main command to use:
# hub pull-request --no-edit
+# todo: test variable assignment with newlines here.
+# https://stackoverflow.com/questions/15783701/which-characters-need-to-be-escaped-when-using-bash
+
+# beware that it only works on the assumption that any special
+# characters in the input string are intended to be escaped, not to work
+# as special chacters.
+shellescape() {
+ LC_ALL=C sed -e 's/[^a-zA-Z0-9,._+@%/-]/\\&/g; 1{$s/^$/""/}; 1!s/^/"/; $!s/$/"/'
+}
+
rmstrips() {
ssh fencepost head -n 300 /gd/gnuorg/EventAndTravelInfo/rms-current-trips.txt | less
}
}
myiwscan() {
- # find input, copy to pattern space, when we find the first field, print the copy in different order without newlines.
- # instead of using labels, we could just match a line and group, eg: /signal:/,{s/signal:(.*)/\1/h}
- sudo iw dev wls1 scan | sed -rn "
+ local i
+ interfaces=$(iw dev | awk '$1 == "Interface" {print $2}')
+ for i in $interfaces; do
+ echo "myiwscan: considering $i"
+ # find input, copy to pattern space, when we find the first field, print the copy in different order without newlines.
+ # instead of using labels, we could just match a line and group, eg: /signal:/,{s/signal:(.*)/\1/h}
+ sudo iw dev $i scan | sed -rn "
s/^\Wcapability: (.*)/\1/;Ta;h;b
:a;s/^\Wsignal: -([^.]+).*/\1/;Tb;H;b
# padded to min width of 20
:b;s/\WSSID: (.*)/\1 /;T;s/^(.{20}(.*[^ ])?) */\1/;H;g;s/(.*)\n(.*)\n(.*)/\2 \3 \1/gp;b
"|sort -r
+ done
}
# Run script by copying it to a temporary location first,
}
-disk-info() {
- local cmds cmd
- mapfile -t cmds <<'EOF'
-tail -n +1 /proc/mdstat /etc/mdadm/mdadm.conf /etc/fstab /etc/crypttab
-lsblk
-blkid
-ls -la /dev/disk/by-id
-EOF
+fsf-sv-header() {
+ local f
+ local -a f_maybe
+ if ! type -p sponge &>/dev/null; then
+ echo "$0: error: missing dependency: sudo apt install moreutils" >&2
+ return 1
+ fi
- for cmd in "${cmds[@]}"; do
- cat <<EOF
-### $cmd
+ for f; do
+ echo "adding header to $f"
+ if [[ -s $f ]]; then
+ f_maybe=("$f")
+ else
+ f_maybe=()
+ fi
+ cat - "${f_maybe[@]}" <<EOF | sponge "$f"
+The following is the GNU All-permissive License as recommended in
+<https://www.gnu.org/licenses/license-recommendations.en.html>
-\`\`\`
-EOF
- $cmd
- cat <<'EOF'
+Copyright (C) $(date +%Y) Free Software Foundation <sysadmin@fsf.org>
-```
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved. This file is offered as-is,
+without any warranty.
+
+Contributions are welcome. See <https://savannah.gnu.org/maintenance/fsf/>.
EOF
done
}
+
+tsr() { # ts run
+ "$@" |& ts || return $?
+}
+
+
# * misc stuff
mpvrpco '{ "command": ["get_property", "percent-pos"] }' | jq .data | sed 's/\..*/%/' 2>/dev/null ||:
}
+# run if not running.
+#
+# Note: this does not work with shell scripts as they are normally
+# invoked, because the ps output has the interpreter at the start.
+# A workaround is to invoke the command in that format, or we could
+# do various other workarounds.
+#
+# background, this relies on how ps converts newlines in arguments to spaces, and
+# assumes we won't be searching for a command with spaces in its arguments
+rinr() {
+ if ps h -o args -C "${1##*/}" | grep -Fxqv "$*" &>/dev/null || [[ $? == 141 ]]; then
+ "$@"
+ fi
+}
+# variation of above: run or wait if running
+rowir() {
+ local pid
+ pid=$(ps h -o 'pid,args' -C "${1##*/}" | sed -r 's/^[[:space:]]*([0-9]+)[[:space:]](.*)/\1\n\2/' | grep -B1 -Fx "$*" | head -n1 ||: )
+ if [[ $pid ]]; then
+ # https://unix.stackexchange.com/questions/427115/listen-for-exit-of-process-given-pid
+ tail --pid="$pid" -f /dev/null
+ else
+ "$@"
+ fi
+}
+
+mpvrpc-loadfile() {
+ local path nextpath cachedir finalpath nextpath count
+ cachedir=$HOME/.iank-music-cache
+ path="$1"
+ nextpath="$2"
+
+ # note: logic duplicated in beetpull
+ local remote_p=true
+ if [[ $HOSTNAME == kd ]]; then
+ remote_p=false
+ fi
+
+ if $remote_p; then
+ finalpath="$cachedir${path#/i/m}"
+ rowir rsync --partial -a --inplace --mkpath "b8.nz:$path" "$finalpath"
+ finalnextpath="$cachedir${nextpath#/i/m}"
+ count=$(pgrep -a -f "^rsync --partial -a --inplace --mkpath $cachdir" || [[ $? == 1 ]] )
+ # allow us to start 2 rsyncs in the background
+ if [[ $count == [01] ]]; then
+ rinr rsync --partial -a --inplace --mkpath "b8.nz:$nextpath" "$finalnextpath" &
+ fi
+ else
+ finalpath="$path"
+ fi
+ mpvrpc '{ "command": ["loadfile", "'"$finalpath"'"] }'
+}
+
# tag with beets.
# usage: beetag [-r] [-s] QUERY
# it lists the query, reads an input char for tagging one by one.
fi
### end arg processing ###
- beetpull
+ # note: I used to do beetpull here, but mpv + ssfs on slowish
+ # connection leads to bad/buggy result.
do_rare_genres=false
volume=70
first_play=false
for (( i=0; i<20; i++ )); do
if [[ $(mpvrpco '{ "command": ["get_property", "idle-active"] }' 2>/dev/null | jq .data) == true ]]; then
- mpvrpc '{ "command": ["loadfile", "'"$path"'"] }' 2>/dev/null
+ mpvrpc-loadfile "$path" 2>/dev/null
break
fi
sleep .1
done
else
- mpvrpc '{ "command": ["loadfile", "'"$path"'"] }'
+ mpvrpc-loadfile "$path"
fi
erasable_line=false
fi
doplay=false
else
doplay=true
- mpvrpc '{ "command": ["loadfile", "'"$path"'"] }'
+ mpvrpc-loadfile "$path"
erasable_line=false
fi
beetag-nostatus 1
}
# 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.
+# secondary computer running bitcoin and receiving a backup (as of
+# 2023). However, in 2024-02, I ran a backup where a receiving machine
+# had the wallet enabled and there was no error, so I don't know if this
+# is still an issue or likely it is an inconsistent behavior.
+#
+# As a workaround, this function is for enabling the wallet when I want
+# to use it and leave it disabled otherwise.
walleton() {
local active
active=false
fi
active=true
m ser stop bitcoind
+ else
+ echo note: bitcoind not active
fi
m rm /var/lib/bitcoind/wallets
if $active; then
+ # note, starting bitcoin always fails, but it actually
+ # succeeds. But this is strangely not consistent.
m ser start bitcoind
if ! $no_on; then
m rm /tmp/no-bitcoinon
digdiff @ns{1,2}.iankelling.org "$@"
}
-tsr() { # ts run
- "$@" |& ts || return $?
-}
-
dup() {
local ran_d
ran_d=false
vpn_ips[kw]=27
vpn_ips[bo]=28
vpn_ips[frodo]=34
+vpn_ips[s23b]=49
vpn-ips-update() {
local host ipsuf f files
"$@" |& pee "xclip -r -selection clipboard" cat
}
-# x copy
+# xorg copy. copy text piped into command
xc() {
xclip -r -selection clipboard
}
e spamtest error: expected 1 arg, filename >&2
return 1
fi
-
- spamdpid=$(systemctl status spamassassin| sed -n '/^ *Main PID:/s/[^0-9]//gp')
- spamcpre="nsenter -t $spamdpid -n -m"
- s $spamcpre sudo -u Debian-exim spamassassin -t --cf='score PYZOR_CHECK 0' <"$1"
+ sdncmdroot spamassassin sudo -u Debian-exim spamassassin -t --cf='score PYZOR_CHECK 0' <"$1"
}
$s /a/exe/teeu "$@"
}
+# execute exim in its namespace. Useful args like -Mrm
enn() {
local ecmd pid
ecmd="/usr/sbin/exim4 -C /etc/exim4/my.conf"
if ip a show veth1-mail &>/dev/null; then
s $ecmd "$@"
- return
+ else
+ sdncmdroot exim4 $ecmd "$@"
fi
- pid=$(pgrep -f "/usr/sbin/exim4 -bd -q10m -C /etc/exim4/my.conf"|h1)
- m s nsenter -t $pid -n -m $ecmd "$@"
}
# get pid of systemd service
m sudo nsenter -t $pid -n -m sudo -u $USER -i bash
}
-sdnbashroot() { # systemd namespace bash
+sdnbashroot() { # systemd namespace bash as root
local unit pid
if (( $# != 1 )); then
echo $0: error wrong number of args >&2
}
-sdncmd() { # systemd namespace cmd
+# systemd namespace cmd
+# usage: UNIT CMD...
+sdncmd() {
local unit pid tmpf
- if (( $# <= 2 )); then
+ if (( $# <= 1 )); then
echo $0: error wrong number of args >&2
return 1
fi
m sudo nsenter -t $pid -n -m sudo -u $USER -i bash -c ". $tmpf & rm $tmpf"
}
+sdncmdroot() { # systemd namespace root command
+ local unit pid
+ if (( $# < 2 )); then
+ echo $0: error wrong number of args >&2
+ return 1
+ fi
+ unit=$1
+ shift
+ pid=$(servicepid $unit)
+ m sudo nsenter -t $pid -n -m "$@"
+}
+
mailnnbash() {
sdnbash mailnn
# }
eximbash() {
- local pid
- pid=$(pgrep -f "/usr/sbin/exim4 -bd -q10m -C /etc/exim4/my.conf"|h1)
- if [[ ! $pid ]]; then
- echo "eximbash: failed to find exim pid. systemctl -n 30 status exim4:"
- systemctl status exim4
- fi
- m sudo nsenter -t $pid -n -m
+ sdnbashroot exim4
}
spamnn() {
local spamdpid
m sudo nsenter -t $spamdpid -n -m sudo -u Debian-exim spamassassin "$@"
}
unboundbash() {
- m sudo nsenter -t "$(systemctl status unbound| sed -n '/^ *Main PID:/s/[^0-9]//gp')" -n -m sudo -u $USER -i bash
+ sdnbashroot unbound
}
nmtc() {
vpncmd() {
- m sudo -E env "PATH=$PATH" nsenter -t "$(pgrep -f "/usr/sbin/openvpn .* --config /etc/openvpn/.*client.conf")" -n "$@"
+ sdncmd openvpn-client-tr@client.service "$@"
}
-
vpni() {
- vpncmd sudo -u iank env "PATH=$PATH" "$@"
+ sdncmd openvpn-client-tr@client.service bash
}
vpnbash() {
- vpncmd bash
+ sdncmdroot openvpn-client-tr@client.service bash
}
um() {
local sink card
sink=$(pactl get-default-sink)
- if [[ $sink != auto_null ]]; then
- return
+ if [[ $sink == auto_null ]]; then
+ # guessing there is just one with an off profile. otherwise we will
+ # need some other solution, like storing the card identifier that we
+ # muted with nap.
+ card=$(pacmd list-cards | sed -n '/^[[:space:]]*index:/{s/^[[:space:]]*index://;h};/^[[:space:]]*active profile: <off>$/{g;p;q}')
+ m pacmd set-card-profile "$card" output:analog-stereo
fi
- # guessing there is just one with an off profile. otherwise we will
- # need some other solution, like storing the card identifier that we
- # muted with nap.
- card=$(pacmd list-cards | sed -n '/^[[:space:]]*index:/{s/^[[:space:]]*index://;h};/^[[:space:]]*active profile: <off>$/{g;p;q}')
- m pacmd set-card-profile "$card" output:analog-stereo
-
- pactl set-sink-mute @DEFAULT_SINK@ false
+ m pactl set-sink-mute @DEFAULT_SINK@ false
rm -f /tmp/ianknap
}
rgv -m 5 -- "$*" $paths /a/t.org /p/w.org /a/work.org ||:
}
+# re on common fsf files
+ref() {
+ local paths
+ paths="/f/gluestick /f/brains /f/s /c"
+ find $paths -not \( -name .svn -prune -o -name .git -prune \
+ -o -name .hg -prune -o -name .editor-backups -prune \
+ -o -name .undo-tree-history -prune \) 2>/dev/null | grep -iP --color=auto -- "$*" ||:
+ rgv -- "$*" $paths /a/work.org ||:
+ }
+
# for use in /f/bind
fupzone() {
rm -fv /tmp/noi3bar
}
+# example:
+# <#part type="image/jpeg" filename="/home/iank/2023-12-24-ski-trip.jpg" disposition=attachment> <#/part>
+#
+attach-txt() {
+ local f
+ for f; do
+ if [[ ! -s $f ]]; then
+ e "error: empty or non-existent file $f"
+ return 1
+ fi
+ done
+ for f; do
+ echo '<#part type="image/jpeg" filename="'"$(rl "$f")"'" disposition=attachment> <#/part>'
+ done | ec
+}
export BASEFILE_DIR=/a/bin/fai-basefiles
--- /dev/null
+#!/bin/bash
+. ~/.bashrc
+"$@"
elif ping -q -c1 -w1 $h.b8.nz &>/dev/null; then
# in case we took it home
targets+=(x3.b8.nz)
+ elif ping -q -c1 -w1 ${h}w.b8.nz &>/dev/null; then
+ targets+=(x3w.b8.nz)
else
targets+=(x3wg.b8.nz)
fi
fi
cd /a/opt/btrbk
m make install
+ cd /
fi
# TODO: i wonder if there should be an option to send to the default
prospective_mps+=(/o)
fi
if [[ $source_host == "$HOST2" ]]; then
- prospective_mps+=(/a /ar /qr /qd /q)
+ prospective_mps+=(/a /qr /qd /q)
fi
else
if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
prospective_mps+=(/o)
fi
if [[ $HOSTNAME == "$HOST2" ]]; then
- prospective_mps+=(/a /ar /qr /qd /q)
+ prospective_mps+=(/a /qr /qd /q)
fi
if $kd_spread; then
- prospective_mps=(/a /ar /o /qr /qd /q)
+ prospective_mps=(/a /o /qr /qd /q)
fi
fi
# note: put q last just in case its specific retention options were to
### end bitcoin
+### begin gh ####
+
+# from https://raw.githubusercontent.com/cli/cli/trunk/docs/install_linux.md
+# One time setup afterwards:
+# gh auth login
+#
+# When it gets to the page where it asks to authorize github, the button
+# is grayed out. You can just open browser dev tools, inspect the
+# button, remove disabled="", then click it and it works.
+#
+# Auth token gets saved into /p/c/subdir_files/.local/share/keyrings/
+#
+# initial config goes to /home/iank/.config/gh
+curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
+ && sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
+ && echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
+ && sudo apt update \
+ && sudo apt install gh -y
+
+### end gh ####
+
+# remove trisquel banner. it is cool but takes up too much space.
+sudo rm -f /etc/update-motd.d/01-banner
+
case $HOSTNAME in
kw|x3)
sd /etc/cups/client.conf <<'EOF'
+# field allowed values
+# ----- --------------
+# minute 0–59
+# hour 0–23
+# day of month 1–31
+# month 1–12 (or names, see below)
+# day of week 0–7 (0 or 7 is Sun, or use names)
+
+
# default is /bin/sh
SHELL=/bin/bash
# default is /usr/bin:/bin
4 20 * * 5 iank /usr/local/bin/check-lets-encrypt-ssl-settings
4 21 * * 5 iank /b/ds/auto-commit-changes /a /p
4 24 * * 5 iank failmail /b/ds/eggdrop-upgrade
+# avoid dnssec expirations. This is a hack, what we should
+# do instead is something like, sign only if expiration is
+# coming soon, and send an email notication, because this
+# push a version that is in the midst of editing. Whatever,
+# I rarely edit them.
+0 16 5 * * iank brcrun bindpush
#!/bin/sh
+
+# Exports here get inherited by X, that is the only reason to do things
+# here. However, they do not get sent with sl().
+
if [ -f $HOME/path-add-function ]; then
. $HOME/path-add-function
path-add /usr/sbin /usr/local/sbin /a/exe /a/opt/bin
# group, so if you copy files there with exact perms, that is probably
# not what you want. I don't use a system like that, so I don't
# care.
+#
+# Note: duplicated in .bashrc
umask 022
# this is how we could test for non-system user
# in case.
LLMNR=no
MulticastDNS=no
-Domains=fsf.org gnu.org
--- /dev/null
+[Unit]
+Description=NZBGet Daemon
+Documentation=http://nzbget.net/Documentation
+After=network.target
+
+[Service]
+User=iank
+Group=iank
+Type=forking
+ExecStart=/usr/bin/nzbget -D
+ExecStop=/usr/bin/nzbget -Q
+ExecReload=/usr/bin/nzbget -O
+KillMode=process
+Restart=on-failure
+
+[Install]
+WantedBy=multi-user.target
#!/bin/bash
+# man profanity says:
+# ALT+c Run external editor (see profanity-editor(1)) for current input line.
+# note: this is NOT in the online manual list of commands, that has got to
+# be a bug.
+
# This, along with changes to emacs init file and prof-remote allows us
# to press alt-c in profanity to send the current text to #fsfsys.
exec emacsclient -s profanity -a "" "$@"
if xrandr | grep -q "^$output disconnected" &>/dev/null; then
xrandr --auto
else
+ xrandr --output $output --off
+ sleep 2
xrandr --output $output --right-of eDP1 --mode 3840x2160
for i in 1 2 4 5 6 7 8 9 10; do
subvolume d
target send-receive /mnt/rust1/btrbk
target send-receive /mnt/rust2/btrbk
+
+subvolume ar
+target send-receive /mnt/rust1/btrbk
+target send-receive /mnt/rust2/btrbk
ssl = required
# this is the same as the certbot list, i check changes in /a/bin/ds/filesystem/usr/local/bin/check-lets-encrypt-ssl-settings
ssl_cipher_list = ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
-ssl_protocols = TLSv1.2
+ssl_min_protocol = TLSv1.2
ssl_prefer_server_ciphers = no
protocol lmtp {
}
cd /m/md
-archive 800 ./!(*archive|Drafts|Sent|INBOX)/*(cur|new) ./l/!(*archive)/*(cur|new)
+archive 800 ./!(*archive|board|Drafts|Sent|INBOX)/*(cur|new) ./l/!(*archive)/*(cur|new)
archive 60 ./{sysadmin,rtcc,fsfcc,fsfmembers}/{cur,new}
archive 30 ./Junk/{cur,new}
EOF
fi
-fa=(/mnt/root/btrbk/ar.*); f=${fa[0]}
-if [[ -e $f ]]; then
- fstab <<EOF
-$crypt_dev /ar btrfs noatime,subvol=ar,uid=1000,gid=1000$mopts 0 0
-EOF
-fi
+# not syncing ar at the moment
+# fa=(/mnt/root/btrbk/ar.*); f=${fa[0]}
+# if [[ -e $f ]]; then
+# fstab <<EOF
+# $crypt_dev /ar btrfs noatime,subvol=ar,uid=1000,gid=1000$mopts 0 0
+# EOF
+# fi
fa=(/mnt/o/btrbk/o.*); f=${fa[0]}
INFODIR=/usr/share/info
sudo rm -f "$INFODIR/dir"
-for dir in $(emacs --batch --eval '(progn(package-initialize) (dolist (x Info-directory-list) (message x)))' |& sort -u); do
+shopt -s nullglob
+
+for dir in $(emacs --batch --eval '(progn(package-initialize) (dolist (x Info-directory-list) (message x)))' |& sed 's,/$,,' | sort -u); do
case ${dir%/} in
# this is from /usr/sbin/update-info-dir
*/info)
- echo $dir
find $dir -type f | while read file ; do
case $file in
*/dir|*/dir.gz|*/dir.old|*/dir.old.gz|*-[0-9]|*-[0-9].gz|*-[1-9][0-9]|*-[1-9][0-9].gz|*.png|*.jpg)
[^/]*) : ;;
*)
for file in $dir/*.info*; do
- #echo $file
+ echo $file
sudo install-info "$file" "$INFODIR/dir"
done
;;
gpick
grepmail
guvcview
+ gwenview
# for my / office hp printers
hplip
html-xml-utils
pixz
profanity
pry
+ # https://wiki.archlinux.org/title/bluetooth
+ pulseaudio-module-bluetooth
pv
python3-doc
qemu-user-static
+ qimgv
qrencode
readline-doc
rename
transmission-remote-gtk
trash-cli
tty-clock
+ units
uuid-runtime
vlc
wamerican-huge
--- /dev/null
+# The current version of the config schema
+version: 1
+# What protocol to use when performing git operations. Supported values: ssh, https
+git_protocol: https
+# What editor gh should run when creating issues, pull requests, etc. If blank, will refer to environment.
+editor:
+# When to interactively prompt. This is a global config that cannot be overridden by hostname. Supported values: enabled, disabled
+prompt: enabled
+# A pager program to send command output to, e.g. "less". Set the value to "cat" to disable the pager.
+pager:
+# Aliases allow you to create nicknames for gh commands
+aliases:
+ co: pr checkout
+# The path to a unix socket through which send HTTP connections. If blank, HTTP traffic will be handled by net/http.DefaultTransport.
+http_unix_socket:
+# What web browser gh should use when opening URLs. If blank, will refer to environment.
+browser:
--- /dev/null
+github.com:
+ git_protocol: ssh
+ users:
+ ian-kelling:
+ user: ian-kelling
header :contains "list-id" "<linux-raid.vger.kernel.org>",
header :contains "list-id" "<mailop.mailop.org>",
header :contains "list-id" "<gcc.gcc.gnu.org>",
+ header :contains "list-id" "<union.gnu.org>",
header :contains "list-id" "<lilypond-devel.gnu.org>",
+ header :contains "list-id" "<libc-alpha.sourceware.org>",
header :contains "list-id" "<xmonad.haskell.org>") {
if header :regex "list-id" "<([a-z_0-9-]+)[.@]" {
set :lower "listname" "${1}";
header :contains "list-id" "<linux-raid.vger.kernel.org>",
header :contains "list-id" "<mailop.mailop.org>",
header :contains "list-id" "<gcc.gcc.gnu.org>",
+ header :contains "list-id" "<union.gnu.org>",
header :contains "list-id" "<lilypond-devel.gnu.org>",
+ header :contains "list-id" "<libc-alpha.sourceware.org>",
header :contains "list-id" "<xmonad.haskell.org>") {
if header :regex "list-id" "<([a-z_0-9-]+)[.@]" {
set :lower "listname" "${1}";
force=false
force_arg=
pull_reexec=false
-mp_args="-m /o,/a,/ar,/q,/qd,/qr"
+mp_args="-m /o,/a,/q,/qd,/qr"
check_installed=false
orig_args=("$@")
if ! temp=$(getopt -l check-installed,force,pull-reexec,help afioh "$@"); then
/usr/local/{bin/{unsaved-buffers{,.el},switch-mail-host},lib/bash-bear}
)
m scp -F $HOME/.ssh/confighome \
- ${files@/#/root@$old_host:} $tmpd
+ ${files[@]/#/root@$old_host:} $tmpd
diff=false
for f in ${files[@]}; do
if ! diff -q $tmpd/${f##*/} $f; then
if $mail_only; then
mp_args="-m /o"
elif $host2_only; then
- mp_args="-m /a,/ar,/q,/qd,/qr"
+ mp_args="-m /a,/q,/qd,/qr"
fi
if ! $force; then
e Running main btrbk
m btrbk-run -v --fast $bbk_args $force_arg $incremental_arg -m /o || ret=$?
if (( ret )); then
- bang="$(printf "$(tput setaf 5)█$(tput sgr0)%.0s" 1 2 3 4 5 6 7)"
+ bang="███████"
e $bang failed btrbk of /o. restoring old host as primary
- m $old_shell /a/exe/primary-setup localhost
+ if ! m $old_shell /a/exe/primary-setup localhost; then
+ die due to failed btrbk of /o, we tried to restore old host as primary, but then we failed at that too. To resolve: Fix & rerun switch-mail-host, or fix and rerun primary-setup localhost on old shell so you have a working mail server and then rerun switch-mail-host.
+ fi
+ e finished restoring old host as primary, now exiting $ret due to earlier failed btrbk of /o.
exit $ret
fi
# new system is usable at this point
blocks=██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
-printf "%s\n" "$(tput setaf 5 2>/dev/null ||:)${blocks:0:${COLUMNS:-180}}$(tput sgr0 2>/dev/null||:)"
+printf "%s\n" "${blocks:0:${COLUMNS:-100}}"
# once I accidentally accepted incoming mail on old host. I used this script to copy over that mail:
#
fi
fi
- rm -fv /etc/systemd/resolved.conf.d/untrusted-network.conf
+ # https://github.com/jonathanio/update-systemd-resolved
+ # suggests this will help prevent leakage into a vpn interface
+ cat >/etc/systemd/resolved.conf.d/untrusted-network.conf <<EOF
+Domains=~.
+EOF
else #untrusted
# https://wiki.archlinux.org/index.php/Systemd-resolved#Manually
cat >/etc/systemd/resolved.conf.d/untrusted-network.conf <<EOF
[Resolve]
DNS=${servers[@]}
-Domains=b8.nz
+Domains=~. b8.nz
DNSOverTLS=yes
EOF
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
if pgrep -G iank -u iank -f '^emacs --daemon$' &>/dev/null; then
elisp=$(cat /usr/local/bin/unsaved-buffers.el)
- emacsout=$(sudo -u iank env XDG_RUNTIME_DIR=/run/user/1000 emacsclient --eval "$elisp")
+ emacsout=$(sudo -u iank env XDG_RUNTIME_DIR=/run/user/1000 emacsclient --eval "$elisp" ||:)
bufs=$(printf "%s\n" "$emacsout"|sed '/^"nil"$/d;s/^"(/E: /;s/)"$//')
if [[ $bufs ]]; then
echo "error: on $HOSTNAME, unsaved emacs files: $bufs" >&2