###### Begin sourcing of files #####
# The distinction between login and non-login shells is super lame
- # and pretty random. get rid of that distinction. The var check is
- # just a random variable i set there and no where else.
- if ! shopt -q login_shell && [[ ! $PITHOSFLY_SAVE_DIR ]]; then
+ # and pretty random. get rid of that distinction.
+ if ! shopt -q login_shell; then
if [[ -r /etc/profile ]]; then
source /etc/profile
fi
email = iank@fsf.org
#email = ian@iankelling.org
[alias]
-# Always use the git lg alias instead of git log. It's too easy to get
-# confused by not seeing branches in git log output.
lg = log --graph
lgstat = log --stat --graph --pretty=format:'%h %ad- %s [%an]'
co = checkout
# hardstatus string "SCREEN @ %H: %-n - %t"
# the default scrollback is way too small
-defscrollback 1000000
\ No newline at end of file
+defscrollback 1000000
+
+# avoid annoying "New screen..." prompt
+# https://serverfault.com/questions/377479/can-i-disable-the-message-line-when-launching-screen-rr
+msgwait 0
# * functions
-ccomp() { # copy completion
- local src=$1
- local c
+
+### begin FSF section ###
+
+# Comments before functions are meant to be good useful
+# documentation. If they fail at that, please improve them or send Ian a
+# note.
+
+## copy bash completion
+# Usage: ORIGINAL_COMMAND TARGET_COMMAND...
+#
+# It copies how the bash completion works from one command to other
+# commands.
+ccomp() {
+ local c src
+ src=$1
shift
if ! c=$(complete -p $src 2>/dev/null); then
_completion_loader $src &>/dev/null ||:
eval $c $*
}
+## directory history tracking and navigation.
+#
+# cd becomes a function, also aliased to c. b to go back, f to go
+# forward, cl to list recent directories and choose one.
+#
+# The finer details you may want to skip:
+#
+# We also define bl to print the list of back and forward directories.
+#
+# We keep 2 stacks, forward and back. Unlike with a web browser, the
+# forward stack is not erased when going somewhere new.
+#
+# Recent directories are stored in ~/.cdirs.
+#
+declare -a _dir_forward _dir_back
+c() {
+ # normally, the top of _dir_back is our current dir. if it isn't,
+ # put it on there, except we don't want to do that when we
+ # just launched a shell
+ if [[ $OLDPWD ]]; then
+ if (( ${#_dir_back[@]} == 0 )) || [[ ${_dir_back[-1]} != "$PWD" ]]; then
+ _dir_back+=("$PWD")
+ fi
+ fi
+ command cd "$@"
+ if (( ${#_dir_back[@]} == 0 )) || [[ ${_dir_back[-1]} != "$PWD" ]]; then
+ _dir_back+=("$PWD")
+ fi
+ echo "$PWD" >> ~/.cdirs
+}
+ccomp cd c
+
+# back
+b() {
+ local top_back
+ if (( ${#_dir_back[@]} == 0 )); then
+ echo "nothing left to go back to" >&2
+ return 0
+ fi
+ top_back="${_dir_back[-1]}"
+
+ if [[ $top_back == "$PWD" ]] && (( ${#_dir_back[@]} == 1 )); then
+ echo "already on last back entry" >&2
+ return 0
+ fi
+
+
+ if [[ $top_back == "$PWD" ]]; then
+ # add to dirf if not already there
+ if (( ${#_dir_forward[@]} == 0 )) || [[ ${_dir_forward[-1]} != "$top_back" ]]; then
+ _dir_forward+=("$top_back")
+ fi
+ unset "_dir_back[-1]"
+ command cd "${_dir_back[-1]}"
+ else
+ if (( ${#_dir_forward[@]} == 0 )) || [[ ${_dir_forward[-1]} != "$PWD" ]]; then
+ _dir_forward+=("$PWD")
+ fi
+ command cd "$top_back"
+ fi
+
+ # Interesting feature, not sure I want it.
+ # give us a peek at what is next in the list
+ # if (( ${#_dir_back[@]} >= 2 )); then
+ # printf "%s\n" "${_dir_back[-2]}"
+ # fi
+ #
+
+ # c/b/f Implementation notes:
+ #
+ # The top of the back is $PWD
+ # as long as the last directory change was due to c,b,or cl.
+ #
+ # Example of stack changes:
+ #
+ # a b c (d)
+ ## back
+ # a b (c)
+ # d
+ #back
+ #a (b)
+ #d c
+ #back
+ #(a)
+ #d c b
+ #forward
+ #a (b)
+ #d c
+ #
+ # a b c
+ ## back
+ # a b
+ # (c)
+ ## forward
+
+}
+# forward
+f() {
+ local top_forward
+ if (( ${#_dir_forward[@]} == 0 )); then
+ echo "no forward dir left" >&2
+ return 0
+ fi
+ top_forward="${_dir_forward[-1]}"
+ unset "_dir_forward[-1]"
+ c "$top_forward"
+
+ # give us a peek at what is next in the list
+ # if (( ${#_dir_forward[@]} )); then
+ # printf "%s\n" "${_dir_forward[-1]}"
+ # fi
+}
+# cd list
+cl() {
+ local i line input start
+ local -A buttondirs alines
+ local -a buttons dirs lines
+ buttons=( {a..z} {2..9} )
+ if [[ ! -s ~/.cdirs ]]; then
+ echo nothing in ~/.cdirs
+ return 0
+ fi
+
+ i=0
+
+ mapfile -t lines <~/.cdirs
+ start=$(( ${#lines[@]} - 1 ))
+
+ # we have ~33 buttons as of this writing, so lets
+ # prune down the history every once in a while.
+ if (( start > 500 )); then
+ tac ~/.cdirs | awk '!seen[$0]++' | head -n 200 | sponge ~/.cdirs
+ fi
+
+ for (( j=$start; j >= 0; j-- )); do
+ line="${lines[$j]}"
+ if [[ ! $line || ${alines[$line]} || ! -d "$line" || $line == "$PWD" || line == "$HOME" ]]; then
+ continue
+ fi
+ alines[$line]=t
+ buttondirs[${buttons[i]}]="$line"
+ printf "%s %s\n" ${buttons[i]} "$line"
+ if (( i == ${#buttons[@]} - 1 )); then
+ break
+ fi
+ i=$(( i + 1 ))
+ done
+
+ if (( i == 0 )); then
+ echo "no dirs in ~/.cdirs"
+ return 0
+ fi
+ read -r -N 1 input
+ if [[ $input != $'\n' ]]; then
+ c ${buttondirs[$input]}
+ fi
+}
+# back list
+bl() {
+ local start i j max
+ max=10
+ start=$(( ${#_dir_back[@]} - 1 ))
+
+ # cleanup possible repeating of pwd
+ if (( start >= 0 )) && [[ ${_dir_back[$start]} == "$PWD" ]]; then
+ start=$(( start - 1 ))
+ fi
+ j=1
+ if (( start >= 0 )); then
+ for (( i=$start; i >= 0 ; i-- )); do
+ printf "%s %s\n" $j ${_dir_back[i]}
+ j=$(( j + 1 ))
+ if (( j >= max )); then
+ break
+ fi
+ done
+ fi
+
+ max=10
+ start=$(( ${#_dir_forward[@]} - 1 ))
+
+ # cleanup possible repeating of pwd
+ if (( start >= 0 )) && [[ ${_dir_forward[$start]} == "$PWD" ]]; then
+ start=$(( start - 1 ))
+ fi
+ if (( start < 0 )); then
+ return 0
+ fi
+ echo --
+ j=1
+ for (( i=$start; i >= 0 ; i-- )); do
+ printf "%s %s\n" $j ${_dir_forward[i]}
+ j=$(( j + 1 ))
+ if (( j >= max )); then
+ break
+ fi
+ done
+}
+
+# pee do. run args as a command with output copied to syslog.
+#
+# Usage: pd [-t TAG] COMMAND...
+#
+# -t TAG Override the tag in the syslog. The default is COMMAND with
+# any path part is removed, eg. for /bin/cat the tag is cat.
+#
+# You can view the log via "journalctl -t TAG"
+pd() {
+ local tag ret
+ ret=0
+ tag=${1##*/}
+ case $1 in
+ -t) tag="$2"; shift 2 ;;
+ esac
+ echo "PWD=$PWD command: $*" | logger -t $tag
+ "$@" |& pee cat "logger -t $tag" || ret=$?
+ echo "exited with status=$ret" | pee cat "logger -t $tag"
+ # this avoids any err-catch
+ (( $ret == 0 )) || return $ret
+}
+ccomp time pd
+
+# jdo = journal do. Run command as transient systemd service, tailing
+# its output in the journal until it completes.
+#
+# Usage: jdo COMMAND...
+#
+# Compared to pd: commands recognize this is a non-interactive shell.
+# The service is unaffected if our ssh connection dies, no need to run
+# in screen or tmux.
+#
+# Note: The last few lines of any existing entries for a unit by that
+# name will be output first, and there will be a few second delay at the
+# start of the command, and a second or so at the end.
+#
+# Note: Functions and aliases obviously won't work, we resolve the
+# command to a file.
+#
+# Note: requires running as root.
+jdo() {
+ local cmd cmd_name jr_pid ret
+ ret=0
+ cmd="$1"
+ shift
+ if [[ $EUID != 0 ]]; then
+ echo "jdo: error: rerun as root"
+ return 1
+ fi
+ cmd_name=${cmd##*/}
+ if [[ $cmd != /* ]]; then
+ cmd=$(type -P "$cmd")
+ fi
+ # -q = quiet
+ journalctl -qn2 -f -u "$cmd_name" &
+ # Trial and error of time needed to avoid missing initial lines.
+ # .5 was not reliable. 1 was not reliable. 2 was not reliable
+ sleep 4
+ jr_pid=$!
+ systemd-run --unit "$cmd_name" --wait --collect "$cmd" "$@" || ret=$?
+ # The sleep lets the journal output its last line
+ # before the prompt comes up.
+ sleep .5
+ kill $jr_pid &>/dev/null ||:
+ unset jr_pid
+ fg &>/dev/null ||:
+ # this avoids any err-catch
+ (( $ret == 0 )) || return $ret
+}
+ccomp time jdo
+#### end fsf section
+
..() { c ..; }
...() { c ../..; }
echo "print( ($1 $(date +%z | sed -r 's/..$//;s/^(-?)0*/\1/')) % 24)"|python3
}
-declare -a _iankdirf _iankdirb
-
-
-# ## old wcd, to be deleted
-# b() {
-# # backwards
-# c -
-# }
-# # shellcheck disable=SC2032
-# f() {
-# # cd forward
-# c +
-# }
-# cl() {
-# # choose recent directory. cl = cd list
-# c =
-# }
-# # c. better cd
-# if ! type -t c &>/dev/null; then
-# if type -p wcd &>/dev/null; then
-# if [[ $LC_INSIDE_EMACS ]]; then
-# c() { wcd -c -z 50 -o "$@"; }
-# else
-# # lets see what the fancy terminal does from time to time
-# c() { wcd -c -z 50 "$@"; }
-# fi
-# else
-# c() { cd "$@"; }
-# fi
-# fi
-
-# c. better cd.
-# keep 2 stacks, forward and back. the top of the back is $PWD
-# as long as the last directory change was due to c,b,or cl.
-c() {
- # normally, the top of dirb is our current dir. if it isn't,
- # put it on there, except we don't want to do that when we
- # just launched a shell
- if [[ $OLDPWD ]]; then
- if (( ${#_iankdirb[@]} == 0 )) || [[ ${_iankdirb[-1]} != "$PWD" ]]; then
- _iankdirb+=("$PWD")
- fi
- fi
- cd "$@"
- if (( ${#_iankdirb[@]} == 0 )) || [[ ${_iankdirb[-1]} != "$PWD" ]]; then
- _iankdirb+=("$PWD")
- fi
- echo "$PWD" >> ~/.iankdirs
-}
-ccomp cd c
-
bwm() {
s bwm-ng -T avg -d
}
-b() {
- local topb
- if (( ${#_iankdirb[@]} == 0 )); then
- echo "nothing left to go back to" >&2
- return 0
- fi
- topb="${_iankdirb[-1]}"
- if [[ $topb == "$PWD" ]] && (( ${#_iankdirb[@]} == 1 )); then
- echo "already on last back entry" >&2
- return 0
- fi
-
-
- if [[ $topb == "$PWD" ]]; then
- # add to dirf if not already there
- if (( ${#_iankdirf[@]} == 0 )) || [[ ${_iankdirf[-1]} != "$topb" ]]; then
- _iankdirf+=("$topb")
- fi
- unset "_iankdirb[-1]"
- cd "${_iankdirb[-1]}"
- else
- if (( ${#_iankdirf[@]} == 0 )) || [[ ${_iankdirf[-1]} != "$PWD" ]]; then
- _iankdirf+=("$PWD")
- fi
- cd "$topb"
- fi
-
- # give us a peek at what is next in the list
- # if (( ${#_iankdirb[@]} >= 2 )); then
- # printf "%s\n" "${_iankdirb[-2]}"
- # fi
-}
-
-f() {
- local topf
- if (( ${#_iankdirf[@]} == 0 )); then
- echo "no forward dir left" >&2
- return 0
- fi
- topf="${_iankdirf[-1]}"
- unset "_iankdirf[-1]"
- c "$topf"
-
- # give us a peek at what is next in the list
- # if (( ${#_iankdirf[@]} )); then
- # printf "%s\n" "${_iankdirf[-1]}"
- # fi
-}
-
-# a b c (d)
-## back
-# a b (c)
-# d
-#back
-#a (b)
-#d c
-#back
-#(a)
-#d c b
-#forward
-#a (b)
-#d c
-#
-# a b c
-## back
-# a b
-# (c)
-## forward
-
-cl() {
- local i line input start tmpfile
- local -A buttondirs alines
- local -a buttons dirs lines
- buttons=( {a..z} {2..9} )
- if [[ ! -s ~/.iankdirs ]]; then
- echo nothing in ~/.iankdirs
- return 0
- fi
-
- i=0
-
- # note, alternate approach like this, made the following read fail
- # done < <(tac ~/.iankdirs | awk '!seen[$0]++')
- # bash: read: read error: 0: Input/output error
- # which went away by adding a sleep 1 after it.
-
- mapfile -t lines <~/.iankdirs
- start=$(( ${#lines[@]} - 1 ))
-
- # we have ~33 buttons as of this writing, so lets
- # prune down the history every once in a while.
- if (( start > 500 )); then
- tmpfile=$(mktemp)
- tac ~/.iankdirs | awk '!seen[$0]++' | head -n 200 >$tmpfile
- cat $tmpfile > ~/.iankdirs
- fi
-
- for (( j=$start; j >= 0; j-- )); do
- line="${lines[$j]}"
- if [[ ! $line || ${alines[$line]} || ! -d "$line" || $line == "$PWD" || line == "$HOME" ]]; then
- continue
- fi
- alines[$line]=t
- buttondirs[${buttons[i]}]="$line"
- printf "%s %s\n" ${buttons[i]} "$line"
- if (( i == ${#buttons[@]} - 1 )); then
- break
- fi
- i=$(( i + 1 ))
+# for running in a fai rescue
+kdrescue() {
+ d=vgata-Samsung_SSD_850_EVO_2TB_S2RLNX0J502123D
+ for f in $d vgata-Samsung_SSD_870_QVO_8TB_S5VUNG0N900656V; do
+ cryptsetup luksOpen --key-file /p /dev/$f/root crypt-$f-root
+ cryptsetup luksOpen --key-file /p /dev/$f/o crypt-$f-o
done
-
- if (( i == 0 )); then
- echo "no dirs in ~/.iankdirs"
- return 0
- fi
- read -r -N 1 input
- if [[ $input != $'\n' ]]; then
- c ${buttondirs[$input]}
- fi
+ mount -o subvol=root_trisquelaramo /dev/mapper/crypt-$d-root /mnt
+ mount -o subvol=a /dev/mapper/crypt-$d-root /mnt/a
+ mount -o subvol=o /dev/mapper/crypt-$d-o /mnt/o
+ mount -o subvol=boot_trisquelaramo /dev/sda2 /mnt/boot
+ cd /mnt
+ chrbind
}
-bl() {
- local start i j max
- max=10
- start=$(( ${#_iankdirb[@]} - 1 ))
- # cleanup possible repeating of pwd
- if (( start >= 0 )) && [[ ${_iankdirb[$start]} == "$PWD" ]]; then
- start=$(( start - 1 ))
- fi
- j=1
- if (( start >= 0 )); then
- for (( i=$start; i >= 0 ; i-- )); do
- printf "%s %s\n" $j ${_iankdirb[i]}
- j=$(( j + 1 ))
- if (( j >= max )); then
- break
- fi
- done
- fi
-
- max=10
-
- start=$(( ${#_iankdirf[@]} - 1 ))
-
- # cleanup possible repeating of pwd
- if (( start >= 0 )) && [[ ${_iankdirf[$start]} == "$PWD" ]]; then
- start=$(( start - 1 ))
- fi
- if (( start < 0 )); then
- return 0
- fi
- echo --
- j=1
- for (( i=$start; i >= 0 ; i-- )); do
- printf "%s %s\n" $j ${_iankdirf[i]}
- j=$(( j + 1 ))
- if (( j >= max )); then
- break
- fi
- done
-}
# On first use, you input username/pass and it gets an oath token so you dont have to repeat
# it\'s at ~/.config/hub
hub() {
- local up uptar updir p
- p=/github/hub/releases/
- up=https://github.com/$(curl -s https://github.com$p| grep -o $p'download/[^/]*/hub-linux-amd64[^"]*' | head -n1)
+ local up uptar updir p v
+ # example https://github.com/github/hub/releases/download/v2.14.2/hub-linux-amd64-2.14.2.tgz
+ up=$(wget -q -O- https://api.github.com/repos/github/hub/releases/latest | jq -r .assets[].browser_download_url | grep linux-amd64)
+ re='[[:space:]]'
+ if [[ ! $up || $up == $re ]]; then
+ echo "failed to get good update url. got: $up"
+ fi
uptar=${up##*/}
updir=${uptar%.tgz}
if [[ ! -e /a/opt/$updir ]]; then
i() { git "$@"; }
ccomp git i
+# git status:
+# cvs -qn update
+
+# git checkout FILE
+# cvs update -C FILE
+
+# git pull
+# cvs up[date]
+
+# potentially useful command translation
+# https://fling.seas.upenn.edu/~giesen/dynamic/wordpress/equivalent-commands-for-git-svn-and-cvs/
+
+# importing cvs repo into git using git-cvs package:
+# /f/www $ /usr/lib/git-core/git-cvsimport -C /f/www-git
+
ic() {
# fast commit all
git commit -am "$*"
grep -Il "" "$@" &>/dev/null
}
+pst() {
+ pstree -apnA
+}
+
jtail() {
journalctl -n 10000 -f "$@"
}
journalctl -u exim4 _SYSTEMD_INVOCATION_ID=$(systemctl show -p InvocationID --value $1)
}
+
+
l() {
if [[ $PWD == /[iap] ]]; then
command ls -A --color=auto -I lost+found "$@"
ngreset
}
+
+ping() { command ping -O "$@"; }
p8() { ping "$@" 8.8.8.8; }
p6() { ping6 "$@" 2001:4860:4860::8888; }
scp() {
rsync --inplace "$@"
}
+ccomp rsync scp
randport() {
# available high ports are 1024-65535,
# rl without preserving modification time.
rsync -ahvic --delete --no-t "$@"
}
-rsu() { # [OPTS] HOST PATH
- # eg. rlu -opts frodo /testpath
+# [RSYNC_OPTS] HOST PATH
+rsu() {
+ # eg. rsu -opts frodo /testpath
# relative paths will expanded with readlink -f.
opts=("${@:1:$#-2}") # 1 to last -2
path="${*:$#}" # last
if [[ $path == .* ]]; then
path=$(readlink -f $path)
fi
- # rync here uses checksum instead of time so we dont mess with
- # unison relying on time as much. g is for group, same reason
- # to keep up with unison.
- m s rsync -rlpchviog --relative "${opts[@]}" "$path" "root@$host:/";
+ m rsync -ahvi --relative --no-implied-dirs "${opts[@]}" "$path" "root@$host:/";
}
ccomp rsync rsd rsa rst rsu
ssh fencepost head -n 300 /gd/gnuorg/EventAndTravelInfo/rms-current-trips.txt | less
}
+urun () {
+ umask $1
+ shift
+ "$@"
+}
sudo () {
command sudo "$@" || return $?
DID_SUDO=true
local SUDOD="$PWD"
sudo -i bash -c "$@"
}
-ccomp sudo s sb
+# secret sudo
+se() { s urun 0077 "$@"; }
+ccomp sudo s sb se
safe_rename() { # warn and dont rename if file exists.
# mv -n exists, but it\'s silent
history -a # save history
fi
- # assigned in brc2
- # shellcheck disable=SC1303
- if [[ $jr_pid ]]; then
- if [[ -e /proc/$jr_pid ]]; then
- kill $jr_pid
- fi
- unset jr_pid
- fi
-
case $return in
0) ps_color="$term_purple"
ps_char='\$'
}
aw() {
pushd /a/work/ans >/dev/null
- time ansible-playbook -v -i inventory adhoc.yml "$@"
+ time ansible-playbook -i inventory adhoc.yml "$@"
popd >/dev/null
}
ad() {
install-my-scripts
# todo: consider changing this to srun and having the args come
# from a file like /etc/default/btrbk, like is done in exim
- s jrun btrbk-run "$@"
+ s jdo btrbk-run "$@"
if $active; then
if (( ret )); then
echo bbk: WARNING: btrbk.timer not restarted due to failure
ngreset
}
-# duplicated somewhat below.
-jrun() { # journal run. run args, log to journal, tail and grep the journal.
- # Note, an alternative without systemd would be something like ts.
- # Note, I tried using systemd-cat, but this seems obviously better,
- # and that seemed to have a problem exiting during a systemctl daemon-reload
- local cmd_name jr_pid s
+scr() {
+ screen -RD "$@"
+}
+
+
+# version of jdo for my non-root user
+jdo() {
+ # comparison of alternative logging methods:
+ #
+ # systemd-run command (what this function does)
+ #
+ # If there is a user prompt, the program will detect that it is not
+ # connected to a terminal and act in a non-interactive way, skipping
+ # the prompt. This has the benefit that you know exactly how the
+ # program will act if you want to move it into a service that runs
+ # automatically.
+ #
+ # If run with sudo and command is a shell script which does a sleep,
+ # it can (sometimes?) output some extra whitespace in front of
+ # messages, more for each subsequent message. This can be avoided by
+ # becoming root first.
+ #
+ # It logs the command's pid and exit code, which is nice.
+ #
+ #
+ ### command |& ts | tee file.log
+ #
+ # If there is a user prompt, like "read -p prompt var", it will hang
+ # without outputting the prompt.
+ #
+ # I've had a few times where ts had an error and I wasn't totally sure
+ # if it was really the command or ts having the problem.
+ #
+ # Sometimes some output will get hidden until you hit enter.
+ #
+ #
+ ### command |& pee cat logger
+ #
+ # This seems to work. I need to test more.
+ #
+ #
+ ### command |& logger -s
+ #
+ # User prompts get confusingly prefixed to earlier output, and all log
+ # entries get prefixed with annoying priority level.
+ #
+ #
+ ### systemd-cat
+ #
+ # Had a few problems. One major one is that it exited in the middle of
+ # a command on systemctl daemon-reload
+ #
+ # Related commands which can log a whole session: script, sudo, screen
+ local cmd cmd_name jr_pid ret
ret=0
- cmd_name=${1##*/}
- cmd=$1
+ cmd="$1"
+ shift
+ cmd_name=${cmd##*/}
if [[ $cmd != /* ]]; then
- cmd=$(which $1)
+ cmd=$(type -P "$cmd")
fi
+ # -q = quiet
journalctl -qn2 -f -u "$cmd_name" &
- # Guess of time needed to avoid missing initial lines.
+ # Trial and error of time needed to avoid missing initial lines.
# .5 was not reliable. 1 was not reliable. 2 was not reliable
sleep 4
- # We kill this in prompt-command for the case that we ctrl-c the
- # systemd-cat. i dont know any way to trap ctrl-c and still run the
- # normal action for it. There might be a way, unsure.
jr_pid=$!
# note, we could have a version that does system --user, but if for example
# it does sudo ssh, that will leave a process around that we can't kill
# and it will leave the unit hanging around in a failed state needing manual
# killing of the process.
- m s systemd-run --uid $(id -u) --gid $(id -g) \
+ s systemd-run --uid $(id -u) --gid $(id -g) \
-E SSH_AUTH_SOCK=/run/openssh_agent \
- --unit "$cmd_name" --wait --collect "$cmd" "${@:2}" || ret=$?
- # This justs lets the journal output its last line
+ --unit "$cmd_name" --wait --collect "$cmd" "$@" || ret=$?
+ # The sleep lets the journal output its last line
# before the prompt comes up.
sleep .5
kill $jr_pid &>/dev/null ||:
unset jr_pid
fg &>/dev/null ||:
+ # this avoids any err-catch
+ (( $ret == 0 )) || return $ret
}
+
# service run, and watch the output
srun() {
local unit
s ssh-add /root/.ssh/home
fi
install-my-scripts
- s jrun switch-mail-host "$@"
+ s jdo switch-mail-host "$@"
return $ret
}
sh2() { # switch host2
s ssh-add /root/.ssh/home
fi
install-my-scripts
- s jrun switch-host2 "$@"
+ s jdo switch-host2 "$@"
return $ret
}
ssh root@iankelling.org "cd $d; find . -mtime -60 -type f -exec grep '\<iank.*' {} +" | sed -r 's,^..([^/]*)/(.{11})(.{5})(.{8}).,\2\4 \1,' | sort
}
+# usage: debvm DEBIAN_VERSION RAM_MB
+debvm() {
+ local ver ram fname src
+ ver=$1
+ ram=${2:-2024}
+ # * is because it might have -backports in the name
+ fname=debian-$ver-*nocloud-$(dpkg --print-architecture).qcow2
+ src=/a/opt/roms/$fname
+ if [[ ! -f $src ]]; then
+ echo debvm: not found $src, download from eg: https://cloud.debian.org/images/cloud/buster/latest/
+ return 1
+ fi
+ cp -a $src /t
+ # note, in fai-revm we do this: not sure why, maybe because of br device
+ # --graphics spice,listen=0.0.0.0
+ m s virt-install --osinfo debian11 --rng /dev/urandom -n deb${ver}tmp --import -r $ram --vcpus 2 --disk /t/$fname --graphics spice
+ # note: to ssh into this machine will require host key generation: ssh-keygen -A
+
+ # random: for cvs2git on gnu www, use debian 10. I could use trisquel,
+ # but happen to want to try out the debian cloud images. the upstream
+ # requires python2 and hasn't really changed since the version in d10.
+ #
+ # apt install cvs2git cvs
+ # # 7G was not enough
+ # mount -o mode=1777,nosuid,nodev,size=34G -t tmpfs tmpfs /tmp
+ # cvs2git --encoding utf_8 --fallback-encoding ascii --dumpfile=dump www-rsync/www |& tee /tmp/l
+ ## www-rsync is an rsynced copy of the cvsfrom savannah
+}
+
mygajim() {
local time time_sec time_pretty days
days=${1:-16}
}
+# very useful, copy directory structure 3 deep. add remove /*/ to change level
+# rsync -aivh --exclude '/*/*/*/' -f"+ */" -f"- *" SRC DEST
+
+
# * stuff that makes sense to be at the end
if [[ "$SUDOD" ]]; then
# allow failure, for example if we are sudoing into a user with diffferent/lesser permissions.
# targets, plus any given on the command line.
-amy=false
+
+kd_spread=false
# set default targets
if [[ ! -v targets && ! $source ]]; then
- if [[ $HOSTNAME != "$MAIL_HOST" ]] && $cron ; then
- echo "MAIL_HOST=$MAIL_HOST, nothing to do"
- mexit 0
- else
- amy=true
+ if $cron; then
+ if [[ $HOSTNAME != "$MAIL_HOST" ]]; then
+ if [[ $HOSTNAME == kd && $MAIL_HOST = x2 ]]; then
+ kd_spread=true
+ else
+ echo "MAIL_HOST=$MAIL_HOST, nothing to do"
+ mexit 0
+ fi
+ fi
fi
+ # x2 at home atm
+ kd_spread=false
+
at_work=false
# todo, fix this up once frodo is back
# targets=(frodo.b8.nz)
case $HOSTNAME in
- x2|kw)
+ kw)
at_work=true
;;&
x2|x3|sy|bo)
home=i.b8.nz
fi
else
- home=b8.nz
+ if ping -q -c1 -w1 b8.nz &>/dev/null; then
+ home=b8.nz
+ else
+ home=i.b8.nz
+ fi
fi
;;&
x2)
fi
;;
kd)
- if ping -q -c1 -w1 x2.office.fsf.org &>/dev/null; then
- targets+=(x2.office.fsf.org)
- else
- targets+=(x2wg.b8.nz)
+ if ! $kd_spread; then
+ if ping -q -c1 -w1 x2.office.fsf.org &>/dev/null; then
+ targets+=(x2.office.fsf.org)
+ else
+ targets+=(x2wg.b8.nz)
+ fi
fi
if ping -q -c1 -w1 sy.b8.nz &>/dev/null; then
targets+=(sy.b8.nz)
transaction_syslog local7
# trying this out
-stream_compress zstd
+#stream_compress zstd
# so we only run one at a time
lockfile /var/lock/btrbk.lock
fi
done
-# if $amy; then
-# # to manually backup amy,
-# # bbk -e -s amy -m root_ubuntubionic
-# cat >>/etc/btrbk.conf <<'EOF'
-# volume ssh://amy/mnt/root
-# subvolume root_ubuntubionic
-# target send-receive /mnt/root/btrbk
-# EOF
-# fi
-
# todo: umount first to ensure we don't have any errors
# todo: do some kill fuser stuff to make umount more reliable
+++ /dev/null
-/a/f/ans/roles/btrfs/files/btrfsmaint
\ No newline at end of file
--- /dev/null
+#!/bin/bash
+
+
+[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
+
+f=/usr/local/lib/err;test -r $f || { echo "error: $0 no $f" >&2;exit 1;}; . $f
+
+# inspired from
+# https://github.com/kdave/btrfsmaintenance
+
+if [[ $INVOCATION_ID ]]; then
+ err-cleanup() {
+ exim -odf -i root <<EOF
+From: root@$(hostname -f)
+To: root@$(hostname -f)
+Subject: btrfsmaint automatically exited on command error
+
+journalctl -u btrfsmaint -n 50:
+$(journalctl -u btrfsmaint -n 50)
+EOF
+ }
+fi
+
+dusage="5 10"
+musage="5"
+
+e() {
+ echo "btrfsmaint: $*"
+ if ! $dryrun; then
+ "$@"
+ fi
+}
+
+check-idle() {
+ type -p xprintidle &>/dev/null || return 0
+ export DISPLAY=:0
+ # a hours, a movie could run that long.
+ idle_limit=$((1000 * 60 * 60 * 2))
+ idle_time=$idle_limit
+ while read -r user; do
+ new_idle_time=$(sudo -u $user xprintidle 2>/dev/null) ||:
+ if [[ $new_idle_time && $new_idle_time -lt $idle_time ]]; then
+ idle_time=$new_idle_time
+ fi
+ done < <(users | tr " " "\n" | sort -u)
+ if (( idle_time < idle_limit )); then
+ idle=false
+ else
+ idle=true
+ fi
+}
+
+usage() {
+ cat <<EOF
+Usage: ${0##*/} [OPTIONS]
+Do btrfs maintence or stop if we have X and xprintidle shows a user
+
+Normally, no options are needed.
+
+--check Only check if an existing maintence should be cancelled due to
+ nonidle user and run in a loop every 20 seconds for 10
+ minutes.
+
+--dryrun Just print out what we would do.
+
+--force Run regardless of user idle status on all disks and do scrub
+ regardless of when it was last run.
+--no-stats Avoid checking error statistics. Use this to avoid a rare race
+ condition when running --check concurrently with normal run.
+
+
+-h|--help Show help
+
+Note: Uses util-linux getopt option parsing: spaces between args and
+options, short options can be combined, options before args.
+EOF
+ exit $1
+}
+
+##### begin command line parsing ########
+
+# ensure we can handle args with spaces or empty.
+ret=0; getopt -T || ret=$?
+[[ $ret == 4 ]] || { echo "Install util-linux for enhanced getopt" >&2; exit 1; }
+
+check=false
+dryrun=false
+force=false
+stats=true
+
+temp=$(getopt -l help,check,dryrun,force,no-stats h "$@") || usage 1
+eval set -- "$temp"
+while true; do
+ case $1 in
+ --check) check=true ;;
+ --dryrun) dryrun=true ;;
+ --force) force=true ;;
+ --no-stats) stats=false ;;
+ -h|--help) usage ;;
+ --) shift; break ;;
+ *) echo "$0: unexpected args: $*" >&2 ; usage 1 ;;
+ esac
+ shift
+done
+readonly check dryrun force stats
+##### end command line parsing ########
+
+
+main() {
+ idle=true
+ if ! $force; then
+ check-idle
+ if ! $check; then
+ min=0
+ max_min=300
+ # When the cron kicks in, we may not be idle (physically sleeping) yet, so
+ # wait.
+ while ! $idle && (( min < max_min )); do
+ min=$(( min + 1 ))
+ sleep 60
+ check-idle
+ done
+ # If we've waited a really long time for idle, just give up.
+ if (( min == max_min )); then
+ return
+ fi
+ fi
+ fi
+
+
+ fnd="findmnt --types btrfs --noheading"
+ for x in $($fnd --output "SOURCE" --nofsroot | sort -u); do
+ mnt=$($fnd --output "TARGET" --first-only --source $x)
+ [[ $mnt ]] || continue
+
+ #### begin look for diff in stats, eg: increasing error count ####
+ if $stats; then
+ tmp=$(mktemp)
+ # ${mnt%/} so that if mnt is / we avoid making a buggy looking path
+ stats_path=${mnt%/}/btrfs-dev-stats
+ if [[ ! -e $stats_path ]]; then
+ btrfs dev stats -c $mnt >$stats_path ||: # populate initial reading
+ elif ! btrfs dev stats -c $mnt >$tmp; then
+ if ! diff -q $stats_path $tmp; then
+ mv $stats_path $stats_path.1
+ cat $tmp >$stats_path
+ diff=$(diff -u $stats_path $tmp 2>&1 ||:)
+ printf "diff of: btrfs dev stats -c %s\n%s\n" "$mnt" "$diff"
+ exim -odf -i root <<EOF
+From: root@$(hostname -f)
+To: root@$(hostname -f)
+Subject: btrfsmaint: device stats changed for $mnt
+
+diff of: btrfs dev stats -c $mnt
+$diff
+EOF
+ fi
+ fi
+ rm -f $tmp
+ fi
+ #### end look for diff in stats, eg: increasing error count ####
+
+ if $check; then
+ if ! $idle; then
+ if $dryrun; then
+ echo "$0: not idle. if this wasnt a dry run, btrfs scrub cancel $mnt"
+ else
+ btrfs scrub cancel $mnt &>/dev/null ||:
+ fi
+ fi
+ continue
+ fi
+
+ # for comparing before and after balance.
+ # the log is already fairly verbose, so commented.
+ # e btrfs filesystem df $mnt
+ # e df -H $mnt
+ if btrfs filesystem df $mnt | grep -q "Data+Metadata"; then
+ for usage in $dusage; do
+ e ionice -c 3 btrfs balance start -dusage=$usage -musage=$usage $mnt
+ done
+ else
+ e ionice -c 3 btrfs balance start -dusage=0 $mnt
+ for usage in $dusage; do
+ e ionice -c 3 btrfs balance start -dusage=$usage $mnt
+ done
+ e ionice -c 3 btrfs balance start -musage=0 $mnt
+ for usage in $musage; do
+ e ionice -c 3 btrfs balance start -musage=$usage $mnt
+ done
+ fi
+ date=
+ scrub_status=$(btrfs scrub status $mnt)
+ if printf "%s\n" "$scrub_status" | grep -i '^status:[[:space:]]*finished$' &>/dev/null; then
+ date=$(printf "%s\n" "$scrub_status" | sed -rn 's/^Scrub started:[[:space:]]*(.*)/\1/p')
+ fi
+ if [[ ! $date ]]; then
+ # output from older versions, at least btrfs v4.15.1
+ date=$(
+ printf "%s\n" "$scrub_status" | \
+ sed -rn 's/^\s*scrub started at (.*) and finished.*/\1/p'
+ )
+ fi
+ if ! $force && [[ $date ]]; then
+ if $dryrun; then
+ echo "$0: last scrub finish for $mnt: $date"
+ fi
+ date=$(date --date="$date" +%s)
+ # if date is sooner than 60 days ago
+ # the wiki recommends 30 days or so, but
+ # I'm going with 60 days.
+ if (( date > EPOCHSECONDS - 60*60*24*60 )); then
+ if $dryrun; then
+ echo "$0: skiping scrub of $mnt, last was $(( (EPOCHSECONDS - date) / 60/60/24 )) days ago, < 30 days"
+ fi
+ continue
+ fi
+ fi
+ # btrfsmaintenance does -c 2 -n 4, but I want lowest pri.
+ e btrfs scrub start -Bd -c 3 $mnt
+
+ # We normally only do one disk since this is meant to be run in
+ # downtime and if we try to do all disks, we invariably end up doing
+ # a scrub after downtime. So, just do one disk per day.
+ if ! $force; then
+ return 0
+ fi
+ done
+}
+
+loop-main() {
+ while true; do
+ main
+ sleep 60
+ done
+}
+
+if $check; then
+ loop-main
+else
+ main
+fi
--- /dev/null
+#!/bin/bash
+
+if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
+source /a/bin/errhandle/err
+
+source /a/bin/bash_unpublished/source-state
+if [[ $HOSTNAME != "$MAIL_HOST" ]]; then
+ exit 0
+fi
+
+# i had a phone which deleted all my contacts in radicale, but kept them
+# locally. then the phone died months later, and i had no backup of
+# recent contacts. This checks that those files didnt get deleted or
+# zerod out, by picking an amount that we dont expect to go below
+# anytime soon as of 2022.
+
+count=$(find /o/radicale/collections -type f | grep -v cache | wc -l)
+
+if (( count < 220 )); then
+ echo "unexpected file count=$count < 220"
+fi
+
+size=$(du -s /o/radicale | awk '{print $1}')
+
+if (( size < 2000 )); then
+ echo "unexpected kb size=$size < 2000"
+fi
#### begin special extra stuff ####
install -d -m700 ~/gpg-agent-socket
+ if [[ -e /etc/bitcoin ]] && getent group bitcoin &>/dev/null; then
+ s chown bitcoin:bitcoin /etc/bitcoin
+ fi
+
f=/var/lib/bind
if [[ -e $f ]]; then
# reset to the original permissions.
########### misc stuff
+# pressing tab after sdf here:
+# scp sdfbash: set +o noglob: command not found
+# in t11, bash 5.1.16. this fixes it.
+sudo sed -ri 's/([[:space:]]*)(\$reset)$/\1set +o noglob #$reset/' /usr/share/bash-completion/bash_completion
+
rm -fv /home/iank/.mpv/watch_later
rm -rf /home/iank/.mpv
hash -r
fi
+# notes about barrier
+# run barrier, do the gui config,
+# setup the 2 screens, using hostnames for the new screen.
+# save the server config
+# $HOME/.local/share/barrier/.barrier.conf
+# per the man page.
+#
+# ssl errors, resolved via advice here: https://github.com/debauchee/barrier/issues/231
+# BARRIER_SSL_PATH=~/.local/share/barrier/SSL/
+# mkdir -p "${BARRIER_SSL_PATH}"
+# openssl req -x509 -nodes -days 365 -subj /CN=Barrier -newkey rsa:4096 -keyout ${BARRIER_SSL_PATH}/Barrier.pem -out ${BARRIER_SSL_PATH}/Barrier.pem
+# ran on both machines.
+# When pressing start in the gui, the cli options used are printed to the console,
+# they are useful. So on server, just run barriers, client run barrierc SERVER_IP
### begin timetrap setup
if mountpoint /p &>/dev/null; then
### begin nagios ###
-pi nagios4
-s rm -fv /etc/apache2/conf-enabled/nagios4-cgi.conf
+case $HOSTNAME in
+ kd)
+ pi nagios4
+ s rm -fv /etc/apache2/conf-enabled/nagios4-cgi.conf
-# to add a password for admin:
-# htdigest /etc/nagios4/htdigest.users Nagios4 iank
-# now using the same pass as prometheus
+ # to add a password for admin:
+ # htdigest /etc/nagios4/htdigest.users Nagios4 iank
+ # now using the same pass as prometheus
-# nagstamon auth settings, set to digest instead of basic.
+ # nagstamon auth settings, set to digest instead of basic.
-web-conf -p 3005 - apache2 i.b8.nz <<'EOF'
+ web-conf -p 3005 - apache2 i.b8.nz <<'EOF'
# adapted from /etc/apache2/conf-enabled/nagios4-cgi.conf
ScriptAlias /cgi-bin/nagios4 /usr/lib/cgi-bin/nagios4
Options +ExecCGI
</Directory>
EOF
-
+ ;;
+esac
# when you alter a service through the web, it changes vars in /var/lib/nagios4/status.dat. for example:
# notifications_enabled=1
### end nagios ###
+### begin bitcoin ###
+
+case $HOSTNAME in
+ sy)
+ f=$dir/bitcoin.conf
+ sudo install -m 0755 -o root -g root -t /usr/bin /a/opt/bitcoin-23.0/bin/*
+ sgo bitcoind
+ sudo usermod -a -G bitcoin iank
+ # todo, link in wallet. see
+ # /a/bin/ds/disabled/bitcoin
+ ;;
+esac
+
+### end bitcoin
+
end_msg <<'EOF'
In mate settings settings, change scrolling to two-finger,
# If theres any logged errors we didnt handle in 4 days, maybe we accidentally missed them,
# so report if we did
4 9 * * 5 root /a/bin/ds/check-stale-alerts
+4 10 * * 5 root /a/bin/ds/check-radicale
4 15 * * 5 iank /a/bin/ds/mailclean
14 * * * * root /a/bin/ds/bk-backup |& log-once -24 bk-backup
0 7 * * * iank failmail myupgrade-iank
-HandleLidSwitch=
+[Login]
+HandleLidSwitch=ignore
--- /dev/null
+# iank: copied from /a/opt/bitcoin/contrib/init/bitcoind.service
+# for sources as of 2022-11-14
+
+# It is not recommended to modify this file in-place, because it will
+# be overwritten during package upgrades. If you want to add further
+# options or overwrite existing ones then use
+# $ systemctl edit bitcoind.service
+# See "man systemd.service" for details.
+
+# Note that almost all daemon options could be specified in
+# /etc/bitcoin/bitcoin.conf, but keep in mind those explicitly
+# specified as arguments in ExecStart= will override those in the
+# config file.
+
+[Unit]
+Description=Bitcoin daemon
+Documentation=https://github.com/bitcoin/bitcoin/blob/master/doc/init.md
+
+# https://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/
+After=network-online.target
+Wants=network-online.target
+
+[Service]
+ExecStart=/usr/bin/bitcoind -daemonwait \
+ -pid=/run/bitcoind/bitcoind.pid \
+ -conf=/etc/bitcoin/bitcoin.conf \
+ -datadir=/var/lib/bitcoind
+
+# Make sure the config directory is readable by the service user
+PermissionsStartOnly=true
+ExecStartPre=/bin/chgrp bitcoin /etc/bitcoin
+
+# Process management
+####################
+
+Type=forking
+PIDFile=/run/bitcoind/bitcoind.pid
+Restart=on-failure
+TimeoutStartSec=infinity
+TimeoutStopSec=600
+
+# Directory creation and permissions
+####################################
+
+# Run as bitcoin:bitcoin
+User=bitcoin
+Group=bitcoin
+
+# /run/bitcoind
+RuntimeDirectory=bitcoind
+RuntimeDirectoryMode=0710
+
+# /etc/bitcoin
+ConfigurationDirectory=bitcoin
+ConfigurationDirectoryMode=0710
+
+# /var/lib/bitcoind
+StateDirectory=bitcoind
+StateDirectoryMode=0710
+
+# Hardening measures
+####################
+
+# Provide a private /tmp and /var/tmp.
+PrivateTmp=true
+
+# Mount /usr, /boot/ and /etc read-only for the process.
+ProtectSystem=full
+
+# Deny access to /home, /root and /run/user
+ProtectHome=true
+
+# Disallow the process and all of its children to gain
+# new privileges through execve().
+NoNewPrivileges=true
+
+# Use a new /dev namespace only populated with API pseudo devices
+# such as /dev/null, /dev/zero and /dev/random.
+PrivateDevices=true
+
+# Deny the creation of writable and executable memory mappings.
+MemoryDenyWriteExecute=true
+
+[Install]
+WantedBy=multi-user.target
[Service]
Type=simple
+# note, btrfs maint is hardlinked into fsf ansible repo
ExecStart=/usr/local/bin/btrfsmaint --no-stats
IOSchedulingClass=idle
CPUSchedulingPolicy=idle
[Service]
Type=simple
-ExecStart=/usr/local/bin/btrfsmaint check
+ExecStart=/usr/local/bin/btrfsmaint --check
Restart=always
RestartSec=600
[Service]
TimeoutStartSec=20
+TimeoutStopSec=7
--- /dev/null
+#!/bin/bash
+[[ $EUID == 0 ]] || exec sudo "${BASH_SOURCE[0]}"
+
+systemctl stop bitcoind
set $mod Mod4
bindsym $mod+2 exec "pavucontrol"
-bindsym $mod+3 exec "abroswer"
-#bindsym $mod+3 exec "abrowser -no-remote -P sfw"
+# ian: dunno why but i needed this version at some point, then
+# it mysteriously stopped working, but works on the cli. 2022-12
+#bindsym $mod+3 exec "abroswer"
+bindsym $mod+3 exec "abrowser -no-remote -P sfw"
bindsym $mod+4 exec "abrowser -no-remote -P firefox-main-profile"
bindsym $mod+5 exec "/usr/local/bin/start-tor-browser"
bindsym $mod+6 exec "/a/bin/redshift.sh"
bindsym $mod+r exec "/a/bin/ds/xl"
# todo, in newer i3, make this toggle split tabbed
bindsym $mod+t layout toggle split
-bindsym $mod+Shift+t move workspace to output right
+bindsym $mod+Shift+t move workspace to output up
+#bindsym $mod+Shift+t move workspace to output right
bindsym $mod+g layout tabbed
# Use Mouse+$mod to drag floating windows to their wanted position
# slow down ploopy trackball, until we recompile firmware
id=$(xinput list | grep -F 'Ploopy Corporation Trackball Mouse' | sed -rn 's/.*[[:space:]]id=([^[:space:]]*).*/\1/p' ||:)
if [[ $id ]]; then
- xinput --set-prop 'libinput Accel Speed' -0.9
+ xinput --set-prop $id 'libinput Accel Speed' -0.9
fi
set +x
0 17 * * 1,2,3,4,5 root failmail wrt-setup -z
# weekends
-0 6 * * 6,7 root failmail wrt-setup -y
-0 17 * * 6,7 root failmail wrt-setup -z
+#0 6 * * 6,7 root failmail wrt-setup -y
+#0 17 * * 6,7 root failmail wrt-setup -z
# saturday morning
# old
# Copyright (C) 2019 Ian Kelling
# SPDX-License-Identifier: AGPL-3.0-or-later
+# perusing through /el/mainlog without test messages:
+# &!testignore|jtuttle|
+#
+#&! testignore|jtuttle|eximbackup|/usr/sbin/exim4 -bpu
+
# todo: check new macro DKIM_TIMESTAMPS
# todo: check if REMOTE_SMTP_INTERFACE or REMOTE_SMTP_TRANSPORTS_HEADERS_REMOVE can simplify my or fsfs config
done
}
sre() {
+ local enabled
for service; do
m systemctl restart $service
- m systemctl enable $service;
+ # Optimization for exim,
+ # is-enabled: 0m0.015s
+ # enable: 0m0.748s
+ # It is related to this message:
+ # exim4.service is not a native service, redirecting to systemd-sysv-install.
+ # Executing: /lib/systemd/systemd-sysv-install enable exim4
+ enabled=$(systemctl is-enabled $service 2>/dev/null ||:)
+ if [[ $enabled != enabled ]]; then
+ m systemctl enable $service
+ fi
done
}
mailhost() {
# enable 587 in addition to the default 25, so that
# i can send mail where port 25 is firewalled by isp
-daemon_smtp_ports = 25 : 587
+daemon_smtp_ports = 25 : 587 : 10025
# default of 25, can get stuck when catching up on mail
smtp_accept_max = 400
smtp_accept_reserve = 100
# those docs are rather old and I see a 110k spam message
# pretty quickly looking through my spam folder.
-warn
+#warn
!hosts = +iank_trusted
remove_header = X-Spam_score: X-Spam_score_int : X-Spam_bar : X-Spam_report
# # setup chgrp www-data in ./conflink
pi-nostart radicale
+ m usermod -a -G radicale iank
u /etc/systemd/system/radicale.service.d/override.conf <<EOF
[Unit]
$MAIL_HOST|bk|je)
# start spamassassin/dovecot before exim.
sre dovecot spamassassin
- # need to wait a bit before restarting exim, else I
- # get a paniclog entry like: spam acl condition: all spamd servers failed
- sleep 3
+ # Wait a bit before restarting exim, else I get a paniclog entry
+ # like: spam acl condition: all spamd servers failed. But I'm tired
+ # of waiting. I'll deal with this some other way.
+ #
+ # sleep 3
m systemctl --now enable mailclean.timer
;;&
$MAIL_HOST)
try_left=$(( try_limit - ( EPOCHSECONDS - try_start_time) ))
timeout=120 # somewhat arbitrary value
if (( try_left < 0 )); then
+ echo "mailtest-check: failed to rsync fencepost > $try_limit seconds"
break
fi
if (( try_left < timeout )); then
fi
tmpfile=$(mktemp)
declare -i unexpected=0
- declare -i missing_dnswl=0
- declare -i dnsfail=0
for folder in ${folders[@]}; do
for from in ${froms[@]}; do
+ declare -i missing_dnswl=0
+ declare -i dnsfail=0
+ declare -i unexpected=0
latest=
last_sec=0
# eggs has RCVD_IN_DNSWL_MED
keys+=(RCVD_IN_DNSWL_MED)
elif [[ $from == *@gnu.org ]]; then
- # eggs has these
- keys+=(RCVD_IN_DNSWL_MED DKIMWL_WL_HIGH)
+ # eggs has this. it used to have DKIMWL_WL_HIGH sometime in 2022
+ keys+=(RCVD_IN_DNSWL_MED)
fi
for t in ${keys[@]}; do
;;
esac
done
+ pr <<EOF
+mailtest_check_missing_dnswl{folder="$folder",from="$from"} $missing_dnswl
+mailtest_check_unexpected_spamd_results{folder="$folder",from="$from"} $unexpected
+EOF
fi # if spamdpid
fi # if $slow
EOF
done # end for from in ${froms[@]}
done # end for folder in ${folders[@]}
- if $slow; then
- pr <<EOF
-mailtest_check_missing_dnswl $missing_dnswl
-mailtest_check_unexpected_spamd_results $unexpected
-EOF
- fi
dir=/var/lib/prometheus/node-exporter
if [[ -e $dir ]]; then
fi
# R = relative, t = times, O = omit-dir-times, p = perms
er rsync -RtOp bin/{mount-latest-subvol,check-subvol-stale} lib/err "root@$rsynctg:/usr/local" || continue
- # this can hang if we have an old nfs mount
- ssh root@$tg timeout -s 9 600 /usr/local/bin/mount-latest-subvol ||:
+ # note: this can hang if we have an old nfs mount.
+ er ssh root@$tg timeout -s 9 600 /usr/local/bin/mount-latest-subvol
done
if (( $# == ${#failed_hosts[@]} )); then
artha
asciidoc
backupninja
+ barrier
bash-doc
# not using it currently and it has a dependency problem
# beets
gimp
git-doc
git-email
+ git-cvs
git-svn
gitk
glibc-doc
mpv
mumble
mupdf
+ mutt
nagstamon
namazu2
ncdu
# gnupload dependency
ncftp
+ nethogs
nginx-doc
nmap
nyancat
fi
+if [[ $HOSTNAME == "$MAIL_HOST" || $HOSTNAME == kd ]]; then
+ m systemctl --now enable btrbk.timer
+else
+ m systemctl --now disable btrbk.timer
+fi
+
+
if dpkg -s rss2email &>/dev/null; then
if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
# arbtt disabled for now
#DISPLAY=:0 arbtt-capture --sample-rate=10 &
m systemctl --now enable rss2email.timer
- # off is in mail-setup. no reason for this to be in the rss2email block.
- m systemctl --now enable btrbk.timer
else
files=(/sysd-mail-once/btrbk*)
if (( ${#files[@]} )); then
rm -f ${files[@]}
fi
- m systemctl --now disable btrbk.timer
m systemctl stop rss2email.service
m systemctl --now disable rss2email.timer
header :contains "list-id" "<emacs-erc.gnu.org>",
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" "<lilypond-devel.gnu.org>",
header :contains "list-id" "<xmonad.haskell.org>") {
if header :regex "list-id" "<([a-z_0-9-]+)[.@]" {
header :contains "list-id" "<emacs-erc.gnu.org>",
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" "<lilypond-devel.gnu.org>",
header :contains "list-id" "<xmonad.haskell.org>") {
if header :regex "list-id" "<([a-z_0-9-]+)[.@]" {
cat <<'EOF'
set -eE
if pgrep -G iank -u iank -f 'emacs --daemon' &>/dev/null; then
- bufs="$(sudo -u iank emacsclient --eval "$(cat /a/bin/ds/unsaved-buffers.el)"| sed '/^"nil"$/d;s/^"(/E: /;s/)"$//')"
+ bufs="$(sudo -u iank env XDG_RUNTIME_DIR=/run/user/1000 emacsclient --eval "$(cat /a/bin/ds/unsaved-buffers.el)"| sed '/^"nil"$/d;s/^"(/E: /;s/)"$//')"
if [[ $bufs ]]; then
echo "error: on $HOSTNAME, unsaved emacs files: $bufs" >&2
exit 1
$old_shell bash -s <<'EOF'
if pgrep -G iank -u iank -f 'emacs --daemon' &>/dev/null; then
- bufs="$(sudo -u iank emacsclient --eval "$(cat /a/bin/ds/unsaved-buffers.el)"| sed '/^"nil"$/d;s/^"(/E: /;s/)"$//')"
+ bufs="$(sudo -u iank env XDG_RUNTIME_DIR=/run/user/1000 emacsclient --eval "$(cat /a/bin/ds/unsaved-buffers.el)"| sed '/^"nil"$/d;s/^"(/E: /;s/)"$//')"
if [[ $bufs ]]; then
echo "error: on $HOSTNAME, unsaved emacs files: $bufs" >&2
exit 1
fi
if $host2_only; then
- if [[ $old_hostname != "$MAIL_HOST" ]]; then
+ if [[ $old_hostname != "$MAIL_HOST" && $old_hostname != kd ]]; then
m $old_shell systemctl --now disable btrbk.timer
fi
m $new_shell systemctl --now enable btrbk.timer
fi
wait=15
if ! $power; then
+ if systemctl -q is-active bitcoind; then
+ bitcoinoff
+ fi
wait=60
fi