From: Ian Kelling Date: Thu, 4 Mar 2021 18:22:26 +0000 (-0500) Subject: various fixes X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=b9d3e5ef77d8d1f3cdd9bbeee55c3eddbe39c698;p=distro-setup various fixes --- diff --git a/brc b/brc index c9078ee..f7d64f4 100644 --- a/brc +++ b/brc @@ -398,10 +398,11 @@ ccomp grep ccat 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 } diff --git a/brc2 b/brc2 index 52e01d8..169b847 100644 --- a/brc2 +++ b/brc2 @@ -135,15 +135,56 @@ EOF } +# 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() { @@ -295,8 +336,9 @@ jrun() { # journal run. run args, log to journal, tail and grep the journal. 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. @@ -1555,7 +1597,7 @@ path-add --end ~/.npm-global 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 diff --git a/btrbk-run b/btrbk-run index 9aef6e0..74deab7 100644 --- a/btrbk-run +++ b/btrbk-run @@ -169,13 +169,13 @@ if [[ ! -v targets && ! $source ]]; then 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 @@ -185,7 +185,7 @@ if [[ ! -v targets && ! $source ]]; then kw) targets+=($home x3) ;; - x2|x3) + x2|x3|sy) targets+=($home kw.office.fsf.org) ;; kd) diff --git a/btrfsmaint b/btrfsmaint index c410b7b..06570b3 100755 --- a/btrfsmaint +++ b/btrfsmaint @@ -2,6 +2,8 @@ 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 @@ -15,79 +17,93 @@ musage="1 5 10 20 30" 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 diff --git a/distro-begin b/distro-begin index e4958f5..df59a3e 100755 --- a/distro-begin +++ b/distro-begin @@ -411,7 +411,7 @@ pi ${p1[@]} ######## 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 diff --git a/distro-end b/distro-end index 5c802ca..73d7a0a 100755 --- a/distro-end +++ b/distro-end @@ -428,6 +428,9 @@ EOF 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' @@ -443,6 +446,9 @@ 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) #### @@ -1610,6 +1616,11 @@ fi # 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, diff --git a/dsremote b/dsremote index 13a5176..2176740 100755 --- a/dsremote +++ b/dsremote @@ -25,6 +25,6 @@ if [[ ! $host || $host == -h ]]; then 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 diff --git a/filesystem/etc/apt/preferences.d/radicale b/filesystem/etc/apt/preferences.d/radicale deleted file mode 100644 index 073b78a..0000000 --- a/filesystem/etc/apt/preferences.d/radicale +++ /dev/null @@ -1,3 +0,0 @@ -Package: firefox -Pin: release a=unstable -Pin-Priority: 500 diff --git a/filesystem/usr/local/bin/abrowser b/filesystem/usr/local/bin/abrowser index 520380a..36c64a6 100755 --- a/filesystem/usr/local/bin/abrowser +++ b/filesystem/usr/local/bin/abrowser @@ -8,10 +8,12 @@ tmp=${tmp%:} 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 diff --git a/machine_specific/btrbk.hosts b/machine_specific/btrbk.hosts index 3e987fa..7af85a1 100644 --- a/machine_specific/btrbk.hosts +++ b/machine_specific/btrbk.hosts @@ -3,3 +3,4 @@ kw x2 x3 frodo +sy diff --git a/pkgs b/pkgs index db4f7c2..e644f6e 100644 --- a/pkgs +++ b/pkgs @@ -49,6 +49,8 @@ p2=( # 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 @@ -146,6 +148,7 @@ p3=( mdadm meld memtester + metastore mhonarc moreutils mps-youtube @@ -179,6 +182,7 @@ p3=( qemu-user-static qrencode readline-doc + rename reportbug rfkill rng-tools