[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]
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 \
}
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
}
}
gr() {
- grep -iIP --color=auto "$@"
+ grep -iIP --color=auto "$@" || return $?
}
grr() { # grep recursive
# 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() {
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
}
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
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 "$@"
}
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
}
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
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
# 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
# set titlebar
#echo -ne "$title_escape ${PWD/#$HOME/~} \007"
-
}
PROMPT_COMMAND=prompt-command
# 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" "$*"
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
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
bbk() { # btrbk wrapper
- local pid
c /
local active=true
systemctl is-active btrbk.timer || active=false
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
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)
# 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
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.
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
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
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
}
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.
# 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)
tu() {
- local s dir
- dir="$(dirname "$1")"
+ local s
if [[ -e $1 && ! -w $1 || ! -w $(dirname "$1") ]]; then
s=s;
fi
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
# 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
# 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
# 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]}" "$@"
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
;;
# 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.
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
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)
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
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
;;
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[@]}"
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
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
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
###### 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
###### 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
#!/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
# fi
-######### begin flidas pinned packages ######
+pi debootstrap
+######### begin universal pinned packages ######
case $(debian-codename) in
etiona|flidas)
sd /etc/apt/preferences.d/etiona-buster <<EOF
Pin: release n=bionic
Pin-Priority: -100
-Package: firefox gnome-screenshot gnome-icon-theme libnautilus-extension1a gnome-settings-daemon nautilus yelp gnome-settings-daemon-schemas nautilus-data ubuntu-wallpapers gnome-control-center gnome-control-center-data gnome-control-center-faces libsnapd-glib1 ubuntu-wallpapers-bionic gir1.2-snapd-1 ubuntu-drivers-common ubuntu-docs libyelp0
-Pin: release n=bionic
-Pin-Priority: 500
EOF
+
+ # Package: firefox gnome-screenshot gnome-icon-theme libnautilus-extension1a gnome-settings-daemon nautilus yelp gnome-settings-daemon-schemas nautilus-data ubuntu-wallpapers gnome-control-center gnome-control-center-data gnome-control-center-faces libsnapd-glib1 ubuntu-wallpapers-bionic gir1.2-snapd-1 ubuntu-drivers-common ubuntu-docs libyelp0
+ # Pin: release n=bionic
+ # Pin-Priority: 500
+
;;&
*)
if isdeb; then
fi
;;
esac
-######### end flidas pinned packages ######
+######### end universal pinned packages ######
##### begin automatic upgrades (after checkrestart has been installed) ####
-sd /etc/apt/apt.conf.d/10periodic <<'EOF'
-# this file was mostly just comments.
+# if apt-config-auto-update is installed,
+# it also has similar config, in a file 10something,
+# but i think his overrides it since its higher number.
+# This file was part of the automatic-updates package,
+# and it has a configu option to not get new package lists,
+# which seems pretty stupid to me, you cant actually upgrade
+# anything if you dont have the new package list.
+sd /etc/apt/apt.conf.d/20auto-upgrades <<'EOF'
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
APT::Periodic::AutocleanInterval "7";
APT::Periodic::Unattended-Upgrade "1";
EOF
-sd /etc/apt/apt.conf.d/50unattended-upgrades <<EOF
# fyi: default file has comments about available options,
# you may want to read that, do pkx unattended-upgrades
+# default is just security updates. this list found from reading
+# match_whitelist_string() in $(which unattended-upgrades)
+sd /etc/apt/apt.conf.d/50unattended-upgrades <<EOF
Unattended-Upgrade::Mail "root";
Unattended-Upgrade::MailOnlyOnError "true";
Unattended-Upgrade::Remove-Unused-Dependencies "true";
Unattended-Upgrade::Origins-Pattern {
- # default is just security updates. this list found from reading
- # match_whitelist_string() in $(which unattended-upgrades)
"o=*,l=*,a=*,c=*,site=*,n=*";
};
EOF
SHELL=/bin/bash
# default is /usr/bin:/bin
PATH=/usr/bin:/bin:/usr/local/bin
-20 7 * * * iank myupgrade |& log-once -1 myupgrade
-0 * * * * root mycheckrestart |& log-once -1 mycheckrestart
+#20 7 * * * iank myupgrade |& log-once -1 myupgrade
+#0 * * * * root mycheckrestart |& log-once -1 mycheckrestart
EOF
##### end automatic upgrades ####
pi task-gnome-desktop
;;
bionic)
- pi gnome-core
+
+ pi xorg lightdm mate-desktop-environment mate-desktop-environment-extras mate-indicator-applet anacron
+
+ # pi gnome-core
+ # # apt-get update periodically fails with an appstream error.
+ # # this removes gnome-core, but its just a package for dependencies
+ # p -y remove appstream
+
+
# by default, it sleeps when not logged in to x/wayland and on ac power.
# stop that.
sudo -u gdm dbus-launch gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type 'nothing'
m systemctl --user stop gvfs-daemon
m systemctl --user disable gvfs-daemon
- # apt-get update periodically fails with an appstream error.
- # this removes gnome-core, but its just a package for dependencies
- p -y remove appstream
;;
esac
# version 70. firefox in ubuntu is at version 70.
# have to rm compabibility.ini to even try downgrade.
pi firefox
-sudo update-alternatives --set x-www-browser /usr/bin/firefox
+sudo update-alternatives --set x-www-browser /usr/bin/abrowser
# TODO: some of the X programs can be removed from pall when using wayland
case $codename in
etiona)
pi arbtt
+ seru enable arbtt
+ seru start arbtt
;;
esac
########### misc stuff
+if ! type -p t &>/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)
# guix package --install guile
# fi
-
+lnf -T /a/opt ~/src
pi tor
m /a/bin/buildscripts/tor-browser
#!/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
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 ;;
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
#!/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
# 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
+#!/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
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"
--- /dev/null
+#!/bin/bash
+exec emacs -f znc-all
# 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
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
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
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
--- /dev/null
+#!/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;
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
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
}
# 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
Description=Run btrbk-run once every 20 mins
[Timer]
-OnCalendar=*:0/20
+OnCalendar=*:0/45
[Install]
WantedBy=timers.target
# 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,
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.
if (( $# > 1 )); then
tun_dev=$1
+ # environment var from openvpn
+ # shellcheck disable=SC2154
$script_type
else
case $1 in
#!/bin/bash
-# -*- eval: (outline-minor-mode); -*-
# * intro
# Copyright (C) 2019 Ian Kelling
# SPDX-License-Identifier: AGPL-3.0-or-later
# * 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
m systemctl daemon-reload
m systemctl restart spamddnsfix.timer
m systemctl enable spamddnsfix.timer
-
-fi # [[ $HOSTNAME != "$MAIL_HOST" ]]
+fi
##### end spamassassin config
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
;;&
$MAIL_HOST)
- # ** exim
+ # * exim
# todo, these pem files look old and useless. whats going on
sudo rsync -ahhi --chown=root:Debian-exim --chmod=0640 \
# 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
# smarthost config type, not sure. all other settings
# would be unused in that config type.
cat >>/etc/exim4/conf.d/main/000_local <<EOF
-# 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
-
# failing message on mail-tester.com:
# We check if there is a server (A Record) behind your hostname kd.
# You may want to publish a DNS record (A type) for the hostname kd or use a different hostname in your mail software
if ! grep -Fx "/nocow/exim4 /var/spool/exim4 none bind 0 0" /etc/fstab; then
echo "/nocow/exim4 /var/spool/exim4 none bind 0 0" >>/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
m systemctl start exim4
fi
+if [[ $HOSTNAME != "$MAIL_HOST" ]]; then
+ m systemctl stop spamassassin
+ m systemctl disable spamassassin
+fi
+
# * mail monitoring / testing
# * 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
exit 0
:
+
+# Local Variables:
+# eval: (outline-minor-mode)
+# outline-regexp: "\\( *\\)# [*]\\{1,8\\} "
+# End:
#!/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
dirs+=($d)
fi
done
- if [[ $dirs ]]; then
+ if (( ${#dirs[*]} )); then
find ${dirs[@]} $@
fi
}
# 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 -- '{}' +
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}
if (( last_sec <= limit )); then
echo $HOSTNAME mailtest failure
- touch /nocow/user/mailtest-failure
- break
-else
- rm -f /nocow/user/mailtest-failure
fi
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
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=()
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))
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
--- /dev/null
+#!/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
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
duplicity
eclipse
elinks
+ etckeeper
evince
fdupes
feh
pdfgrep
perl-doc
pianobar
+ pinentry-tty
pidgin
pidgin-otr
pry
python-pygments
)
+# shellcheck disable=SC2034
pall=(${p1[@]} ${p2[@]} ${p3[@]} )
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
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
}
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)
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
[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
#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
}
+if anyof (
+ header :contains "list-id" "<license-review.lists.opensource.org>"
+ ) {
+ fileinto :create "l/license-discuss";
+ stop;
+ }
if anyof (
header :contains "list-id" "<~sircmpwn/sr.ht-discuss.lists.sr.ht>"
}
+if anyof (
+ header :contains "list-id" "<license-review.lists.opensource.org>"
+ ) {
+ fileinto :create "l/license-discuss";
+ stop;
+ }
if anyof (
header :contains "list-id" "<~sircmpwn/sr.ht-discuss.lists.sr.ht>"
usage() {
cat <<EOF
-Usage: ${0##*/} push|pull HOST
+Usage: ${0##*/} [OPTIONS] push|pull HOST
Turn off mail receiving on OLD_HOST, run btrbk to move mail to NEW_HOST,
turn on mail receiving on NEW_HOST. Assumes we want to move all
filesystems unless passing -o.
+-i Disallow incremental backup.
-o Only btrbk /o, instead of all filesystems.
-h|--help Print help and exit.
force=false
mp_args="-m /o,/q,/a"
-temp=$(getopt -l force,help owh "$@") || usage 1
+temp=$(getopt -l force,help ioh "$@") || usage 1
eval set -- "$temp"
while true; do
case $1 in
--force) force=true ;;
+ -i) incremental_arg="-i" ;;
-o) mp_args="-m /o"; shift ;;
-h|--help) usage ;;
--) shift; break ;;
(( $# == 2 )) || usage 1
if [[ ! $HOSTNAME ]]; then
- err '$HOSTNAME is unset'
+ err "\$HOSTNAME is unset"
mexit 1
fi
e Running initial btrbk
-if ! m btrbk-run -v $bbk_args $mp_args; then
+if ! m btrbk-run -v $bbk_args $incremental_arg $mp_args; then
ret=$?
err "failed initial btrbk"
mexit $ret
m $old_shell /a/exe/primary-setup $new_hostname
e Running main btrbk
-m btrbk-run -v $bbk_args -m /o || ret=$?
+m btrbk-run -v $bbk_args $incremental_arg -m /o || ret=$?
if (( ret )); then
bang="$(printf "$(tput setaf 5)█$(tput sgr0)%.0s" 1 2 3 4 5 6 7)"
e $bang failed btrbk of /o. restoring old host as primary
shopt -s nullglob
shopt -s dotglob
+for p in ~/.gem/ruby/*/bin; do
+ PATH="$PATH:$p"
+done
+
+
verbose=false
if [[ $1 ]]; then
verbose=true
write-status() {
chars=("${first_chars[@]}")
+ # clock us out in timetrap if are idle too long
+ export DISPLAY=:0
+ if type -p xprintidle &>/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!")
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
chars+=("DISTRO-END!")
else
f=~/.local/conflink
+ # shellcheck disable=SC2043
for _ in 1; do
if [[ -e $f ]]; then
now=$(date +%s)
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
# 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
# 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
-#!/bin/bash
+#!/bin/bash -l
set -eE -o pipefail
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
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