From: Ian Kelling Date: Sun, 5 Apr 2020 14:30:50 +0000 (-0400) Subject: bunch of misc updates X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=eebd9873a11e2fae35caba6493dabaf68977466b;p=distro-setup bunch of misc updates --- diff --git a/.gitconfig b/.gitconfig index 839cb5f..8c769ea 100644 --- a/.gitconfig +++ b/.gitconfig @@ -5,11 +5,12 @@ email = iank@fsf.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 --decorate +lg = log --graph +lgstat = log --stat --graph --pretty=format:'%h %ad- %s [%an]' co = checkout s = status ci = commit -lol = log --graph --decorate --pretty=oneline --abbrev-commit --all +lol = log --graph --pretty=oneline --abbrev-commit --all dt = difftool [core] diff --git a/brc b/brc index 08ad406..b881920 100644 --- a/brc +++ b/brc @@ -295,6 +295,14 @@ c4() { c /var/log/exim4; } caa() { git commit --amend --no-edit -a; } +cf() { + for f; do + hr + echo "$f" + hr + cat "$f" + done +} caf() { # shellcheck disable=SC2033 find -L $1 -type f -not \( -name .svn -prune -o -name .git -prune \ @@ -493,8 +501,10 @@ eless() { } eqcat() { exiqgrep -i | while read -r i; do - exim -Mvh $i; hr; exim -Mvb $i; hr; - exigrep $i /var/log/exim4/mainlog; hr + m exim -Mvh $i + m exim -Mvb $i + hr + m exigrep $i /var/log/exim4/mainlog | cat ||: done } @@ -624,7 +634,7 @@ gdkill() { } gr() { - grep -iIP --color=auto "$@" + grep -iIP --color=auto "$@" || return $? } grr() { # grep recursive @@ -652,7 +662,10 @@ hrcat() { local f; for f; do [[ -f $f ]] || continue; hr; echo "$f"; cat "$f"; d # main command to use: # hub pull-request --no-edit # --no-edit means to use the first commit\'s message as the pull request message. -# Also, you need to use a feature branch, not master in your fork. +# If that fails, try doing +# hub pull-request --no-edit -b UPSTREAM_OWNER:branch +# where branch is usually master. it does the pr against your current branch. +# # 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() { @@ -666,6 +679,8 @@ hub() { wget -P /a/opt $up tar -C /a/opt -zxf /a/opt/$uptar rm -f /a/opt/$uptar + fi + if ! which hub &>/dev/null; then sudo /a/opt/$updir/install fi @@ -898,25 +913,29 @@ r() { } rl() { + readlink -f "$@" +} + +rsd() { # rsync, root is required to keep permissions right. # rsync --archive --human-readable --verbose --itemize-changes --checksum \(-ahvic\) \ # --no-times --delete # basically, make an exact copy, use checksums instead of file times to be more accurate rsync -ahvic --delete "$@" } -rld() { +rsa() { # like rlu, but dont delete files on the target end which # do not exist on the original end. rsync -ahvic "$@" } complete -F _rsync -o nospace rld rl rlt -rlt() { +rst() { # rl without preserving modification time. rsync -ahvic --delete --no-t "$@" } -rlu() { # [OPTS] HOST PATH +rsu() { # [OPTS] HOST PATH # eg. rlu -opts frodo /testpath # relative paths will expanded with readlink -f. opts=("${@:1:$#-2}") # 1 to last -2 @@ -971,6 +990,7 @@ safe_rename() { # warn and dont rename if file exists. sb() { # sudo bash -c # use sb instead of s is for sudo redirections, # eg. sb 'echo "ok fine" > /etc/file' + # shellcheck disable=SC2034 local SUDOD="$PWD" sudo -i bash -c "$@" } @@ -1035,13 +1055,15 @@ sgu() { sk() { + # 2029: "unescaped, this expands on the client side." yes, I know how ssh works + # 2164: "Use 'cd ... || exit' or 'cd ... || return' in case cd fails." i have automatic error handling # 2086: unquoted $var # 2046: unquoted $(cmd) # 2068: Double quote array expansions to avoid re-splitting elements. # 2119: Functions with optional args get bad warnings when none are passed. # 2033: too many false positives for thing that will never work, passing shell function to find. # i had -x as an arg, but debian testing(stretch) doesn\'t support it - shellcheck -x -e 2086,2046,2068,2119,2033 "$@" || return $? + shellcheck -x -e 2029,2164,2086,2046,2068,2119,2033 "$@" || return $? # had this before. not sure what it is 2119 } @@ -1178,6 +1200,13 @@ psnetns() { m() { printf "%s\n" "$*"; "$@"; } +uptime() { + if type -p uprecords &>/dev/null; then + uprecords -B + else + uptime + fi +} virshrm() { for x in "$@"; do virsh destroy "$x"; virsh undefine "$x"; done @@ -1274,6 +1303,8 @@ if [[ $- == *i* ]]; then history -a # save history fi + # assigned in brc2 + # shellcheck disable=SC1303 if [[ $jr_pid ]]; then if [[ -e /proc/$jr_pid ]]; then kill $jr_pid @@ -1301,7 +1332,7 @@ if [[ $- == *i* ]]; then fi # faster than sourceing the file im guessing - if [[ -e /dev/shm/iank-status ]]; then + if [[ -e /dev/shm/iank-status && ! -e /tmp/quiet-status ]]; then eval $(< /dev/shm/iank-status) fi if [[ ! $SSH_CLIENT && $MAIL_HOST != "$HOSTNAME" ]]; then @@ -1311,7 +1342,6 @@ if [[ $- == *i* ]]; then # set titlebar #echo -ne "$title_escape ${PWD/#$HOME/~} \007" - } PROMPT_COMMAND=prompt-command @@ -1326,7 +1356,7 @@ if [[ $- == *i* ]]; then # one is running, otherwise, show nothing if [[ $1 == prompt-command ]]; then set -- - fi + fi if [[ ${#BASH_ARGC[@]} == 1 ]]; then echo -ne "$_title_escape ${PWD/#$HOME/~} " printf "%s" "$*" @@ -1334,14 +1364,18 @@ if [[ $- == *i* ]]; then fi } - # for titlebar. - # condition from the screen man page i think. - # note: duplicated in tx() - if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then - trap 'settitle "$BASH_COMMAND"' DEBUG - else - trap DEBUG - fi + # this is busted. for example, this wont work: + # x=$(mktemp); cp a $x + # I havnt figured out why, bigger fish to fry. + # + # # for titlebar. + # # condition from the screen man page i think. + # # note: duplicated in tx() + # if [[ $TERM == *(screen*|xterm*|rxvt*) ]]; then + # trap 'settitle "$BASH_COMMAND"' DEBUG + # else + # trap DEBUG + # fi fi diff --git a/brc2 b/brc2 index d8a0358..eb8c06f 100644 --- a/brc2 +++ b/brc2 @@ -17,7 +17,7 @@ path-add /a/exe path-add --end ~/.local/bin path-add --ifexists --end /a/work/libremanage path-add --ifexists --end /a/opt/adt-bundle*/tools /a/opt/adt-bundle*/platform-tools -path-add --ifexists --end /a/opt/scancode-toolkit-3.0.2 +path-add --ifexists --end /a/opt/scancode-toolkit-3.10. export WCDHOME=/a @@ -109,7 +109,6 @@ EOF bbk() { # btrbk wrapper - local pid c / local active=true systemctl is-active btrbk.timer || active=false @@ -125,7 +124,7 @@ bbk() { # btrbk wrapper install-my-scripts jrun -p btrbk btrbk-run "$@" if $active; then - if (( $ret )); then + if (( ret )); then echo bbk: WARNING: btrbk.timer not restarted due to failure else ser start btrbk.timer @@ -140,26 +139,12 @@ bigclock() { xclock -digital -update 1 -face 'arial black-80:bold' } -inttrap() { - pid=$1 - # just passing on -INT doesnt work. - kill -TERM $pid - sleep .05 - if [[ ! -e /proc/$pid ]]; then - if [[ $old_int_trap ]]; then - $old_int_trap - else - trap INT - fi - fi -} - 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 doing cmd | pee "sudo systemd-cat" cat, but that # had some problems like ctrl-c didnt work or something. - local pid pattern sedscript cmd_name ended + local pattern sedscript cmd_name ret=0 case $1 in -p) @@ -178,7 +163,7 @@ jrun() { # journal run. run args, log to journal, tail and grep the journal. # normal action for it. There might be a way, unsure. jr_pid=$! systemd-cat -t "$cmd_name" "$@" || ret=$? - if (( $ret )); then + if (( ret )); then echo "jrun: ERROR: $* returned $ret" fi # This justs lets the journal output its last line @@ -197,6 +182,7 @@ sm() { return $ret } +# shellcheck disable=SC2120 lipush() { # note, i had --delete-excluded, but that deletes all files in --exclude-from on # the remote site, which doesn't make sense, so not sure why i had it. @@ -276,7 +262,7 @@ chrome() { if type -p chromium &>/dev/null; then cmd=chromium else - cd + cd / cmd="schroot -c stretch chromium" CHROMIUM_FLAGS='--enable-remote-extensions' $cmd &r fi @@ -674,13 +660,11 @@ mbenable() { local mb=$1 dst=/m/4e/$mb src=/m/md/$mb - set -x - [[ -e $src ]] || { set +x; return 1; } - mv -T $src $dst || { set +x; return 1; } - ln -s -T $dst $src - /a/exe/lnf /m/.mu ~ + [[ -e $src ]] || { echo "src:$src does not exist"; return 1; } + m mv -T $src $dst + m ln -s -T $dst $src + m /a/exe/lnf /m/.mu ~ mu index --maildir=/m/4e - set +x } mbdisable() { local mb=$1 @@ -824,7 +808,7 @@ resolvcat() { fi if systemctl is-enabled systemd-resolved &>/dev/null || [[ $(systemctl is-active systemd-resolved ||:) != inactive ]]; then hr; m ser status systemd-resolved | cat || : - hr; m systemd-resolve --status + hr; m systemd-resolve --status | cat fi } @@ -836,6 +820,9 @@ reresolv() { if [[ $(systemctl is-active dnsmasq ||:) != inactive ]]; then sudo systemctl restart dnsmasq fi + if [[ $(systemctl is-active systemd-resolved ||:) != inactive ]]; then + sudo systemctl restart systemd-resolved + fi } # only run on MAIL_HOST. simpler to keep this on one system. @@ -960,7 +947,7 @@ sl() { # inspired from https://github.com/Russell91/sshrc - local args info_date info_t type now tmp tmp2 old sshinfo cmd haveinfo dorsync info_sec + local now args remote dorsync haveinfo tmpa sshinfo tmp tmp2 type info_sec declare -a args tmpa now=$(date +%s) @@ -1164,8 +1151,7 @@ trc() { tu() { - local s dir - dir="$(dirname "$1")" + local s if [[ -e $1 && ! -w $1 || ! -w $(dirname "$1") ]]; then s=s; fi @@ -1237,28 +1223,18 @@ wtr() { curl wttr.in/boston; } xevkb() { xev -event keyboard; } -ziva() { e "toot! i love dancing. fart"; } - # * misc stuff -# from curl cheat.sh/:bash_completion -_cheatsh_complete_curl() -{ - local cur prev opts - _get_comp_words_by_ref -n : cur - - COMPREPLY=() - #cur="${COMP_WORDS[COMP_CWORD]}" - prev="${COMP_WORDS[COMP_CWORD-1]}" - opts="$(curl -s cheat.sh/:list | sed s@^@cheat.sh/@)" - - if [[ ${cur} == cheat.sh/* ]] ; then - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - __ltrim_colon_completions "$cur" - return 0 - fi +vrun() { + printf "running: %s\n" "$*" + "$@" } -complete -F _cheatsh_complete_curl curl + +f=/a/f/ansible-configs/files/common/etc/fsf-workstation-bashrc.sh +if [[ -e $f ]]; then + # shellcheck disable=SC1090 + source $f +fi @@ -1277,7 +1253,7 @@ reset-sakura() { # shellcheck disable=SC2154 setini $k $v sakura /a/c/subdir_files/.config/sakura/sakura.conf done <<'EOF' -colorset1_back rgb(33,37,39 +colorset1_back rgb(33,37,39) less_questions true audible_bell No visible_bell No @@ -1353,11 +1329,13 @@ export ARDUINO_PATH=/a/opt/arduino-1.8.9 # that should be avoided unless we really need it. path-add --end ~/.npm-global + path-add --end $HOME/.cargo/bin # taken from default changes to bashrc and bash_profile -path-add --end $HOME/.rvm/bin -path-add --end $HOME/.gem/ruby/2.3.0/bin +path-add --end --ifexists $HOME/.rvm/bin +# also had ruby bin dir, but moved that to environment.sh +# so its included in overall env export BASEFILE_DIR=/a/bin/fai-basefiles diff --git a/btrbk-run b/btrbk-run index dde230e..2a15864 100644 --- a/btrbk-run +++ b/btrbk-run @@ -14,7 +14,10 @@ # limitations under the License. -# todo: if we cancel in the middle of a btrfs send, then run again immediately, the received subvolume doesn't get a Received UUID: field, and we won't mount it. Need to figure out a solution that will fix this. +# todo: if we cancel in the middle of a btrfs send, then run again +# immediately, the received subvolume doesn't get a Received UUID: +# field, and we won't mount it. Need to figure out a solution that will +# fix this. [[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" @@ -66,7 +69,7 @@ dry_run=false # mostly for testing rate_limit=no verbose=true; verbose_arg=-v progress_arg="--progress" -incremental_strict=true +incremental_strict=false pull_reexec=false default_args_file=/etc/btrbk-run.conf @@ -91,7 +94,7 @@ while true; do ;; # only creates the config file, does not run btrbk -c) conf_only=true; shift ;; - -i) incremental_strict=false; shift ;; + -i) incremental_strict=true; shift ;; # bytes per second, suffix k m g -l) rate_limit=$2; shift 2 ;; # Comma separated mountpoints to backup. This has defaults set below. @@ -133,7 +136,8 @@ if $verbose; then fi ### end options parsing -if ! btrbk --version |& grep 0.29.0 >/dev/null; then +# note, this test succeeds if not installed +if [[ /a/opt/btrbk/btrbk -nt /usr/sbin/btrbk ]]; then cd /a/opt/btrbk m sudo make install fi @@ -176,8 +180,8 @@ if [[ ! -v targets && ! $source ]]; then tp) # kd disabled temporarily while its hot and i plan to work on it. #targets=(frodo kd) - #targets=(frodo x2.b8.nz) - targets=(frodo) + targets=(frodo x2.b8.nz) + #targets=(frodo) # might not be connected to the vpn if timeout -s 9 6 ssh kw :; then targets+=(kw) @@ -205,8 +209,8 @@ if [[ $source ]]; then fi -if [[ $mountpoints ]]; then - for mp in ${mountpoints[@]}; do # default mountpoints to sync +if [[ ${mountpoints[0]} ]]; then + for mp in ${mountpoints[@]}; do if [[ -e /nocow/btrfs-stale/$mp ]]; then die "error: $mp is stale, mount-latest-subvol first" fi @@ -229,7 +233,11 @@ else fi else if [[ $HOSTNAME == "$MAIL_HOST" ]]; then - prospective_mps+=(/o) + if [[ $HOST2 && $HOST2 != "$HOSTNAME" ]]; then + echo "skipping /o because HOST2 is not us" + else + prospective_mps+=(/o) + fi fi fi ;; @@ -268,7 +276,7 @@ done if ! $pull_reexec && [[ $source ]] && $pulla ; then tmpf=$(mktemp) scp $source:/a/bin/distro-setup/btrbk-run $tmpf - if ! diff -q $tmpf $BASH_SOURCE; then + if ! diff -q $tmpf ${BASH_SOURCE[0]}; then e "found newer version on host $source. reexecing" install -T $tmpf /usr/local/bin/btrbk-run m /usr/local/bin/btrbk-run --pull-reexec "${orig_args[@]}" @@ -294,7 +302,7 @@ if [[ $source ]]; then if ! zone=$(ssh root@$source date +%z); then die failed to ssh to root@$source fi - if [[ $zone != $local_zone ]]; then + if [[ $zone != "$local_zone" ]]; then die "error: dont confuse yourself with multiple time zones. $h has different timezone than localhost" fi @@ -318,17 +326,17 @@ else fi fi sshable+=($h) - if [[ $zone != $local_zone ]]; then + if [[ $zone != "$local_zone" ]]; then die "error: dont confuse yourself with multiple time zones. $h has different timezone than localhost" fi else sshfail+=($h) fi done - if [[ ! ${sshable[@]} ]] || { ! $cron && [[ ${sshfail[@]} ]]; }; then + if [[ ! ${sshable[*]} ]] || { ! $cron && [[ ${sshfail[*]} ]]; }; then die "failed to ssh to hosts: ${sshfail[*]}" else - if [[ ${sshfail[@]} ]]; then + if [[ ${sshfail[*]} ]]; then ret=1 e "error: failed to ssh to ${sshfail[*]} but continuing with other hosts" fi diff --git a/distro-begin b/distro-begin index 290b14d..4a071e4 100755 --- a/distro-begin +++ b/distro-begin @@ -352,7 +352,7 @@ case $(debian-codename-compat) in sudo rmmod evbug ||: # might not be loaded yet file=/etc/modprobe.d/evbug.conf line="blacklist evbug" - if [[ $(cat $file) != $line ]]; then + if [[ $(cat $file) != "$line" ]]; then sudo dd of=$file 2>/dev/null <<<"$line" sudo depmod -a sudo update-initramfs -u @@ -364,6 +364,7 @@ esac ###### link files # convenient to just do all file linking in one place sudo /a/exe/lnf -T /a/bin /b +sudo /a/exe/lnf -T /a/f /f sudo /a/exe/lnf -T /nocow/t /t if has_p; then lnf -T /p/News ~/News @@ -538,7 +539,8 @@ if has_monitor; then ###### install X - pi i3 + # no recommends due to this bug: https://trisquel.info/en/issues/26525 + pi --no-install-recommends i3 ##### install xinput case $(distro-name) in diff --git a/distro-end b/distro-end index f391912..0f8a212 100755 --- a/distro-end +++ b/distro-end @@ -1,6 +1,8 @@ #!/bin/bash # Copyright (C) 2019 Ian Kelling # SPDX-License-Identifier: AGPL-3.0-or-later + +# shellcheck source=/a/bin/ds/.bashrc export BRC=t; if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi ### setup @@ -164,7 +166,8 @@ sgo certbotmail.timer # fi -######### begin flidas pinned packages ###### +pi debootstrap +######### begin universal pinned packages ###### case $(debian-codename) in etiona|flidas) sd /etc/apt/preferences.d/etiona-buster </dev/null; then + pi ruby-dev libsqlite3-dev + gem install --user timetrap +fi + case $codename in # needed for debootstrap scripts for fai since fai requires debian flidas) @@ -1522,7 +1545,7 @@ m /a/bin/buildscripts/pithosfly # guix package --install guile # fi - +lnf -T /a/opt ~/src pi tor m /a/bin/buildscripts/tor-browser diff --git a/distro-pkgs b/distro-pkgs index ab6fa64..909caca 100755 --- a/distro-pkgs +++ b/distro-pkgs @@ -1,6 +1,7 @@ #!/bin/bash # Copyright (C) 2019 Ian Kelling # SPDX-License-Identifier: AGPL-3.0-or-later +# shellcheck source=/a/bin/ds/.bashrc if [[ -s ~/.bashrc ]];then . ~/.bashrc;fi @@ -33,14 +34,10 @@ isdeb() { return 1 } -bool_opt=false # default -long_opt=foo # default -temp=$(getopt -l help,long-opt: hso: "$@") || usage 1 +temp=$(getopt -l help h "$@") || usage 1 eval set -- "$temp" while true; do case $1 in - -s) bool_opt=true; shift ;; - -o|--long-opt) long_opt="$2"; shift 2 ;; -h|--help) usage ;; --) shift; break ;; *) echo "$0: Internal error! unexpected args: $*" ; exit 1 ;; @@ -130,12 +127,10 @@ case $distro in arch|fedora) e par2cmdline ;; esac -# needed for my tex resume -case $distro in - trisquel|ubuntu|debian) e texlive-full ;; - arch) e texlive-most ;; - # fedora unknown -esac +# for my tex resume. commented, due to t9 gnome causing package version conflict +# case $distro in +# trisquel|ubuntu|debian) e texlive-full ;; +# esac case $distro in # optional dep for firefox for h.264 video diff --git a/email-date.py b/email-date.py index f090336..2786037 100755 --- a/email-date.py +++ b/email-date.py @@ -1,4 +1,7 @@ #!/usr/bin/env python3 + +# unused. was in a mail archiving script, but its too slow. + from email.parser import BytesParser, Parser from email.policy import default from pathlib import Path diff --git a/filesystem/etc/cron.d/ian b/filesystem/etc/cron.d/ian index 5545e13..a97434d 100644 --- a/filesystem/etc/cron.d/ian +++ b/filesystem/etc/cron.d/ian @@ -6,3 +6,4 @@ PATH=/usr/bin:/bin:/usr/local/bin:/a/exe # 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 find /var/local/cron-errors /home/iank/cron-errors /sysd-mail-once-state -type f -mtime +4 +4 15 * * 5 iank /a/bin/ds/mailclean diff --git a/filesystem/etc/profile.d/environment.sh b/filesystem/etc/profile.d/environment.sh index 38a775f..fc6e804 100644 --- a/filesystem/etc/profile.d/environment.sh +++ b/filesystem/etc/profile.d/environment.sh @@ -1,16 +1,21 @@ +#!/bin/sh if [ -f $HOME/path-add-function ]; then . $HOME/path-add-function path-add /usr/sbin /usr/local/sbin /sbin /a/exe /a/opt/bin path-add --end $HOME/.cabal/bin + for p in $HOME/.gem/ruby/*/bin; do + path-add --ifexists --end $p + done + if [ -r /etc/alternatives/java_sdk ]; then export JAVA_HOME=/etc/alternatives/java_sdk path-add /etc/alternatives/java_sdk fi export GUIX_PROFILE=/root/.config/guix/current - if [[ -e $GUIX_PROFILE/etc/profile ]]; then - source $GUIX_PROFILE/etc/profile + if [ -f $GUIX_PROFILE/etc/profile ]; then + . $GUIX_PROFILE/etc/profile fi path-add $HOME/.guix-profile/bin export GUIX_LOCPATH=$HOME/.guix-profile/lib/locale @@ -57,7 +62,7 @@ if [ -f /etc/fedora-release ]; then if ! $GPGAGENT 2>/dev/null; then temp="$(mktemp)" eval "$($GPGAGENT --homedir /p/do-not-delete --daemon --sh --write-env-file=$PID_FILE 2>$temp)" - temperr="$(<"$temp")" + temperr="$(cat "$temp")" [ -n "$temperr" ] && xmessage "gpg-agent stderr: $temperr" elif [ -r "$PID_FILE" ]; then . "$PID_FILE" diff --git a/filesystem/usr/local/bin/irc b/filesystem/usr/local/bin/irc new file mode 100755 index 0000000..19aca3b --- /dev/null +++ b/filesystem/usr/local/bin/irc @@ -0,0 +1,2 @@ +#!/bin/bash +exec emacs -f znc-all diff --git a/filesystem/usr/local/bin/mycheckrestart b/filesystem/usr/local/bin/mycheckrestart index 1d4bdaa..e5cf601 100755 --- a/filesystem/usr/local/bin/mycheckrestart +++ b/filesystem/usr/local/bin/mycheckrestart @@ -3,8 +3,6 @@ # SPDX-License-Identifier: AGPL-3.0-or-later if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi -if [[ $EUID != 0 ]]; then s=sudo; fi - set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR @@ -14,7 +12,25 @@ if [[ $HOSTNAME != "$MAIL_HOST" && $hn != li.b8.nz && ! $DISPLAY ]]; then exit 0 fi -cmd="$s /usr/sbin/checkrestart -p" -if [[ $($cmd | sed '/^Found 0 processes using old versions of upgraded files$/d' | wc -l) != 0 ]]; then - $cmd +# note this is duplicated in /a/bin/ds/filesystem/usr/local/bin/myupgrade +ignore_lines=( + "Found 0 processes using old versions of upgraded files" + "lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs" + "Output information may be incomplete." + "Found 0 processes using old versions of upgraded files" +) +out= +while read -r line; do + ignore=false + for l in "${ignore_lines[@]}"; do + if [[ $line == "$l" ]]; then + ignore=true + break + fi + done + if $ignore; then continue; fi + out+="$line"$'\n' +done < <(sudo /usr/sbin/checkrestart -p 2>&1) +if (( ${#out} )); then + printf "%s" "$out" | pee cat wall fi diff --git a/filesystem/usr/local/bin/myupgrade b/filesystem/usr/local/bin/myupgrade index 737cb13..f439562 100755 --- a/filesystem/usr/local/bin/myupgrade +++ b/filesystem/usr/local/bin/myupgrade @@ -44,17 +44,44 @@ path-add /usr/local/go/bin l /a/bin/buildscripts/go l go get -u mvdan.cc/fdroidcl -cmd="sudo /usr/sbin/checkrestart -p" -if [[ $($cmd | sed '/^Found 0 processes using old versions of upgraded files$/d' | wc -l) != 0 ]]; then - $cmd | pee cat wall +# i disabled gvfs-daemon.service. I ran systemd-analyze --user dot, +# which doesnt show why it started, so its getting started by some +# startup script, and I dont want to track it down. + +# note, this is duplicated in /a/bin/ds/filesystem/usr/local/bin/mycheckrestart +ignore_lines=( + "Found 0 processes using old versions of upgraded files" + "lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/1000/gvfs" + "Output information may be incomplete." + "Found 0 processes using old versions of upgraded files" +) +out= +while read -r line; do + ignore=false + for l in "${ignore_lines[@]}"; do + if [[ $line == "$l" ]]; then + ignore=true + break + fi + done + if $ignore; then continue; fi + out+="$line"$'\n' +done < <(sudo /usr/sbin/checkrestart -p 2>&1) +if (( ${#out} )); then + printf "%s" "$out" | pee cat wall fi +if (( ${#out} )); then +dorestart=true +fi + + # no automatic reboot for these hosts -if [[ $HOSTNAME == "$MAIL_HOST" || $hn == li.b8.nz ]]; then +if [[ $HOSTNAME == "$MAIL_HOST" || $HOSTNAME == kw ]]; then exit 0 fi -if [[ -s /var/log/checkrestart.log ]]; then +if [[ -s /var/log/checkrestart.log ]] || $dorestart; then for x in {30..1}; do echo "pid $PID. unattended upgrade, rebooting in $((x*10)) seconds" | sudo wall -n sleep 10 @@ -62,6 +89,7 @@ if [[ -s /var/log/checkrestart.log ]]; then for x in {30..1}; do if ! fuser /var/lib/dpkg/lock &> /dev/null; then echo "pid $PID. unattended upgrade, rebooting now" | pee cat "sudo wall -n" + sudo /a/bin/ds/keyscript-on sudo /sbin/reboot exit 0 fi diff --git a/filesystem/usr/share/applications/emacsmail.desktop b/filesystem/usr/share/applications/emacsmail.desktop new file mode 100644 index 0000000..c7c9796 --- /dev/null +++ b/filesystem/usr/share/applications/emacsmail.desktop @@ -0,0 +1,12 @@ +#!/usr/bin/env xdg-open +# copied from mutt +[Desktop Entry] +Version=1.0 +Type=Application +Terminal=false +Name[en]=emacsmail +Exec=/a/bin/emacsmail %u +Name=emacsmail +MimeType=x-scheme-handler/mailto; +NoDisplay=false +Categories=Office;Network;Email; diff --git a/i3-sway/common.conf b/i3-sway/common.conf index 341613f..f5f7d21 100644 --- a/i3-sway/common.conf +++ b/i3-sway/common.conf @@ -7,12 +7,16 @@ bindsym $mod+2 exec "pavucontrol" bindsym $mod+3 exec "x-www-browser" bindsym $mod+4 exec "x-www-browser -no-remote -P firefox-main-profile" bindsym $mod+5 exec "/a/bin/redshift.sh" +bindsym $mod+equal exec "t s w; t in" +bindsym $mod+Home exec "t out" +bindsym $mod+End exec "t s x; t in x" bindsym $mod+w focus parent bindsym $mod+e fullscreen toggle 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+g layout tabbed # Use Mouse+$mod to drag floating windows to their wanted position diff --git a/i3-sway/i3.conf b/i3-sway/i3.conf index 1107e7b..29fb0a8 100644 --- a/i3-sway/i3.conf +++ b/i3-sway/i3.conf @@ -4,7 +4,9 @@ bindsym $mod+Shift+q exec "i3-nagbar -t warning -m 'You pressed the exit shortcu bindsym $mod+Shift+p restart bar { -status_command i3status +#status_command i3status +status_command /usr/local/bin/myi3status mode hide hidden_state hide +font pango:monospace 14 } diff --git a/install-my-scripts b/install-my-scripts index 6a763ef..ada75a3 100755 --- a/install-my-scripts +++ b/install-my-scripts @@ -35,5 +35,5 @@ x="$(readlink -f -- "${BASH_SOURCE[0]}")"; cd ${x%/*} # directory of this file # ran. Very strange, dunno why, but rsync won't do anything unless these # changed, so that should fix it. rsync -t --chmod=755 --chown=root:root /a/bin/log-quiet/log-once switch-mail-host btrbk-run mount-latest-subvol \ - check-subvol-stale system-status /usr/local/bin + check-subvol-stale system-status myi3status /usr/local/bin rsync -t --chmod=755 --chown=root:root /a/bin/errhandle/err /usr/local/lib diff --git a/machine_specific/btrbk/filesystem/etc/systemd/system/btrbk.timer b/machine_specific/btrbk/filesystem/etc/systemd/system/btrbk.timer index 27113f6..c63b999 100644 --- a/machine_specific/btrbk/filesystem/etc/systemd/system/btrbk.timer +++ b/machine_specific/btrbk/filesystem/etc/systemd/system/btrbk.timer @@ -2,7 +2,7 @@ Description=Run btrbk-run once every 20 mins [Timer] -OnCalendar=*:0/20 +OnCalendar=*:0/45 [Install] WantedBy=timers.target diff --git a/mail-route b/mail-route index 599c9d3..600ef07 100755 --- a/mail-route +++ b/mail-route @@ -6,7 +6,7 @@ # http://www.apache.org/licenses/LICENSE-2.0 -set -x +#set -x exec &> >(logger) # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, @@ -24,7 +24,7 @@ Usage: mail-route up|down|show Marks tcp packets on port 25, 143 and 587 to be routed through a vpn ip. If called from --up/--down in openvpn, (we have multiple args) $1 is the -tun_dev, and action is from $script_type. +tun_dev, and action is from $script_type env variable, openvpn sets this. Is idempotent. @@ -174,6 +174,8 @@ modify() { if (( $# > 1 )); then tun_dev=$1 + # environment var from openvpn + # shellcheck disable=SC2154 $script_type else case $1 in diff --git a/mail-setup b/mail-setup index 575511d..301fd77 100755 --- a/mail-setup +++ b/mail-setup @@ -1,5 +1,4 @@ #!/bin/bash -# -*- eval: (outline-minor-mode); -*- # * intro # Copyright (C) 2019 Ian Kelling # SPDX-License-Identifier: AGPL-3.0-or-later @@ -245,10 +244,9 @@ systemctl daemon-reload # * spamassassin -if [[ $HOSTNAME != "$MAIL_HOST" ]]; then +if [[ $HOSTNAME == "$MAIL_HOST" ]]; then m systemctl stop spamassassin m systemctl disable spamassassin -else # per readme.debian sed -i '/^\s*CRON\s*=/d' /etc/default/spamassassin @@ -289,8 +287,7 @@ EOF m systemctl daemon-reload m systemctl restart spamddnsfix.timer m systemctl enable spamddnsfix.timer - -fi # [[ $HOSTNAME != "$MAIL_HOST" ]] +fi ##### end spamassassin config @@ -724,6 +721,10 @@ CHECK_DATA_VERIFY_HEADER_SENDER = true CHECK_RCPT_SPF = true CHECK_RCPT_REVERSE_DNS = true CHECK_MAIL_HELO_ISSUED = true + +# 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 EOF m systemctl enable mailclean.timer @@ -732,7 +733,7 @@ EOF ;;& $MAIL_HOST) - # ** exim + # * exim # todo, these pem files look old and useless. whats going on sudo rsync -ahhi --chown=root:Debian-exim --chmod=0640 \ @@ -771,7 +772,7 @@ EOF # man page: is used to build the local_domains list, together with "localhost" # iank.bid is for testing # mail.iankelling.org is for machines i own -dc_other_hostnames='*.iankelling.org;iankelling.org;*zroe.org;zroe.org;$HOSTNAME.b8.nz;b8.nz' +dc_other_hostnames='*.iankelling.org;iankelling.org;*zroe.org;zroe.org;!l2.b8.nz;*.b8.nz;b8.nz' EOF @@ -791,10 +792,6 @@ EOF # smarthost config type, not sure. all other settings # would be unused in that config type. cat >>/etc/exim4/conf.d/main/000_local <>/etc/fstab fi + f=/etc/systemd/system/exim4.service.d/override.conf + if [[ ! -s $f ]]; then + # without this, we get these kind of errors in paniclog on shutdown: + # 2020-03-12 07:25:31.965 [32678] 1jCLxz-0008V4-V9 Failed to create spool file /var/spool/exim4//input//1jCLxz-0008V4-V9-D: Permission denied + mkdir -p /etc/systemd/system/exim4.service.d + cat >$f <<'EOF' +[Unit] +After=local-fs.target +EOF + m systemctl daemon-reload + fi if ! mountpoint -q $sdir; then m systemctl stop exim4 if [[ -L $sdir ]]; then @@ -989,6 +997,11 @@ else m systemctl start exim4 fi +if [[ $HOSTNAME != "$MAIL_HOST" ]]; then + m systemctl stop spamassassin + m systemctl disable spamassassin +fi + # * mail monitoring / testing @@ -1038,7 +1051,17 @@ esac # * misc -m sudo -u $u ln -sf -T /m/.mu /home/$u/.mu +sudo -u $u mkdir -p /home/$u/.cache +set -- /m/mucache /home/$u/.cache/mu /m/.mu /home/$u/.mu +while (($#)); do + target=$1 + f=$2 + shift 2 + if [[ -e $f && ! -L $f ]]; then + rm -rf $f + fi + m sudo -u $u ln -sf -T $target $f +done # /etc/alias setup is debian specific, and exim postinst script sets up @@ -1063,3 +1086,8 @@ m sudo -u $u ln -sf -T /m/.mu /home/$u/.mu exit 0 : + +# Local Variables: +# eval: (outline-minor-mode) +# outline-regexp: "\\( *\\)# [*]\\{1,8\\} " +# End: diff --git a/mailclean b/mailclean index 04c8f9d..8755338 100755 --- a/mailclean +++ b/mailclean @@ -1,9 +1,12 @@ #!/bin/bash -set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR -x="$(readlink -f -- "$BASH_SOURCE")"; scriptdir=${x%/*} +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 # find but ignore directories which dont exist, assuming first args are directories @@ -20,7 +23,7 @@ myfind() { dirs+=($d) fi done - if [[ $dirs ]]; then + if (( ${#dirs[*]} )); then find ${dirs[@]} $@ fi } @@ -29,9 +32,9 @@ myfind() { # I want to hop into conversations about our mailing # systems there, but I don't need many old messages. myfind /m/md/l/qemu-devel/new -type f -mtime +14 -execdir rm -- '{}' + -myfind /m/md/{sec,Spam,Drafts,{rtcc,sysadmin,l/outreachy-mentors}/new} -type f -mtime +100 -execdir rm -- '{}' + +myfind /m/md/{sec,Spam,Drafts,{rtcc,sysadmin}/new} -type f -mtime +100 -execdir rm -- '{}' + myfind /m/md/log -type f -mtime +300 -execdir rm -- '{}' + -myfind /m/md/dmarc -type f -mtime +14 -execdir rm -- '{}' + +myfind /m/md/dmarc -type f -mtime +60 -execdir rm -- '{}' + myfind /m/md/fsfalerts -type f -mtime +10 -execdir rm -- '{}' + @@ -39,25 +42,25 @@ myfind /m/md/fsfalerts -type f -mtime +10 -execdir rm -- '{}' + shopt -s nullglob shopt -s extglob -now=$(date +%s) -cd /m/md -for d in ./!(*archive|Drafts)/*(cur|new) ./l/!(*archive)/*(cur|new); do - madearchive=false - leafdir=${d##*/} - md=${d%/*}; md=${md##*/} - archivebase=${d%/*/*}/${md}-myarchive - archive=$archivebase/$leafdir - for f in $d/1*; do - date=$($scriptdir/email-date.py $f) || echo $f - [[ $date ]] || continue - if (( date < now - 60*60*24*400 )); then - if ! $madearchive; then - echo mkdir -p ${archivebase}/{cur,tmp,new} - mkdir -p ${archivebase}/{cur,tmp,new} - madearchive=true - fi - mv $f $archive - echo mv $f $archive - fi + +archive() { + days=$1 + shift + for d; do + [[ -d $d ]] || continue + leafdir=${d##*/} # cur/new + archivebase=${d%/*}-myarchive + archive=$archivebase/$leafdir + mkdir -p ${archivebase}/{cur,tmp,new} + find $d -type f -mtime +$days -name '1*' -exec mv '{}' $archive \; + # count=$(find $d -type f -mtime +$days -name '1*' | wc -l) + # if (( count )); then + # echo $d $count + # fi done -done +} + +cd /m/md +archive 400 ./!(*archive|Drafts)/*(cur|new) ./l/!(*archive)/*(cur|new) +archive 60 ./{sysadmin,rtcc,fsfcc,fsfmembers}/{cur,new} +archive 14 ./Junk/{cur,new} diff --git a/mailtest-check b/mailtest-check index 7adec92..e0272e2 100755 --- a/mailtest-check +++ b/mailtest-check @@ -41,8 +41,4 @@ limit=$(( now - 60 * min_limit )) if (( last_sec <= limit )); then echo $HOSTNAME mailtest failure - touch /nocow/user/mailtest-failure - break -else - rm -f /nocow/user/mailtest-failure fi diff --git a/mount-latest-remote b/mount-latest-remote index 2b5ca59..2d17f1e 100755 --- a/mount-latest-remote +++ b/mount-latest-remote @@ -18,18 +18,20 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR script_dir=$(dirname $(readlink -f "$BASH_SOURCE")) -if [[ ! $@ ]]; then +if (( ! $# )); then echo "mount-latest-remote: error: expected 1 or more host arguments" exit 1 fi -ret=0 + +$script_dir/install-my-scripts +cd /usr/local for tg; do - scp $script_dir/{mount-latest-subvol,check-subvol-stale} \ - root@$tg:/usr/local/bin + rsync -RtO bin/{mount-latest-subvol,check-subvol-stale} lib/err root@$tg:/usr/local ssh root@$tg bash <<'EOF' set -e chmod +x /usr/local/bin/{mount-latest-subvol,check-subvol-stale} -/usr/local/bin/mount-latest-subvol +# this can hang if we have an old nfs mount +timeout -s 9 600 /usr/local/bin/mount-latest-subvol EOF done diff --git a/mount-latest-subvol b/mount-latest-subvol index bce478a..5e3dbc0 100644 --- a/mount-latest-subvol +++ b/mount-latest-subvol @@ -237,7 +237,7 @@ for vol in q a o i; do if [[ $vol == q ]]; then # allow to fail, user might not be logged in - sudo -u iank systemctl --user stop arbtt ||: + x sudo -u $(id -nu 1000) XDG_RUNTIME_DIR=/run/user/1000 systemctl --user stop arbtt ||: fi umount_ret=true unmounted=() @@ -316,7 +316,7 @@ for vol in q a o i; do count=1 for leaf in ${leaf_vols[@]}; do leaf_secs=$(date -d ${leaf#$vol.leaf.} +%s) - if (( $(date +%s) - 60*60*24*60 > leaf_secs || count > 200 )); then # 60 days + if (( $(date +%s) - 60*60*24*60 > leaf_secs || count > 100 )); then # 60 days x btrfs sub del $leaf fi count=$((count+1)) @@ -334,7 +334,7 @@ for vol in q a o i; do done if [[ $vol == q ]]; then # maybe this will fail if X is not running - sudo -u iank systemctl --user stop arbtt ||: + x sudo -u $(id -nu 1000) XDG_RUNTIME_DIR=/run/user/1000 systemctl --user start arbtt ||: fi stale_dir=/nocow/btrfs-stale rm -f $stale_dir/$d diff --git a/myi3status b/myi3status new file mode 100644 index 0000000..34d44da --- /dev/null +++ b/myi3status @@ -0,0 +1,79 @@ +#!/bin/bash +# Copyright (C) 2019 Ian Kelling +# SPDX-License-Identifier: AGPL-3.0-or-later + +if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi + +source /a/bin/errhandle/err + +shopt -s nullglob +shopt -s dotglob + +shopt -s nullglob +for p in ~/.gem/ruby/*/bin; do + PATH="$PATH:$p" +done + + +main() { + + ps_char= + if [[ -e /dev/shm/iank-status ]]; then + eval $(< /dev/shm/iank-status) + fi + + # clocked in or out? + cursheet=$(sqlite3 /p/.timetrap.db "select sheet from entries where end is NULL;") + : ${cursheet:=out} + + # maybe sometime show work and x separate + today=$(t today -ftotal all) + + # hours remaining in the day: + + # work+study in the last week, not counting today. + # no arg to printf for the intentional behavior of no arg + # shellcheck disable=SC2183 + cache=/tmp/timetrap$(printf '%(%F)T') + if [[ -e $cache ]]; then + eval $(<$cache) + else + week=$(t display -ftotal -s '8 days ago' -e 'yesterday' all) + printf 'week="%s"\n' "$week" >$cache + week4=$(t display -ftotal -s '29 days ago' -e 'yesterday' all) + printf 'week4="%s"\n' "$week4" >>$cache + fi + # weekly work+study in the last 4 weeks, not counting today. + # todo later: + # 4 weeks + # ($x4week + $w4week + .05) /4 + #weekly work+study in the last 16 weeks, not counting today. + #weekly work+study in the last 52 weeks, not counting today. + + unixtime=$(date +%s) + midnight=$(date +%s -d 'tomorrow 00:00') + tmp=($(echo "scale=1; today_left=($midnight-$unixtime) / 60 / 60; +today_left; +done_today=($today + .05) /1; +/* hours I could do today by working 80% of the remainder time */ +today_left * .8 + done_today; +done_today; +($week + .05) /1; +($week4 + .05) /1"|bc)) + printf "[ { \"full_text\": \"" + if [[ $ps_char ]]; then + printf "%s| " "$ps_char" + fi + printf "%s | left today %s %s | today %s | week %s | 4weeks %s | %s\" } ],\n" "$cursheet" "${tmp[@]}" "$(date "+%A, %B %d, %r")" +} + +# pass any arg and we just run once +if (( $# )); then + main +else + printf '{ "version": 1 }\n[' + while true; do + main + sleep 5 + done +fi diff --git a/mymimes b/mymimes index 3177908..4c5c298 100755 --- a/mymimes +++ b/mymimes @@ -10,6 +10,8 @@ shopt -s extglob nullglob echo '[Default Applications]' >/etc/xdg/defaults.list sed -r '/^MimeType=/!d;s/^MimeType=//;s/;/=mpv.desktop\n/g' /usr/share/applications/mpv.desktop >>/etc/xdg/defaults.list +echo x-scheme-handler/mailto=emacsmail.desktop >>/etc/xdg/defaults.list + # this is the new one, according to # https://specifications.freedesktop.org/mime-apps-spec/mime-apps-spec-1.0.html # https://wiki.debian.org/MIME diff --git a/pkgs b/pkgs index c24084c..26fcc3d 100644 --- a/pkgs +++ b/pkgs @@ -82,6 +82,7 @@ p3=( duplicity eclipse elinks + etckeeper evince fdupes feh @@ -151,6 +152,7 @@ p3=( pdfgrep perl-doc pianobar + pinentry-tty pidgin pidgin-otr pry @@ -196,4 +198,5 @@ p3=( python-pygments ) +# shellcheck disable=SC2034 pall=(${p1[@]} ${p2[@]} ${p3[@]} ) diff --git a/subdir_files/.config/i3/config b/subdir_files/.config/i3/config index 3d6d055..14b6924 100644 --- a/subdir_files/.config/i3/config +++ b/subdir_files/.config/i3/config @@ -7,12 +7,16 @@ bindsym $mod+2 exec "pavucontrol" bindsym $mod+3 exec "x-www-browser" bindsym $mod+4 exec "x-www-browser -no-remote -P firefox-main-profile" bindsym $mod+5 exec "/a/bin/redshift.sh" +bindsym $mod+equal exec "t s w; t in" +bindsym $mod+Home exec "t out" +bindsym $mod+End exec "t s x; t in x" bindsym $mod+w focus parent bindsym $mod+e fullscreen toggle 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+g layout tabbed # Use Mouse+$mod to drag floating windows to their wanted position @@ -80,7 +84,9 @@ bindsym $mod+Shift+q exec "i3-nagbar -t warning -m 'You pressed the exit shortcu bindsym $mod+Shift+p restart bar { -status_command i3status +#status_command i3status +status_command /usr/local/bin/myi3status mode hide hidden_state hide +font pango:monospace 14 } diff --git a/subdir_files/.config/sakura/sakura.conf b/subdir_files/.config/sakura/sakura.conf index 266fd06..1fb5215 100644 --- a/subdir_files/.config/sakura/sakura.conf +++ b/subdir_files/.config/sakura/sakura.conf @@ -5,7 +5,7 @@ disable_numbered_tabswitch=true visible_bell=No audible_bell=No less_questions=true -colorset1_back=rgb(33,37,39 +colorset1_back=rgb(33,37,39) stop_tab_cycling_at_end_tabs=No colorset1_fore=rgb(192,192,192) colorset1_curs=rgb(255,255,255) diff --git a/subdir_files/.config/sway/config b/subdir_files/.config/sway/config index 2715465..7f9c2dc 100644 --- a/subdir_files/.config/sway/config +++ b/subdir_files/.config/sway/config @@ -7,12 +7,16 @@ bindsym $mod+2 exec "pavucontrol" bindsym $mod+3 exec "x-www-browser" bindsym $mod+4 exec "x-www-browser -no-remote -P firefox-main-profile" bindsym $mod+5 exec "/a/bin/redshift.sh" +bindsym $mod+equal exec "t s w; t in" +bindsym $mod+Home exec "t out" +bindsym $mod+End exec "t s x; t in x" bindsym $mod+w focus parent bindsym $mod+e fullscreen toggle 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+g layout tabbed # Use Mouse+$mod to drag floating windows to their wanted position diff --git a/subdir_files/.config/systemd/user/arbtt.service b/subdir_files/.config/systemd/user/arbtt.service index 5ac2c44..26154dd 100644 --- a/subdir_files/.config/systemd/user/arbtt.service +++ b/subdir_files/.config/systemd/user/arbtt.service @@ -1,11 +1,15 @@ [Unit] Description=arbtt +# StartLimitIntervalSec in recent systemd versions +StartLimitInterval=0 [Service] Type=simple ExecStart=/usr/bin/arbtt-capture --sample-rate=15 Environment="DISPLAY=:0" Restart=always +# time to sleep before restarting a service +RestartSec=10 [Install] WantedBy=default.target diff --git a/subdir_files/.gnupg/gpg.conf b/subdir_files/.gnupg/gpg.conf index 21955c4..6759281 100644 --- a/subdir_files/.gnupg/gpg.conf +++ b/subdir_files/.gnupg/gpg.conf @@ -40,13 +40,13 @@ default-key B125F60B7B287FF6A2B7DF8F170AF0E2954295DF #keyserver hkp://pool.sks-keyservers.net #keyserver hkp://keys.openpgp.org -#keyserver hkp://pgp.mit.edu +keyserver hkp://pgp.mit.edu #keyserver hkp://keyserver.pgp.com #keyserver hkp://ipv4.pool.sks-keyservers.net -keyserver hkp://keys.gnupg.net +#keyserver hkp://keys.gnupg.net #keyserver hkp://keyserver.ubuntu.com #keyserver hkp://keyring.debian.org -keyserver keyserver.ubuntu.com +#keyserver keyserver.ubuntu.com # more secure hkps, but had problems with my gpg version #keyserver hkps://hkps.pool.sks-keyservers.net diff --git a/subdir_files/sieve/lists.sieve b/subdir_files/sieve/lists.sieve index 35a2355..5ff6a68 100644 --- a/subdir_files/sieve/lists.sieve +++ b/subdir_files/sieve/lists.sieve @@ -100,6 +100,12 @@ if anyof ( } +if anyof ( + header :contains "list-id" "" + ) { + fileinto :create "l/license-discuss"; + stop; + } if anyof ( header :contains "list-id" "<~sircmpwn/sr.ht-discuss.lists.sr.ht>" diff --git a/subdir_files/sieve/liststest.sieve b/subdir_files/sieve/liststest.sieve index 35a2355..5ff6a68 100644 --- a/subdir_files/sieve/liststest.sieve +++ b/subdir_files/sieve/liststest.sieve @@ -100,6 +100,12 @@ if anyof ( } +if anyof ( + header :contains "list-id" "" + ) { + fileinto :create "l/license-discuss"; + stop; + } if anyof ( header :contains "list-id" "<~sircmpwn/sr.ht-discuss.lists.sr.ht>" diff --git a/switch-mail-host b/switch-mail-host index df0b836..88f9d8f 100644 --- a/switch-mail-host +++ b/switch-mail-host @@ -4,12 +4,13 @@ source /usr/local/lib/err usage() { cat </dev/null; then + xidle=$(xprintidle) + if [[ $xidle == [0-9]* ]]; then + now=$(sqlite3 /p/.timetrap.db "select sheet from entries where end is NULL;") + if [[ $now && $xidle -gt 300000 ]]; then + timetrap out + fi + fi + fi + glob=(/nocow/btrfs-stale/*) if [[ -e ${glob[0]} ]]; then chars+=("STALE!") @@ -43,9 +60,10 @@ write-status() { lo -1 bounce $bouncemsg glob=(/m/md/alerts/new/* /m/md/alerts/cur/*) if [[ -e ${glob[0]} ]]; then - chars+=("ALERT!") + chars+=("A") fi - if [[ -e /nocow/user/mailtest-failure ]]; then + tmp=(~/cron-errors/mailtest-failure*) + if (( ${#tmp[@]} )); then chars+=("MAILPING!") fi @@ -84,6 +102,7 @@ write-status() { chars+=("DISTRO-END!") else f=~/.local/conflink + # shellcheck disable=SC2043 for _ in 1; do if [[ -e $f ]]; then now=$(date +%s) @@ -123,8 +142,11 @@ write-status() { break fi - untracked=$(git ls-files -o --exclude-standard) - if [[ $untracked && $(find $untracked -mmin $fminplus -type f -print -quit) ]]; then + untracked=() + while read -r l; do + untracked+=("$l") + done < <(git ls-files -o --exclude-standard) + if [[ ${untracked[0]} && $(find "${untracked[@]}" -mmin $fminplus -type f -print -quit) ]]; then v conflink: untracked in $d chars+=("CONFLINK!") break @@ -181,6 +203,7 @@ write-status() { # Profiled it using time and also adding to the top of the file: # set -x # PS4='+ $(date "+%2N") ' + # shellcheck disable=SC2012 snaps=($(ls -1avdr /mnt/root/btrbk/$vol.20*|head -n1 || [[ $? == 141 ]] )) now=$(date +%s) maxtime=0 diff --git a/trusted-network b/trusted-network index 7cd754c..ce1e6f4 100755 --- a/trusted-network +++ b/trusted-network @@ -9,8 +9,6 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR # to a trusted one. if [[ -e /etc/dnsmasq.d/untrusted-network.conf ]]; then - rm -f /etc/dnsmasq.d/untrusted-network.conf - - nscd -i hosts - systemctl restart dnsmasq + rm -f /etc/dnsmasq.d/untrusted-network.conf /etc/systemd/resolved.conf.d/untrusted-network.conf + reresolv fi diff --git a/untrusted-network b/untrusted-network index b4fdb70..1936de7 100755 --- a/untrusted-network +++ b/untrusted-network @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash -l set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR @@ -8,8 +8,10 @@ trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR # Usage: use when switching from a trusted network to an untrusted one, # like public wifi. -if [[ ! -s /etc/dnsmasq.d/untrusted-network.conf ]]; then - cat >/etc/dnsmasq.d/untrusted-network.conf <<'EOF' +if [[ -s /etc/dnsmasq.d/untrusted-network.conf ]]; then + exit 0 +fi +cat >/etc/dnsmasq.d/untrusted-network.conf <<'EOF' server=8.8.4.4 server=8.8.8.8 server=2001:4860:4860::8844 @@ -19,6 +21,12 @@ no-resolv stop-dns-rebind EOF - nscd -i hosts - systemctl restart dnsmasq -fi +# https://wiki.archlinux.org/index.php/Systemd-resolved#Manually +cat >/etc/systemd/resolved.conf.d/untrusted-network.conf <<'EOF' +[Resolve] +DNS=8.8.4.4 8.8.8.8 2001:4860:4860::8844 2001:4860:4860::8888 +Domains=~. +EOF + + +reresolv