summaryrefslogtreecommitdiff
path: root/archive
diff options
context:
space:
mode:
Diffstat (limited to 'archive')
-rw-r--r--archive/.bash_defns152
-rwxr-xr-xarchive/.shenv107
-rwxr-xr-xarchive/bin/bedtime17
-rwxr-xr-xarchive/bin/debian-ftp-master158
-rwxr-xr-xarchive/bin/develacc-please39
-rwxr-xr-xarchive/bin/develacc-second-stage26
-rwxr-xr-xarchive/bin/rt25
-rwxr-xr-xarchive/bin/usbskelhere25
8 files changed, 549 insertions, 0 deletions
diff --git a/archive/.bash_defns b/archive/.bash_defns
new file mode 100644
index 00000000..2ce59444
--- /dev/null
+++ b/archive/.bash_defns
@@ -0,0 +1,152 @@
+# This file was for core aliases & functions which we wanted available in
+# shell commands run from Emacs. However, nowadays I mostly use
+# Eshell, so I moved these back to .shinit. The following code was in
+# init.el, and .bashrc *sourced* .bash_defns (BASH_ENV *not* set there):
+#
+# (when-let ((bash (executable-find "bash")))
+# (setq shell-file-name "bash")
+# (setenv "SHELL" bash)
+# (setenv "BASH_ENV" (expand-file-name "~/.bash_defns")))
+
+shopt -s expand_aliases
+
+# --- aliases
+
+alias soffice-pdf="soffice --headless --convert-to pdf"
+alias new-login-shell="exec su -l $USER" # get new UNIX group without relog
+alias b="bts --mbox show"
+
+# alias develacc='sudo machinectl shell spw@develacc \
+# $(sudo enter-develacc /bin/sh -c "getent passwd spw | cut -d: -f7")'
+# alias develaccr='sudo machinectl shell root@develacc \
+# $(sudo enter-develacc /bin/sh -c "getent passwd root | cut -d: -f7")'
+
+alias whitenoise="echo -en \"\033]0;whitenoise\a\";\
+ cvlc --quiet --loop ~/annex/media/sounds/R*.ogg"
+
+alias host-suite-build-deps='mk-build-deps -ir -s sudo -t \
+ "apt-get --no-install-recommends"'
+alias sid-build-deps='mk-build-deps -ir -s sudo -t \
+ "apt-get -o Debug::pkgProblemResolver=yes -t sid --no-install-recommends"'
+alias bts-policy="bts user debian-policy@packages.debian.org \
+ , package debian-policy , "
+alias dak-rdeps="ssh mirror.ftp-master.debian.org dak rm -Rn"
+alias afsid="apt-file --filter-suites unstable"
+alias dinstall="curl https://ftp-master.debian.org/dinstall.status;echo -n 'Right now: ';date -u '+%a %b %d %T %Z %Y (%s)'"
+# use with care, in order for this to actually provide a security advantage
+alias update-debian-known-hosts="scp master.debian.org:/etc/ssh/ssh_known_hosts ~/src/dotfiles/.ssh/known_hosts_debian"
+# from dgit-user(7), this pushes a non-native package through sbuild
+# without an orig.tar for the version in the first changelog entry.
+# Useful for sbuilding an unreleased version of a package I maintain
+# upstream
+alias sbuild-prerelease="sbuild --dpkg-source-opts='-Zgzip -z1 --format=1.0 -sn' --no-run-lintian"
+
+# alias does not call `git develacc` because we want manual
+# verification of what is to be pushed (i.e. `git diff
+# master..develacc/develacc-iris` to check patch queue is sane)
+alias push-develacc-dotfiles-branch="git push \
+ -f origin develacc/develacc-$(hostname -s):develacc-$(hostname -s)"
+
+alias spin-this-host-now='(cd /usr/local/propellor && sudo ./propellor)'
+
+# --- more powerful aliases built with shell functions
+
+secs () {
+ for i in $(seq $1 -1 1); do
+ echo $i
+ sleep 1
+ done
+ echo 0
+}
+
+package-plan-unpack () {
+ ~/src/dotfiles/scripts/debian/package-plan-unpack "$1"; cd "/tmp/$1"
+}
+
+# install package(s) and immediately mark as auto installed, so it
+# will get cleaned up by the next autoclean.
+# --no-install-recommends is needed as otherwise packages are manually
+# installed beyond those specified on the command line
+install-as-auto () {
+ if [[ $EUID -ne 0 ]]; then
+ sudo apt-get --no-install-recommends install "$@"
+ sudo apt-mark auto "$@"
+ else
+ apt-get --no-install-recommends install "$@"
+ apt-mark auto "$@"
+ fi
+}
+
+# PDF word count
+pdfwords () {
+ pdftotext "$1" - | wc -w
+}
+
+# also see soffice-pdf alias above
+soffice-pdf-all () {
+ for f in *.doc *.docx; do
+ soffice --headless --convert-to pdf "$f"
+ done
+}
+
+# Debian archive processing logs
+alias tail-dak="ssh ftp-master.debian.org tail -F \
+ /srv/ftp-master.debian.org/log/current"
+alias tail-queued="ssh ssh.upload.debian.org tail -F \
+ /srv/upload.debian.org/queued/run/log"
+grep-dak () {
+ ssh ftp-master.debian.org grep "$@" /srv/ftp-master.debian.org/log/current
+}
+grep-queued () {
+ ssh ssh.upload.debian.org grep "$@" /srv/upload.debian.org/queued/run/log
+}
+
+# sometimes a remote SSH session cannot get at my forwarded SSH agent
+# because an unwanted instance of gpg-agent running on the remote host
+# gets in the way. this is a way to kill off that unwanted agent. we
+# also need to restart the multiplexed SSH connection to get agent
+# forwarding working again. I think this problem is mostly caused by
+# the fact that I use gnupg as my SSH agent
+kill-remote-gpg () {
+ ssh "$1" 'rm -f $XDG_RUNTIME_DIR/gnupg/*'
+ ssh -O exit "$1"
+}
+
+# build debs from a Linux kernel source tree *without* calling `make clean`.
+#
+# The -dbg deb takes some time to build. To get rid of it when it's
+# not needed: scripts/config --disable DEBUG_INFO
+bindeb-pkg () {
+ ver="$(make kernelversion)"
+ date="$(date +%Y%m%d+%H%M)"
+ arch="$(dpkg --print-architecture)"
+ make -j$((2 * $(nproc))) bindeb-pkg \
+ LOCALVERSION=-spw \
+ KDEB_PKGVERSION=$ver-$date \
+ "$@"
+ echo "sudo apt-get install \
+../linux-{image,headers}-$ver-spw_$ver-${date}_$arch.deb"
+}
+
+# --- host-specific aliases/functions
+
+# not ftp-master.debian.org
+
+# this is useful for processing removal requests
+# (credits to Mark Wooding)
+#
+# alternative, by me, but involves spawning another process or two:
+#
+# command -v dak >/dev/null \
+# || alias dak="perl -MString::ShellQuote \
+# -we'system qw(ssh -t ftp-master.debian.org dak), shell_quote @ARGV'"
+if ! command -v dak >/dev/null; then
+ dak () {
+ local i
+ local c=
+ for i; do # implicit "in $@"
+ c="$c '${i/\'/\'\\\'\'}'"
+ done
+ ssh -t ftp-master.debian.org dak "$c"
+ }
+fi
diff --git a/archive/.shenv b/archive/.shenv
new file mode 100755
index 00000000..d461cc84
--- /dev/null
+++ b/archive/.shenv
@@ -0,0 +1,107 @@
+#!/bin/sh
+
+# Environment variables for X and all text-mode shells: bash, Xsession
+# and scripts run by cron all source this. So POSIX only.
+
+# We have calls to `which` which we expect to fail
+set +e
+
+# ---- choose editor depending on what's available
+
+if [ "$DESKTOP_SESSION" = "i3" ] \
+ || [ "$DESKTOP_SESSION" = "xfce" ] \
+ || [ "XDG_CURRENT_DESKTOP" = "sway" ]; then
+ ec_opt="-c"
+else
+ ec_opt="-t"
+fi
+
+# Either GNU Emacs, or UNIX vi -- lightweight Emacs alternatives like mg and
+# zile are so rarely installed, so let's have a constant fallback which is
+# almost certainly available and which I can use well enough.
+#
+# Rely on my ~/src/dotfiles/bin/emacsclient wrapper to start up an Emacs
+# daemon: don't bother setting ALTERNATE_EDITOR. Check that there's an Emacs
+# on (as yet unmodified) PATH, else that wrapper might fail.
+if command -v emacs >/dev/null; then
+ EDITOR="emacsclient $ec_opt"
+else
+ EDITOR="vi"
+fi
+unset ec_opt
+export EDITOR
+VISUAL="$EDITOR"
+export VISUAL
+
+# ---- set $PATH
+
+# this function prepends $addition to $PATH iff $addition isn't
+# already in $PATH and $addition is a directory
+maybe_add_to_path ()
+{
+ if ! echo $PATH | grep -q "$addition"; then
+ if [ -d "$addition" ]; then
+ PATH="$addition:$PATH"
+ fi
+ fi
+}
+
+addition="/sbin"; maybe_add_to_path
+addition="/usr/sbin"; maybe_add_to_path
+addition="/usr/local/bin"; maybe_add_to_path
+addition="/usr/pkg/bin"; maybe_add_to_path
+addition="$HOME/local/pkg/bin"; maybe_add_to_path
+addition="$HOME/local/pkg/sbin"; maybe_add_to_path
+addition="$HOME/src/dotfiles/bin"; maybe_add_to_path
+addition="$HOME/local/bin"; maybe_add_to_path
+addition="$HOME/.cabal/bin"; maybe_add_to_path
+addition="$HOME/.local/bin"; maybe_add_to_path
+addition="/meta/s/spw/local/src/git-annex.linux"; maybe_add_to_path
+unset addition
+
+export PATH
+
+# ---- package management by Nix: add to $PATH once more
+
+# # crude heuristic to determine if it's already been added
+# if ! echo $PATH | grep -q "$HOME/.nix-profile/bin"; then
+# if [ -e "/etc/profile.d/nix.sh" ]; then
+# . /etc/profile.d/nix.sh
+# fi
+# fi
+
+# ---- set language (snippet from joeyh's home-etc.git repo)
+
+# TODO: according to <https://wiki.debian.org/Locale>, I ought not to
+# be setting LC_ALL. Instead I could set most of LC_* to en_GB.UTF-8,
+# and some e.g. LC_PAPER to en_US.UTF-8.
+
+# disabled: propellor setting it system-wide on my machines and that's
+# enough
+
+# case " $(echo $(locale -a)) " in
+# *\ en_GB.utf8\ *) LANG=en_GB.utf8 ;;
+# *\ en_GB.UTF-8\ *) LANG=en_GB.UTF-8 ;;
+# *\ C.UTF-8\ *) LANG=C.UTF-8 ;;
+# *\ C.utf8\ *) LANG=C.utf8 ;;
+# *) unset LANG ;;
+# esac
+
+# LC_ALL=$LANG
+# export LC_ALL
+# export LANG
+
+# ---- further preferences
+
+# LD_RUN_PATH="$HOME/local/lib/"
+# export LD_RUN_PATH
+# LD_LIBRARY_PATH="$HOME/local/lib/"
+# export LD_LIBRARY_PATH
+
+# "Setting the monitor port to 0 turns the monitoring function off,
+# and autossh will only restart ssh upon ssh's exit."
+#
+# We rely on ServerAliveInterval and ServerAliveCountMax set in ~/.ssh/config
+AUTOSSH_PORT=0
+export AUTOSSH_PORT
+
diff --git a/archive/bin/bedtime b/archive/bin/bedtime
new file mode 100755
index 00000000..d0fda52f
--- /dev/null
+++ b/archive/bin/bedtime
@@ -0,0 +1,17 @@
+#!/bin/bash
+
+. $HOME/.shenv
+
+# someday, make this work instead:
+# <http://joeyh.name/blog/entry/a_programmable_alarm_clock_using_systemd/>
+
+(($EUID == 0)) || exec sudo "$0" "$@"
+
+WHEN="${1:-tomorrow 6am}"
+CMD="/home/spwhitton/bin/goodmorning"
+
+when=$(date +%s -d "$WHEN")
+
+loginctl lock-sessions
+systemd-inhibit --what=handle-lid-switch --why=goodmorning sh -c \
+ "rtcwake -m mem -t $when && /bin/su spwhitton -c $CMD"
diff --git a/archive/bin/debian-ftp-master b/archive/bin/debian-ftp-master
new file mode 100755
index 00000000..e410c021
--- /dev/null
+++ b/archive/bin/debian-ftp-master
@@ -0,0 +1,158 @@
+#!/bin/bash
+
+# debian-ftp-master -- set up some windows for doing work on Debian's ftp-master
+
+# Copyright (C) 2019 Sean Whitton
+#
+# GPL-3 or later
+
+set -e
+
+. $HOME/.shenv
+
+# # require irssi is already raiseable, as starting it is interactive in
+# # a way we can't easily wait for
+# if ! wmctrl -l | grep -q "irssi"; then
+# zenity --error --no-wrap --text="Please attach to irssi first."
+# exit 1
+# fi
+
+# # kill off any broken session (e.g. lost WiFi)
+# wmctrl -c "ftp-master session cleanup" ||:
+# wmctrl -c "ftp-master dak command session" ||:
+# wmctrl -c "ftp-master GNU mc session" ||:
+# wmctrl -c "*NEW notes*" ||:
+# # wait, in case xfce4-terminal prompted the user
+# while wmctrl -l | grep -q -E "ftp-master (session cleanup|dak command session|GNU mc session)"; do
+# sleep 1
+# done
+
+# # If there are no other Emacs frames open, the title of the frame will
+# # be emacs@$HOST rather than *NEW notes*, which means we can't control
+# # it. So, ensure one is open
+# if ! wmctrl -lx | grep -q "emacs.Emacs"; then
+# emacsclient -c -a '' -n -e '(switch-to-buffer "*scratch*")'
+# fi
+
+# first establish a control socket, so that the two interactive ssh
+# connections don't race to do this and one of them disables multiplexing
+ssh -fN ftp-master.debian.org
+
+# start Emacs on ftp-master
+ssh ftp-master.debian.org pgrep -u spwhitton emacs \
+ || ssh ftp-master.debian.org emacs --daemon &
+
+# # open zenity dialog first; i3 will not float it
+# zenity --question --no-wrap --no-markup \
+# --title="ftp-master session cleanup" \
+# --text="Kill tmux & Emacs sessions on ftp-master?" &
+# zenity_pid=$!
+# until wmctrl -l | grep -q "ftp-master session cleanup"; do
+# sleep 0.3
+# done
+
+monitors="$(xrandr -q | grep ' connected' | wc -l)"
+
+if ! wmctrl -l | grep -q "ftp-master dak command session"; then
+ first="$(i3-fresh-workspace)"
+
+ xfce4-terminal -x ssh-and-tmux \
+ ftp-master.debian.org dak "ftp-master dak command session"
+ until wmctrl -l | grep -q "ftp-master dak command session"; do
+ sleep 0.3
+ done
+ wmctrl -R "ftp-master dak command session"
+
+ # if we have the `layout tabbed` above, before any windows are opened,
+ # the workspace ends up with a tabbed container inside a tabbed
+ # container on buster's i3 (but not stretch's)
+ i3-msg layout tabbed
+
+ xfce4-terminal -x ssh-and-tmux \
+ ftp-master.debian.org mc "ftp-master GNU mc session"
+ until wmctrl -l | grep -q "ftp-master GNU mc session"; do
+ sleep 0.3
+ done
+ wmctrl -R "ftp-master GNU mc session"
+
+ emacsclient -c -a '' -n -e '(progn (switch-to-buffer "*NEW notes*") (text-mode))'
+ until wmctrl -l | grep -q "*NEW notes*"; do
+ sleep 0.3
+ done
+ wmctrl -R "*NEW notes*"
+
+ # Now we've the windows opened, arrange them. For some reason, in
+ # order to have the resize commands take effect, there has to be a
+ # pause before each resize command is issued, i.e. separate i3-msg
+ # calls separated by calls to sleep
+ monwidth="$(xdpyinfo | awk '/dimensions/{print $2}' | cut -dx -f1)"
+ if [ $monitors -gt 1 ] ; then
+ second="$(i3-fresh-workspace)"
+ i3-msg workspace "$first"
+ # ensure mc window is on primary output, since I spend more time
+ # in it (I think this is sensible!)
+ i3-msg move workspace to output primary
+ # move the dak control window
+ i3-msg focus left, focus left, move to workspace "$second"
+ # split windows
+ i3-msg move up
+ sleep 0.2
+ i3-msg resize set height 70 ppt
+ # machine-specific: move workspace 9 to the secondary monitor, if
+ # we know what that's called. Otherwise, user can just manually
+ # move workspace 9 to the correct monitor right after executing
+ # this script; workspace 7 will be left displayed on the primary
+ # monitor
+ if [ "$(hostname -f)" = "iris.silentflame.com" ]; then
+ i3-msg workspace "$second"
+ i3-msg move workspace to output LVDS-1
+ i3-msg workspace "$second"
+ else # no machine-specific config
+ # ensure dak control window focused
+ i3-msg workspace "$first"
+ fi
+ elif [ $monwidth -ge 1920 ]; then
+ # three column split (i.e. two mc columns and dak column) should
+ # work on a monitor this big (after some tweaking of mc's display
+ # settings)
+ i3-msg move down, focus up, focus left, move right, move right, move right
+ sleep 0.2
+ i3-msg resize set width 35 ppt, focus left
+ sleep 0.2
+ i3-msg resize set height 65 ppt, focus right
+ else
+ # small screen view
+ i3-msg focus left, split v, focus right, move left
+ sleep 0.2
+ i3-msg resize set height 30 ppt, focus up, focus left
+ fi
+else
+ wmctrl -a "ftp-master dak command session"
+ if [ "$(hostname -f)" = "iris.silentflame.com" ] \
+ && [ $monitors -gt 1 ]; then
+ i3-msg move workspace to output LVDS-1
+ wmctrl -a "ftp-master GNU mc session"
+ fi
+ i3-msg move workspace to output primary
+fi
+
+# ssh athena tmux send-keys -t irssi DOWN
+# ssh athena tmux send-keys -t irssi "\"/join -OFTC #debian-ftp-private\"" ENTER
+# # ssh athena tmux send-keys -t irssi ! l o c k SPACE N E W
+# # ssh athena tmux send-keys -t irssi LEFT LEFT LEFT LEFT LEFT LEFT LEFT LEFT
+# i3-msg '[class="^Xfce4-terminal$" title="^irssi$"]' scratchpad show
+
+# # finally, get a little more space in the mc session
+# ssh ftp-master.debian.org tmux set -t mc status off
+
+# # clean everything up, per DMUP
+# wait $zenity_pid
+# zenity_exit=$?
+# wmctrl -c "*NEW notes*" ||:
+# if [ $zenity_exit = 0 ]; then
+# ssh ftp-master.debian.org tmux kill-server
+# ssh ftp-master.debian.org pkill -u spwhitton emacs
+# sleep 10
+# # --title needs to be different from the above so i3 floats the window
+# ssh ftp-master.debian.org pgrep -u spwhitton emacs && zenity --error --no-wrap --title="Session cleanup error" --text="Processes still running on ftp-master!"
+# fi
diff --git a/archive/bin/develacc-please b/archive/bin/develacc-please
new file mode 100755
index 00000000..63d86ecc
--- /dev/null
+++ b/archive/bin/develacc-please
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+# Boot or resume develacc and open a VNC viewer. Suspend develacc,
+# mainly to save battery power, when the viewer is closed.
+#
+# This is mainly for when I want to work in develacc for a while, full
+# screen, almost as if my laptop was running sid.
+#
+# For work where I expect to be going back and forth between the VM
+# and the bare metal host or other VMs, it might be better to access
+# the VM via a normal, non-fullscreened virt-manager window rather
+# than full screen virt-viewer. Similarly if I have a large monitor
+# available, it might be more convenient not to have the VM viewer
+# fullscreened
+
+set -e
+
+. $HOME/.shenv
+
+VIRSH="virsh --connect qemu:///system"
+develacc="develacc.$(hostname -f)"
+
+if wmctrl -l | grep -q "$develacc"; then
+ wmctrl -a "$develacc"
+else
+ if $VIRSH list | grep -q "$develacc .*paused"; then
+ $VIRSH resume $develacc
+ elif ! $VIRSH list | grep -q $develacc; then
+ $VIRSH start $develacc
+ fi
+
+ virt-viewer -c qemu:///system --hotkeys=release-cursor=ctrl+alt \
+ -a -f -r $develacc # \
+ # && $VIRSH suspend $develacc &
+ until wmctrl -l | grep -q "$develacc"; do
+ sleep 0.3
+ done
+ i3-fresh-workspace --take-along
+fi
diff --git a/archive/bin/develacc-second-stage b/archive/bin/develacc-second-stage
new file mode 100755
index 00000000..1d95b4e0
--- /dev/null
+++ b/archive/bin/develacc-second-stage
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+set -e
+
+. $HOME/.shenv
+
+# ---- configuration
+
+FOXIT="$HOME/lib/annex/big/software/FoxitReader.enu.setup.2.4.4.0911.x64.run.tar.gz"
+DEVELACC="$HOME/local/develacc"
+
+# ---- start develacc
+
+sudo virsh list | grep -q "develacc.$(hostname -f) .*running" \
+ || sudo virsh start develacc.$(hostname -f)
+
+# ---- install FoxitReader
+
+mkdir -p "$DEVELACC/tmp"
+cp -L "$FOXIT" "$DEVELACC/tmp"
+( cd "$DEVELACC/tmp" && tar axf $(basename $FOXIT))
+ssh root@develacc "/home/spwhitton/tmp/FoxitReader.enu.setup.*"
+
+# ---- clone dionysus annex & pair with home directory copy
+
+# TODO
diff --git a/archive/bin/rt b/archive/bin/rt
new file mode 100755
index 00000000..66c8a864
--- /dev/null
+++ b/archive/bin/rt
@@ -0,0 +1,25 @@
+#!/bin/bash
+. $HOME/.shenv
+
+# first check that there exist the dirs we need
+
+if [ ! -e "$HOME/local/rt/watch" -o ! -d "$HOME/local/rt/session" -o ! -d "$HOME/local/rt/incomplete" -o ! -e "$HOME/local/rt/complete" ]; then
+ echo "I was asked to start rtorrent, but one of the dirs in ~/local/rt is missing" >&2
+ echo "(myrepos fixups should do it)" >&2
+ exit 1
+fi
+
+# start rtorrent under dtach if it's not running
+
+if ! pgrep -u $LOGNAME rtorrent >/dev/null; then
+ rm -f $HOME/local/rt/session/dtach.socket
+ TERM=xterm nice -n 19 dtach -n $HOME/local/rt/session/dtach.socket rtorrent
+fi
+
+# if we're not at a dumb terminal (so this script can be shoved in a
+# crontab), try to attach what we (maybe) just made
+
+# this is a bashism
+if [ -t 1 ]; then
+ dtach -a $HOME/local/rt/session/dtach.socket
+fi
diff --git a/archive/bin/usbskelhere b/archive/bin/usbskelhere
new file mode 100755
index 00000000..d242e482
--- /dev/null
+++ b/archive/bin/usbskelhere
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+. $HOME/.shenv
+. $HOME/src/dotfiles/lib-src/tputfs.sh
+
+skelhere ()
+{
+ usbpubkeys
+ mkdir -p doc bin lib
+ cp -RLf ~/lib/annex/big/skel/usb/* .
+ cp ~/src/dotfiles/bin/{apple-setup.sh,dasl-setup.bat} bin
+ cp -L ~/lib/pro.terminal lib
+ cp -L "$HOME/lib/annex/doc/sounds/Rainy Mood pomodoro.mp3" lib
+ zip -j lib/spwhitton.zip lib/*.reg bin/*
+ # status now you might want to clone ~/lib/dionysus\; see comproc.org
+}
+
+while true; do
+ read -p "This might overwrite stuff in $(pwd). Is that okay? " yn
+ case $yn in
+ [Yy]* ) skelhere; break;;
+ [Nn]* ) exit;;
+ * ) echo "Please answer yes or no.";;
+ esac
+done