chrbind() {
local d
- for d in dev proc sys; do
+ # dev/pts needed for pacman signature check
+ for d in dev proc sys dev/pts; do
[[ -d $d ]]
if ! mountpoint $d &>/dev/null; then
- mount -o bind /$d $d
+ s mount -o bind /$d $d
fi
done
}
}
+# note: this is incomplete and untested.
+# https://wiki.archlinux.org/index.php/Install_Arch_Linux_from_existing_Linux#Creating_a_chroot
+mkarchchroot() {
+ local tarball mirror
+ mirror=https://mirrors.edge.kernel.org/archlinux/iso/latest/
+ tarball=$(curl -s $mirror | sed -nr 's/.*"(archlinux-bootstrap-.*-x86_64.tar.gz)".*/\1/p')
+ wget -O /tmp/arch.tar.gz https://mirrors.edge.kernel.org/archlinux/iso/latest/$tarball
+ s mkdir -p /nocow/schroot/arch
+ cd _/nocow/schroot/arch
+ s sed -i '/## United States/,/^$/s,^#,,' etc/pacman.d/mirrorlist
+ # error: could not determine cachedir mount point /var/cache/pacman/pkg
+ s sed -i /^CheckSpace/d etc/pacman.conf
+ chroot . /bin/bash -s <<'EOF'
+pacman-key --init
+pacman-key --populate archlinux
+pacman -Syyu
+EOF
+ # example of building an aur package:
+ # pacman -Sy base-devel wget
+ # useradd -m iank
+ # f=$target/etc/sudoers
+ # line='iank ALL=(ALL) NOPASSWD: ALL'
+ # if [[ ! -e $f ]] || ! grep -xF "$line" $f; then
+ # echo "$line" >> $f
+ # fi
+ # su iank
+ # wget https://aur.archlinux.org/cgit/aur.git/snapshot/anbox-image-gapps.tar.gz
+ # tar xzf anbox-image-gapps.tar.gz
+ # cd anbox-image-gapps
+ # makepkg -s
+}
+
+
# clock back in to timetrack from last entry
tback() {
sqlite3 /p/.timetrap.db "update entries set end = NULL where id = (select max(id) from entries);"
}
bum() {
- local host=$1
+ local cur host
+ host=$1
(( $# == 1 )) || return 1
- sshfs $host:/bu/md /bu/mnt
+ cur="$(awk '$2 == "/bu/mnt" {print $1}' /proc/mounts)"
+ if [[ $cur ]]; then
+ if [[ $cur != "$host:/bu/md" ]]; then
+ fusermount -u /bu/mnt
+ fi
+ else
+ sshfs $host:/bu/md /bu/mnt
+ fi
ser start exim4
}
bu() {
cmd=$(which $1)
fi
journalctl -qn2 -f -u "$cmd_name" &
- # 1st guess to avoid missing some initial lines.
- sleep .5
+ # Guess of time needed to avoid missing initial lines.
+ # .5 was not reliable.
+ sleep 1
# We kill this in prompt-command for the case that we ctrl-c the
# systemd-cat. i dont know any way to trap ctrl-c and still run the
# normal action for it. There might be a way, unsure.
path-add --end $HOME/.cargo/bin
if type -P rg &>/dev/null; then
- rg() { command rg -i -M 200 --no-ignore "$@"; }
+ rg() { command rg -i -M 300 --no-ignore "$@"; }
complete -r rg
else
alias rg=grr
kw)
at_work=true
;;&
- x2|x3)
+ x2|x3|sy)
if ping -q -c1 -w1 hal.office.fsf.org \
&& ip n show 192.168.0.26 | grep . &>/dev/null; then
at_work=true
fi
;;&
- kw|x2|x3)
+ kw|x2|x3|sy)
if $at_work && ping -q -c1 -w1 iank.vpn2.office.fsf.org &>/dev/null; then
home=iank.vpn2.office.fsf.org
else
kw)
targets+=($home x3)
;;
- x2|x3)
+ x2|x3|sy)
targets+=($home kw.office.fsf.org)
;;
kd)
set -eE -o pipefail
trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
+
+[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@"
# inspired from
# https://github.com/kdave/btrfsmaintenance
e() { echo "cron: $*"; "$@"; }
check-idle() {
- export DISPLAY=:0
- # 3 hours, assume a movie might run that long.
- idle_limit=$((1000 * 60 * 60 * 3))
- idle_time=$idle_limit
- id=999
- while id $((++id)) &>/dev/null; do
- new_idle_time=$(sudo -u \#$id xprintidle 2>/dev/null) ||:
- if [[ $new_idle_time && $new_idle_time -lt $idle_time ]]; then
- idle_time=$new_idle_time
- fi
- done
- if (( idle_time < idle_limit )); then
- idle=false
- else
- idle=true
+ export DISPLAY=:0
+ # 3 hours, assume a movie might run that long.
+ idle_limit=$((1000 * 60 * 60 * 3))
+ idle_time=$idle_limit
+ id=999
+ while id $((++id)) &>/dev/null; do
+ new_idle_time=$(sudo -u \#$id xprintidle 2>/dev/null) ||:
+ if [[ $new_idle_time && $new_idle_time -lt $idle_time ]]; then
+ idle_time=$new_idle_time
fi
+ done
+ if (( idle_time < idle_limit )); then
+ idle=false
+ else
+ idle=true
+ fi
}
-if [[ $1 == check ]]; then
- check=true
-else
- check=false
+force=false
+check=false
+if [[ $1 ]]; then
+ case $1 in
+ check)
+ check=true
+ ;;
+ force)
+ force=true
+ ;;
+ *)
+ echo "$0: error: unexpected arg" >&2
+ exit 1
+ ;;
+ esac
fi
-check-idle
+idle=true
+if ! $force; then
+ check-idle
+fi
fnd="findmnt --types btrfs --noheading"
for x in $($fnd --output "SOURCE" --nofsroot | sort -u); do
- mnt=$($fnd --output "TARGET" --first-only --source $x)
- [[ $mnt ]] || continue
+ mnt=$($fnd --output "TARGET" --first-only --source $x)
+ [[ $mnt ]] || continue
- if ! $idle; then
- btrfs scrub cancel $mnt &>/dev/null ||:
- continue
- fi
- if $check; then
- continue
- fi
+ if ! $idle; then
+ btrfs scrub cancel $mnt &>/dev/null ||:
+ continue
+ fi
+ if $check; then
+ continue
+ fi
- # for comparing before and after balance.
- # the log is already fairly verbose, so commented.
- # e btrfs filesystem df $mnt
- # e df -H $mnt
- if btrfs filesystem df $mnt | grep -q "Data+Metadata"; then
- for usage in $dusage; do
- e btrfs balance start -dusage=$usage -musage=$usage $mnt
- done
- else
- e btrfs balance start -dusage=0 $mnt
- for usage in $dusage; do
- e btrfs balance start -dusage=$usage $mnt
- done
- e btrfs balance start -musage=0 $mnt
- for usage in $musage; do
- e btrfs balance start -musage=$usage $mnt
- done
- fi
- # e btrfs filesystem df $mnt
- # e df -H $mnt
- date=$(
- btrfs scrub status $mnt | \
- sed -rn 's/^\s*scrub started at (.*) and finished.*/\1/p'
- )
- if [[ $date ]]; then
- date=$(date --date="$date" +%s)
- # if date is sooner than 90 days ago
- # the wiki recommends 30 days or so, but
- # it makes the comp lag like shit for a day,
- # so I'm going with 90 days.
- if (( date > $(date +%s) - 60*60*24*30 )); then
- echo "cron: skiping scrub of $mnt"
- continue
- fi
+ # for comparing before and after balance.
+ # the log is already fairly verbose, so commented.
+ # e btrfs filesystem df $mnt
+ # e df -H $mnt
+ if btrfs filesystem df $mnt | grep -q "Data+Metadata"; then
+ for usage in $dusage; do
+ e btrfs balance start -dusage=$usage -musage=$usage $mnt
+ done
+ else
+ e btrfs balance start -dusage=0 $mnt
+ for usage in $dusage; do
+ e btrfs balance start -dusage=$usage $mnt
+ done
+ e btrfs balance start -musage=0 $mnt
+ for usage in $musage; do
+ e btrfs balance start -musage=$usage $mnt
+ done
+ fi
+ # e btrfs filesystem df $mnt
+ # e df -H $mnt
+ date=$(
+ btrfs scrub status $mnt | \
+ sed -rn 's/^\s*scrub started at (.*) and finished.*/\1/p'
+ )
+ if [[ $date ]]; then
+ date=$(date --date="$date" +%s)
+ # if date is sooner than 90 days ago
+ # the wiki recommends 30 days or so, but
+ # it makes the comp lag like shit for a day,
+ # so I'm going with 90 days.
+ if (( date > $(date +%s) - 60*60*24*30 )); then
+ echo "cron: skiping scrub of $mnt"
+ continue
fi
- e btrfs scrub start -Bd $mnt
+ fi
+ e btrfs scrub start -Bd $mnt
done
######## fix evbug bug ######
case $(debian-codename-compat) in
- xenial|bionic)
+ xenial|bionic|focal)
# noticed in flidas. dunno if it affects any others
#https://bugs.launchpad.net/ubuntu/+source/module-init-tools/+bug/240553
#https://wiki.debian.org/KernelModuleBlacklisting
Package: *
Pin: release n=bionic,o=Ubuntu
Pin-Priority: -100
+Package: firefox
+Pin: release n=bionic,o=Ubuntu
+Pin-Priority: 500
EOF
sd /etc/apt/preferences.d/etiona-sa <<'EOF'
fi
;;
esac
+
+# 2020-03-03 old file
+rm -fv /etc/apt/preferences.d/radicale
######### end universal pinned packages ######
##### begin automatic upgrades (after checkrestart has been installed) ####
# note: to see when it was last run,
# ser list-timers
+case $HOSTNAME in
+ kd)
+ sgo btrbkrust.timer
+ ;;
+esac
end_msg <<'EOF'
In mate settings settings, change scrolling to two-finger,
exit 1
fi
-rlu $host /a/bin/distro-setup/
+bbk -t $host
ssh $host /a/bin/distro-setup/distro-begin
ssh $host /a/bin/distro-setup/distro-end
+++ /dev/null
-Package: firefox
-Pin: release a=unstable
-Pin-Priority: 500
tmp=${tmp#:}
PATH=$tmp
-rm -f {/p/c/firefox-main-profile,/p/c/firefox-main-profile,/p/c/firefox-vpn2-profile,/mnt/z/firefox-vpn-profile}/compatibility.ini
+# -allow-downgrade good enough?
+#rm -f {/p/c/firefox-main-profile,/p/c/firefox-main-profile,/p/c/firefox-vpn2-profile,/mnt/z/firefox-vpn-profile}/compatibility.ini
-if type -P abrowser &>/dev/null; then
- abrowser "$@"
+# abrowser is 2 releases behind, so prefer firefox for now
+if type -P firefox &>/dev/null; then
+ firefox -allow-downgrade "$@"
else
- firefox "$@"
+ abrowser -allow-downgrade "$@"
fi
# python3-autopep8 is nice, etiona only has python2 version, not bothering
# to setup a conditional or pin to nabia.
+# metastore is for /p/c commit hook to store user/perms
+
p3=(
at
mdadm
meld
memtester
+ metastore
mhonarc
moreutils
mps-youtube
qemu-user-static
qrencode
readline-doc
+ rename
reportbug
rfkill
rng-tools