local quotes others
quotes=2048,2068,2086,2206,2254
- others=2029,2033,2054,2164
+ others=2029,2032,2033,2054,2164,
shellcheck -W 999 -x -e $quotes,$others "$@" || return $?
}
# sk with quotes. For checking scripts that we expect to take untrusted
# pull in beets library locally
beetpull() {
- local sshfs_host
+ local sshfs_host sshfs_cmd
sshfs_host=b8.nz
if [[ $HOSTNAME == kd ]]; then
return 0
s mkdir /i
s chown iank:iank /i
fi
- if ! mountpoint /i &>/dev/null; then
- m sshfs $sshfs_host:/i /i
+ sshfs_cmd="sshfs -o ServerAliveInterval=15,reconnect $sshfs_host:/i /i"
+ if ! pgrep -f "^$sshfs_cmd$" >/dev/null; then
+ m $sshfs_cmd
fi
}
else
i=0
fi
- min_date=$(date -d 'monday 2 weeks ago' +%s)
+ # usually do this on monday, sometimes later
+ if [[ $(date +%A) == Monday ]]; then
+ min_date=$(date -d 'monday 2 weeks ago' +%s)
+ else
+ min_date=$(date -d 'monday 3 weeks ago' +%s)
+ fi
for (( ; i < logcount; i++ )); do
log=${logs[$i]}
d=$(date -d "$(head -n1 $log|awk '{print $1}')" +%s)
popd
}
-# tail pms in the last day, for the case where we restart profanity and
-# didn't check for pms beforehand.
-profrecent() {
+# Tail pms in the last day, for the case where we restart profanity and
+# didn't check for pms beforehand. Assume the most recent logs are on kd.
+# If that isn't the case, use prof-recent-local
+prof-recent() {
+ case $HOSTNAME in
+ kd)
+ prof-recent-local
+ ;;
+ *)
+ ssh b8.nz prof-recent-local
+ ;;
+ esac
+}
+
+prof-recent-local() {
local d dates date files f
# consider making the day count passed by parameter. note: this works: $(date -d '2 day ago' +%Y_%m_%d)
- dates=("$(date -d +%Y_%m_%d)" "$(date -d '1 day ago' +%Y_%m_%d)" )
+ dates=("$(date +%Y_%m_%d)" "$(date -d '1 day ago' +%Y_%m_%d)" )
for d in /d/p/profanity/chatlogs/iank_at_fsf.org/!(rooms); do
files=()
for date in ${dates[@]}; do
##### begin automatic upgrades (after checkrestart has been installed) ####
# 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.
+# but i think this 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,
+# and it has a config 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'
+# note: man apt.conf says
+# /usr/share/doc/apt/examples/configure-index.gz is a configuration file showing
+# example values for all possible options.
+# but that is a incorrect.
+# Periodic and other options are only documented in
+# /usr/lib/apt/apt.systemd.daily
+# That filename can be found through poking around in apt daily cronjob.
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Download-Upgradeable-Packages "1";
-APT::Periodic::AutocleanInterval "7";
+# 0 means disabled. I used to set this to 7, however, trisquel doesn't
+# have an archive of old package versions, so I want to
+# keep around old versions so I can easily downgrade.
+APT::Periodic::AutocleanInterval "0";
+# daily expire old files /var/cache/apt if it gets above this MB
+APT::Periodic::MaxSize "50000";
APT::Periodic::Unattended-Upgrade "1";
EOF
####### begin misc packages ###########
+# old location, 2023.
+sudo rm -fv /etc/systemd/system/profanity.service
case $HOSTNAME in
kd)
ln -sfT /d/p/profanity ~/.local/share/profanity
ln -sfT /d/p/profanity-config ~/.config/profanity
source /a/bin/bash_unpublished/source-state
- if [[ $HOSTNAME == "$HOST2" ]]; then
- systemctl --now enable profanity
+ if [[ $HOSTNAME == "$HOST2" || ! -e /p/profanity-here ]]; then
+ systemctl --user --now enable profanity
fi
;;
*)
Wants=network-online.target
[Service]
+# iank: on a laptop, when it is doing its catchup, it tends to jump
+# between 100% and 180% cpu and makes the fan spin annoyingly. Randomly
+# trying out 50% to see if it will make the fan quieter.
+CPUQuota=50%
ExecStart=/usr/bin/bitcoind -daemonwait \
-pid=/run/bitcoind/bitcoind.pid \
-conf=/etc/bitcoin/bitcoin.conf \
+++ /dev/null
-[Unit]
-Description=profanity
-After=network-online.target
-
-[Service]
-# bash is required to get colors working
-ExecStart=/usr/bin/screen -S profanity -Dm /bin/bash -c profanity
-User=iank
-Group=iank
-
-[Install]
-WantedBy=multi-user.target
}
-case $HOSTNAME in
+case $hn in
kd)
/c/roles/prom/files/simple/usr/local/bin/fsf-install-prometheus
/c/roles/prom_export/files/simple/usr/local/bin/fsf-install-node-exporter -l 127.0.0.1
# because rebooting from the script stops the ability to send email.
# We should figure some workaround.
-if ! out=$(/sbin/needrestart -p 2>&1); then
- if [[ $HOSTNAME == "$MAIL_HOST" ]]; then
+# I originally had the idea that for MAIL_HOST, I'd just send an email
+# if something needs restarting. But atm, I have a bad habit of ignoring
+# those emails.
+
+if ! needrestart -p -k &>/dev/null; then
+ myreboot
+fi
+
+needrestart -b -l -r a |& logger -t myupgrade
+sleep 1
+
+# Restart based on library doesnt always work. If we still
+# detect outdated libraries after trying to automatically restart,
+# then do a reboot unless we are on systems we care a bit more about
+# uptime, then send us an email.
+#
+# Note: I've noticed restart based on library has tended to screw up
+# desktop related daemons because they have bugs when restarted in
+# isolation instead of as part of bring up and down the whole desktop.
+# But, I'd rather something gets messed up than things not get
+# restarted.
+if ! /sbin/needrestart -p -l &>/dev/null; then
+ if [[ $hn == "$MAIL_HOST" || $hn == kd ]]; then
+ # send us an email so we can decide what to do
needrestart -r l
else
myreboot
#bindsym $mod+3 exec "abrowser 2>&1 >/tmp/l"
#bindsym $mod+3 exec "abrowser -no-remote -P sfw"
bindsym $mod+4 exec "abrowser -no-remote -P firefox-main-profile"
-bindsym $mod+5 exec "/usr/local/bin/start-tor-browser"
-bindsym $mod+6 exec "/a/bin/redshift.sh"
+bindsym $mod+5 exec "/a/bin/ds/laptop-xrandr"
+bindsym $mod+6 exec "/usr/local/bin/start-tor-browser"
+#bindsym $mod+6 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"
--- /dev/null
+#!/bin/bash
+set -e; . /usr/local/lib/err; set +e
+
+# xrandr --auto
+
+# xrandr --output HDMI2 --right-of eDP1 --mode 3840x2160
+
+for i in 1 2 4 5 6 7 8 9 10; do
+ # if the workspace is already there, this will fail
+ i3-msg '[workspace="'$i'"]' move workspace to output HDMI2 ||:
+done
# Copyright (C) 2019 Ian Kelling
# SPDX-License-Identifier: AGPL-3.0-or-later
+# todo:
+# on bk (and fsf servers that run multiple exim4 daemons, eg eximfsf2 and eximfsf3),
+# make it so that when exim is restarted due to package upgrades,
+# we also restart those daemons, which can be done like so, based on looking
+# at the prerm and postinst scripts of exim4-daemon-heavy.
+#
+# if [[ ! -e /usr/sbin/invoke-rc.d-diverted ]]; then
+# mv /usr/sbin/invoke-rc.d /usr/sbin/invoke-rc.d-diverted
+# dpkg --divert /usr/sbin/invoke-rc.d-diverted --no-rename /usr/sbin/invoke-rc.d
+# fi
+# /usr/sbin/invoke-rc.d:
+# #!/bin/bash
+# if [[ DPKG_MAINTSCRIPT_PACKAGE == exim4* && $1 == exim4 ]]; then
+# shift
+# ret=0
+# for daemon in exim4 eximfsf2 eximfsf3; do
+# /usr/sbin/invoke-rc.d-diverted $daemon "$@" || ret=$?
+# done
+# else
+# /usr/sbin/invoke-rc.d-diverted "$@"
+# fi
+
# Things I tend to forget. on MAIL_HOST, daemon runs with /etc/exim4/my.conf,
# due to /etc/default/exim4 containing:
# COMMONOPTIONS='-C /etc/exim4/my.conf'
#######
-# * perstent password instructions
-# Note: for cert cron, we need to manually run first to accept known_hosts
+# * perstent password instructions Note: for cert cron, we need to
+# manually run first to accept known_hosts
# # exim passwords:
# # for hosts which have all private files I just use the same user
remote=$1
else
remote=b8.nz
- if systemctl --quiet is-active profanity || [[ $HOSTNAME == kd ]]; then
+ if systemctl --user --quiet is-active profanity || [[ $HOSTNAME == kd ]]; then
dossh=false
fi
fi
export IANK_BASHRC_RUN="prof-remote $remote"
konsole --profile profanity
else
+ prof-tail | prof-notify &
konsole --profile profanity -e screen -RD -S profanity
fi
fi
;;
*)
- if ssh b8.nz systemctl --quiet is-active profanity; then
+ if ssh iank@b8.nz systemctl --user --quiet is-active profanity; then
rsync -a b8.nz:/d/p/profanity{,-config} /p
fi
;;
--- /dev/null
+#!/bin/bash
+set -e; . /usr/local/lib/err; set +e
+
+while read -r line; do
+ # check that the profanity window is not focused
+ if ! i3-msg -t get_tree | jq -e '.nodes[].nodes[].nodes[].nodes[] | select(.focused==true and .name=="profanity — Konsole") |.name' &>/dev/null; then
+ # the profanity tag makes it so new notification replaces old.
+ dunstify -h string:x-dunst-stack-tag:profanity $line
+ fi
+done
fastcon=0
while true; do
start=$EPOCHSECONDS
- ssh -t $remote screen -Dr -S profanity
+ # -n or else it competes with the other ssh for reading stdin.
+ ssh -n $remote prof-tail | prof-notify &
+ ssh -t $remote screen -Dr -S profanity ||:
+ builtin kill %% &> /dev/null ||:
if (( EPOCHSECONDS > start + 600 )); then
fastcon=0
fi
--- /dev/null
+#!/bin/bash
+set -e; . /usr/local/lib/err; set +e
+
+
+xmpp_users=(
+ anoukr
+ craigt
+ dawnbp
+ devinu
+ gregf
+ johnh
+ jrasata
+ ksiewicz
+ michael
+ miriam
+ ruben
+ zoe
+ jtuttle
+)
+
+
+while true; do
+ midnight=$(date -d '00:00:00 tomorrow' +%s)
+ secs_till_midnight=$(( midnight - EPOCHSECONDS ))
+ log_today=$(date '+%Y_%m_%d').log
+ logdir=/home/iank/.local/share/profanity/chatlogs/iank_at_fsf.org
+
+ timeout --foreground $secs_till_midnight tail -n0 -qF \
+ $(for u in ${xmpp_users[@]}; do echo $logdir/${u}_at_fsf.org/$log_today; done) 2>/dev/null \
+ | awk '$3 != "me:" {print $3; fflush()}' | sed -u 's/^/pm /;s/@.*//' || [[ $? == 124 ]] &
+
+ timeout --foreground $secs_till_midnight tail -n0 -qF \
+ $logdir/rooms/*/$log_today 2>/dev/null \
+ | awk '$3 != "iank:"' | grep -i '\biank\b' | awk '{print $3; fflush()}' | sed 's/^/room /;s/@.*//' || [[ $? == 124 ]]
+
+ sleep 1
+
+done
prof
prof-remote
prof-backup
+ prof-tail
+ prof-notify
)
for f in /b/log-quiet/*; do
--- /dev/null
+#!/bin/bash
+set -e; . /usr/local/lib/err; set +e
+
+mpv --speed=1 --no-terminal --vo=null --volume=90 /a/bin/data/d20.wav
--- /dev/null
+[play_sound]
+ summary = "*"
+ script = /b/ds/sound-alert
+
+
+# default light blue is too light
+[urgency_normal]
+ background = "#335EA8"
--- /dev/null
+[Unit]
+Description=profanity
+# background: i originally started profanity as a system service after
+# networking-online.target but strangely, it had a hidden lock on /p
+# preventing it from unmounting, and the only thing in /p i can see it
+# using is gpg. I could try to get this to run after the last target,
+# which is default.target, but all I can find documented on how to do
+# this is to do this strange unexplained thing of making a new target,
+# aliasing it to the default target and also make it
+# After=default.target. I figured this probably works and is simpler.
+After=gpg-agent.service
+
+[Service]
+# bash is required to get colors working
+ExecStart=/usr/bin/screen -S profanity -Dm /bin/bash -c profanity
+
+[Install]
+WantedBy=default.target