# mail related
etail() {
+ ngset
+ tail -F /var/log/exim4/mainlog /var/log/exim4/*main -n 200 "$@"
+ ngreset
+}
+etailm() {
tail -F /var/log/exim4/mainlog -n 200 "$@"
}
etail2() {
ccomp tail etail etail2
+
# print exim old pids
eoldpids() {
local configtime pid piduptime now daemonpid
esac
}
+
+ngset() {
+ if shopt nullglob >/dev/null; then
+ ngreset=false
+ else
+ shopt -s nullglob
+ ngreset=true
+ fi
+}
+ngreset() {
+ if $ngreset; then
+ shopt -u nullglob
+ fi
+}
+
nopanic() {
# shellcheck disable=SC2024
- sudo tee -a /var/log/exim4/paniclog-archive </var/log/exim4/paniclog; sudo truncate -s0 /var/log/exim4/paniclog
+ ngset
+ for f in /var/log/exim4/paniclog /var/log/exim4/*panic; do
+ base=${f##*/}
+ if [[ -s $f ]]; then
+ echo ================== $f =============
+ s tee -a /var/log/exim4/$base-archive <$f
+ s truncate -s0 $f
+ fi
+ done
+ ngreset
}
p8() { ping "$@" 8.8.8.8; }
fi
}
+
+# * spark
+# spark 1 5 22 13 53
+# # => ▁▁▃▂▇
+
+# The MIT License
+# Copyright (c) Zach Holman, https://zachholman.com
+# https://github.com/holman/spark
+
+# As of 2022-10-28, I reviewed github forks that had several newer
+# commits, none had anything interesting. I did a little refactoring
+# mostly to fix emacs indent bug.
+
+# Generates sparklines.
+_spark_echo()
+{
+ if [ "X$1" = "X-n" ]; then
+ shift
+ printf "%s" "$*"
+ else
+ printf "%s\n" "$*"
+ fi
+}
+
+
+spark()
+{
+ local f tc
+ local n numbers=
+
+ # find min/max values
+ local min=0xffffffff max=0
+
+ for n in ${@//,/ }
+ do
+ # on Linux (or with bash4) we could use `printf %.0f $n` here to
+ # round the number but that doesn't work on OS X (bash3) nor does
+ # `awk '{printf "%.0f",$1}' <<< $n` work, so just cut it off
+ n=${n%.*}
+ (( n < min )) && min=$n
+ (( n > max )) && max=$n
+ numbers=$numbers${numbers:+ }$n
+ done
+
+ # print ticks
+ local ticks=(▁ ▂ ▃ ▄ ▅ ▆ ▇ █)
+
+ # use a high tick if data is constant
+ (( min == max )) && ticks=(▅ ▆)
+
+ tc=${#ticks[@]}
+ f=$(( ( (max-min) <<8)/( tc - 1) ))
+ (( f < 1 )) && f=1
+
+ for n in $numbers
+ do
+ _spark_echo -n ${ticks[$(( ((($n-$min)<<8)/$f) ))]}
+ done
+ _spark_echo
+}
+
+
# * misc stuff
s scp bow:/tmp/oegu.jpg /t
s ssh bow rm /tmp/oegu.jpg
feh /t/oegu.jpg
- }
+}
slemacs() {
local arg rtime v
fi
ngreset
}
-ngset() {
- if shopt nullglob >/dev/null; then
- ngreset=false
- else
- shopt -s nullglob
- ngreset=true
- fi
-}
-ngreset() {
- if $ngreset; then
- shopt -u nullglob
- fi
-}
checkre() {
s checkrestart -b /a/bin/ds/checkrestart-blacklist -pv
done
}
-# these might need a mu index or something added.
-mbenable() {
- local mb=$1
- dst=/m/4e/$mb
- src=/m/md/$mb
- [[ -e $src ]] || { echo "src:$src does not exist"; return 1; }
- m mv -T $src $dst
- m ln -s -T $dst $src
-}
-mb2enable() {
- local mb
- for mb; do
- dst=/m/4e2/$mb
- link=/m/md/$mb
- src=/m/md/$mb
- if [[ ! -e $src || -L $src ]]; then
- src=/m/4e/$mb
+# maildir enable
+mdenable() {
+ local md dst ln_path src two
+
+ two=false
+ case $1 in
+ -2) two=true shift ;;
+ esac
+
+ for md; do
+ src=
+ if $two; then
+ dst=/m/4e2/$md
+ else
+ dst=/m/4e/$md
+ fi
+
+ ln_path=/m/md/$md
+ for d in /m/md/$md /m/4e2/$md; do
+ if [[ -d $d && ! -L $d ]]; then
+ src=$d
+ break
+ fi
+ done
+ if [[ ! $src ]]; then
+ echo "error: could not find $md" >&2
+ return 1
fi
- [[ -e $src ]] || { echo "src:$src does not exist"; return 1; }
m mv -T $src $dst
- m ln -sf -T $dst $link
+ m ln -sf -T $dst $ln_path
done
}
-mbdisable() {
- local mb=$1
- dst=/m/md/$mb
- src=/m/4e/$mb
- set -x
- [[ -e $src ]] || { set +x; return 1; }
- if [[ -L $dst ]]; then rm $dst; fi
- mv -T $src $dst
- set +x
+md2enable() {
+ mdenable -2 "$@"
}
-mb2disable() {
- local mb=$1
- dst=/m/md/$mb
- src=/m/4e2/$mb
- set -x
- [[ -e $src ]] || { set +x; return 1; }
- if [[ -L $dst ]]; then rm $dst; fi
- mv -T $src $dst
- set +x
+mddisable() {
+ local md=$1
+ dst=/m/md/$md
+
+ ### begin copied from mdenable, but different d ###
+ for d in /m/4e/$md /m/4e2/$md; do
+ if [[ -d $d && ! -L $d ]]; then
+ src=$d
+ break
+ fi
+ done
+ if [[ ! $src ]]; then
+ echo "error: could not find $md" >&2
+ return 1
+ fi
+ ### end copy from mdenable ###
+
+ if [[ -L $dst ]]; then m rm $dst; fi
+ m mv -T $src $dst
}
# exim -t 'test@zroe.org, t2@zroe.org' <<'EOF'
#
# -t = get recipient from header
- exim -d -t <<'EOF'
-From: root@$(hostname-f)
-To: root@$(hostname-f)
+ exim -d -t <<EOF
+From: root@$(hostname -f)
+To: root@$(hostname -f)
Subject: test2
This is a test message.
# other says gmail does not reject. figure out and open a new bug.
IGNORE_SMTP_LINE_LENGTH_LIMIT = true
-# more verbose logs
-MAIN_LOG_SELECTOR = +all
+# more verbose logs. used to use +all, but made it less for more efficiency.
+MAIN_LOG_SELECTOR = -tls_cipher -tls_certificate_verified +pid +received_recipients +received_sender +sender_on_delivery +return_path_on_delivery +msg_id_created +subject +address_rewrite +smtp_confirmation
# Based on spec, seems like a good idea to be nice.
smtp_return_error_details = true
set -eE
if pgrep -G iank -u iank -f 'emacs --daemon' &>/dev/null; then
export XDG_RUNTIME_DIR=/run/user/1000
- bufs="$(emacsclient --eval "$(cat /a/bin/ds/unsaved-buffers.el)"| sed '/^"nil"$/d;s/^"(/E: /;s/)"$//')"
+ bufs="$(sudo -u iank 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
export XDG_RUNTIME_DIR=/run/user/1000
- bufs="$(emacsclient --eval "$(cat /a/bin/ds/unsaved-buffers.el)"| sed '/^"nil"$/d;s/^"(/E: /;s/)"$//')"
+ bufs="$(sudo -u iank 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