From f5936ffe8eb19cc364b19caf79437f4863d73fd0 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Sun, 16 Aug 2020 10:01:12 -0400 Subject: [PATCH] various fixes and improvements --- brc | 56 ++++++++++++++++++++++++++++++- distro-begin | 2 +- distro-end | 10 +++--- i3-sway/i3.conf | 2 +- mail-route | 2 -- mailclean | 2 +- pt | 12 +++++++ subdir_files/.config/mpv/mpv.conf | 2 +- 8 files changed, 75 insertions(+), 13 deletions(-) create mode 100755 pt diff --git a/brc b/brc index c2cac5b..46651f1 100644 --- a/brc +++ b/brc @@ -252,7 +252,7 @@ fpst() { # file paste _khfix_common() { local host=${1##*@} local ip port - read -r ip port < <(timeout 1 ssh -oBatchMode=yes -oControlMaster=no -oControlPath=/ -v $1 |& sed -rn "s/debug1: Connecting to $host \[([^\]*)] port ([0-9]+).*/\1 \2/p") + read -r ip port < <(timeout 1 ssh -oBatchMode=yes -oControlMaster=no -oControlPath=/ -v $1 |& sed -rn "s/debug1: Connecting to $host \[([^\]*)] port ([0-9]+).*/\1 \2/p" || [[ $? == 124 ]]) if [[ ! $ip ]]; then echo "khfix: ssh failed" return 1 @@ -520,6 +520,60 @@ ediff() { etail() { tail -F /var/log/exim4/mainlog -n 200 "$@" } + +# print exim old pids +eoldpids() { + local configtime pid piduptime now daemonpid + printf -v now '%(%s)T' -1 + configtime=$(stat -c%Y /var/lib/exim4/config.autogenerated) + if [[ -s /run/exim4/exim.pid ]]; then + daemonpid=$(cat /run/exim4/exim.pid) + fi + for pid in $(pgrep -f '^/usr/sbin/exim4( |$)'); do + # the daemonpid gets reexeced on HUP (service reloads), keeping its same old timestamp + if [[ $pid == $daemonpid ]]; then + continue + fi + piduptime=$(awk -v ticks="$(getconf CLK_TCK)" 'NR==1 { now=$1; next } END { printf "%9.0f\n", now - ($20/ticks) }' /proc/uptime RS=')' /proc/$pid/stat) ||: # sometimes pids disappear pretty fast + if (( configtime > now - piduptime )); then + echo $pid + fi + done +} + +# exim tail but only watch lines from new pids +etailnew() { + local pid oldpids + for pid in $(eoldpids); do + oldpids+="$pid|" + done + if [[ $oldpids ]]; then + etail | awk '$3 !~ /^\[('"${oldpids%|}"')\]$/' + else + etail + fi +} +# exim watch as old pids go away +ewatchold() { + local configtime pid piduptime now + local -i count + local -a oldpids + count=0 + while true; do + oldpids=($(eoldpids)) + if (( ! ${#oldpids[@]} )); then + return + fi + # print the date every 20 iterations + if (( ! count % 20 )); then + date + fi + count+=1 + ps -f -p "${oldpids[*]}" + sleep 1 + done +} + eless() { less /var/log/exim4/mainlog } diff --git a/distro-begin b/distro-begin index 619cc25..8595d1b 100755 --- a/distro-begin +++ b/distro-begin @@ -153,7 +153,7 @@ EOF sudo dd of=/etc/systemd/system/keyscriptoff.service <<'EOF' [Unit] -Description=keyscriptoff +Description=keyscriptoffIMG_20200803_221621 [Service] Type=oneshot diff --git a/distro-end b/distro-end index cc593e2..b99c242 100755 --- a/distro-end +++ b/distro-end @@ -523,9 +523,9 @@ ifconfig-ipv6-push 2600:3c00:e000:280::2/64 EOF if [[ -e /lib/systemd/system/openvpn-server@.service ]]; then - vpn_service=openvpn-server@server + vpn_service=openvpn-server@mail else - vpn_service=openvpn@server + vpn_service=openvpn@mail fi sudo dd of=/etc/systemd/system/vpnmail.service <&2; exit 1; fi + +shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4 +set -eE -o pipefail +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?. PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR + +cd /a/opt/Pithosfly +ninja -C build run diff --git a/subdir_files/.config/mpv/mpv.conf b/subdir_files/.config/mpv/mpv.conf index b7c2860..8325153 100644 --- a/subdir_files/.config/mpv/mpv.conf +++ b/subdir_files/.config/mpv/mpv.conf @@ -5,7 +5,7 @@ loop-file=no shuffle #volume=50 -save-position-on-quit +#save-position-on-quit # use --profile d [d] -- 2.30.2