From: Ian Kelling Date: Tue, 13 Jul 2021 04:11:48 +0000 (-0400) Subject: amy backup restore, various improvements X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=1dc729029b3f118e77866760236a076716b2cc9f;p=distro-setup amy backup restore, various improvements --- diff --git a/brc2 b/brc2 index b57789f..ccc4968 100644 --- a/brc2 +++ b/brc2 @@ -332,6 +332,10 @@ bbk() { # btrbk wrapper return $ret } +faimon() { + fai-monitor | pee cat "fai-monitor-gui -" +} + bfg() { java -jar /a/opt/bfg-1.12.14.jar "$@"; } bigclock() { @@ -945,15 +949,20 @@ o() { } ccomp xdg-open o -jfilter() { - grep -Evi -e "^(\S+\s+){4}(sudo|sshd|cron)\[\S*:" \ - -e "^(\S+\s+){4}systemd\[\S*: (starting|started) (btrfsmaintstop|dynamicipupdate|spamd dns bug fix cronjob|rss2email)\.*$" -} -jtail() { - journalctl -n 10000 -f "$@" | jfilter -} -jr() { journalctl "$@" | jfilter | less ; } -jrf() { journalctl -n 200 -f "$@" | jfilter; } +# jfilter() { +# grep -Evi -e "^(\S+\s+){4}(sudo|sshd|cron)\[\S*:" \ + # -e "^(\S+\s+){4}systemd\[\S*: (starting|started) (btrfsmaintstop|dynamicipupdate|spamd dns bug fix cronjob|rss2email)\.*$" +# } +# jtail() { +# journalctl -n 10000 -f "$@" | jfilter +# } +# jr() { journalctl "$@" | jfilter | less ; } +# jrf() { journalctl -n 200 -f "$@" | jfilter; } + +jr() { journalctl "$@" ; } +jrf() { journalctl -n 200 -f "$@" ; } + + ccomp journalctl jtail jr jrf kff() { # keyboardio firmware flash diff --git a/btrbk-run b/btrbk-run index fd05c09..88676be 100644 --- a/btrbk-run +++ b/btrbk-run @@ -143,11 +143,13 @@ fi ### end options parsing # note, this test succeeds if not installed -if [[ /a/opt/btrbk/btrbk -nt /usr/btrbk ]]; then +if [[ /a/opt/btrbk/btrbk -nt /usr/bin/btrbk ]]; then if [[ -e /b/distro-functions/src/package-manager-abstractions ]]; then . /b/distro-functions/src/package-manager-abstractions pi asciidoctor fi + # remove path from earlier version of btrbk + rm -f /usr/sbin/btrbk cd /a/opt/btrbk m make m sudo make install @@ -191,15 +193,16 @@ if [[ ! -v targets && ! $source ]]; then targets+=($home x3) ;; x2|x3|sy) - targets+=($home kw.office.fsf.org) - ;; - kd) - targets+=(x2.b8.nz sy.b8.nz) - # might not be connected to the vpn - if timeout -s 9 6 ssh kw.office.fsf.org :; then + targets+=($home) + if $at_work; then targets+=(kw.office.fsf.org) + else + targets+=(kw.b8.nz) fi ;; + kd) + targets+=(x2.b8.nz sy.b8.nz kw.b8.nz) + ;; frodo) # no targets targets=() @@ -388,9 +391,8 @@ ssh_identity /root/.ssh/home # transaction info. transaction_syslog local7 -# note, i had this because man said 20% speedup, but ran into -# this issue, https://github.com/digint/btrbk/issues/275 -#stream_buffer 512m +# trying this out +stream_compress zstd # so we only run one at a time lockfile /var/lock/btrbk.lock diff --git a/btrbkr2 b/btrbkr2 new file mode 100755 index 0000000..321948c --- /dev/null +++ b/btrbkr2 @@ -0,0 +1,104 @@ +#!/bin/bash +# Copyright (C) 2019 Ian Kelling +# SPDX-License-Identifier: AGPL-3.0-or-later +# SPDX-License-Identifier: GPL-3.0-or-later +# SPDX-License-Identifier: Apache-2.0 + +if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi +shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4 +set -eE -o pipefail +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR +# alternatively, using https://iankelling.org/git/?p=errhandle;a=tree +# source /path/errhandle/err +# on my machine +source /a/bin/errhandle/err + +[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" + +usage() { + cat <&2; exit 1; } + +temp=$(getopt -l help h "$@") || usage 1 +eval set -- "$temp" +while true; do + case $1 in + -h|--help) usage ;; + --) shift; break ;; + *) echo "$0: unexpected args: $*" >&2 ; usage 1 ;; + esac + shift +done + +read -r target <<<"$@" + +if [[ ! $target ]]; then + echo $0: error: specify target + exit 1 +fi + +cat >/etc/btrbk/root2.conf <$tmpconf <<<"archive_exclude ${exclude}_ubuntubionic" + btrbk -c $tmpconf archive /mnt/r7/amy/btrbk ssh://$target/mnt/${base}2/btrbk + # swaps the vars + exclude=$base +done diff --git a/check-subvol-stale b/check-subvol-stale index 7758df7..d20c1aa 100644 --- a/check-subvol-stale +++ b/check-subvol-stale @@ -23,7 +23,7 @@ shopt -s nullglob usage() { cat <&2 ; usage 1 ;; esac + shift done if [[ ! $1 ]]; then @@ -73,38 +78,49 @@ stale-file() { } d() { - if $debug; then + if $verbose; then printf "%s\n" "$*" fi } for d; do - vol=${d##*/} - # second field, non-comment line == $d - dev=$(sed -rn "s,^\s*([^#]\S*)\s+$d\s.*,\1,p" /etc/fstab /etc/mtab|head -n1) - - d dev=$dev - subvol_dir=$(sed -rn "s,^\s*[^#]\S*\s+$d\s.*\bsubvol=([a-zA-A/]+).*,\1,p" /etc/fstab /etc/mtab|head -n1) - if [[ ! $subvol_dir ]]; then - continue - fi - d subvol_dir=$subvol_dir - # note, we need $dev because $d might not be mounted, and we do this loop - # because the device in fstab for the rootfs can be different. - for devx in $(btrfs fil show $dev| sed -rn 's#.*path (/\S+)$#\1#p'); do - d devx=$devx - root_dir=$(sed -rn "s,^\s*$devx\s+(\S+).*\bsubvolid=[05]\b.*,\1,p" /etc/mtab /etc/fstab|head -n1) - if [[ $root_dir ]]; then - d root_dir=$root_dir - break + if $subvol_path; then + svp=$d + root_dir=${d%/*} + subvol_dir=${d##*/} + vol=$subvol_dir + else + vol=${d##*/} + # second field, non-comment line == $d + dev=$(sed -rn "s,^\s*([^#]\S*)\s+$d\s.*,\1,p" /etc/fstab /etc/mtab|head -n1) + + d dev=$dev + subvol_dir=$(sed -rn "s,^\s*[^#]\S*\s+$d\s.*\bsubvol=([a-zA-A/]+).*,\1,p" /etc/fstab /etc/mtab|head -n1) + if [[ ! $subvol_dir ]]; then + continue fi - done - if [[ ! $root_dir ]]; then - echo "$0: error could not find root subvol mount for $dev" >&2 - exit 1 + d subvol_dir=$subvol_dir + + ### begin getting root_dir + ### this is duplicated in mount-latest-subvol + # note, we need $dev because $d might not be mounted, and we do this loop + # because the device in fstab for the rootfs can be different. + for devx in $(btrfs fil show $dev| sed -rn 's#.*path (/\S+)$#\1#p'); do + d devx=$devx + root_dir=$(sed -rn "s,^\s*$devx\s+(\S+).*\bsubvolid=[05]\b.*,\1,p" /etc/mtab /etc/fstab|head -n1) + if [[ $root_dir ]]; then + d root_dir=$root_dir + break + fi + done + if [[ ! $root_dir ]]; then + echo "$0: error could not find root subvol mount for $dev" >&2 + exit 1 + fi + ### end getting root_dir + svp=$root_dir/$subvol_dir # subvolume path + d "svp=$svp # subvolume path" fi - svp=$root_dir/$subvol_dir # subvolume path - d "svp=$svp # subvolume path" snaps=($root_dir/btrbk/$subvol_dir.20*) # Assumes we are in the 21st century. if [[ ! ${snaps[*]} ]]; then diff --git a/distro-begin b/distro-begin index b4fdfe6..4cd02df 100755 --- a/distro-begin +++ b/distro-begin @@ -165,7 +165,7 @@ EOF sudo systemctl enable keyscriptoff.service sudo systemctl start keyscriptoff.service - pi rsync + pi rsync zstd ## /usr/share/doc/dropbear-initramfs/README.initramfs.gz ## claims we need to do this. but it works fine without it. @@ -611,8 +611,6 @@ if isubuntu; then sudo dd of=/etc/default/apport <<<'enabled=0' fi - - ##### install laptop hardware packages if tp || x2 || x3; then case $distro in diff --git a/distro-end b/distro-end index 2ca2005..b1de654 100755 --- a/distro-end +++ b/distro-end @@ -982,7 +982,7 @@ Type=oneshot # about 24 hours of failures # it copies over its files without respecting symlinks, so # we pass options to use different location. -ExecStart=/a/bin/log-quiet/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run +ExecStart=/usr/local/bin/sysd-mail-once -288 rss2email r2e -d /p/c/rss2email.json -c /p/c/rss2email.cfg run EOF sd /etc/systemd/system/rss2email.timer <<'EOF' [Unit] @@ -1011,7 +1011,7 @@ After=multi-user.target [Service] User=iank Type=oneshot -ExecStart=/a/bin/log-quiet/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs +ExecStart=/usr/local/bin/sysd-mail-once irc-backup rsync -rlptDhSAX root@iankelling.org:/var/lib/znc/moddata/log/iank/freenode/ /k/irclogs EOF sd /etc/systemd/system/ircbackup.timer <<'EOF' [Unit] @@ -1250,7 +1250,7 @@ After=multi-user.target [Service] Type=oneshot -ExecStart=/a/bin/log-quiet/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate +ExecStart=/usr/local/bin/sysd-mail-once schrootupdate /a/bin/distro-setup/schrootupdate EOF sd /etc/systemd/system/schrootupdate.timer <<'EOF' [Unit] @@ -1694,6 +1694,9 @@ EOF sgo btrfsmaint.timer sgo btrfsmaintstop.timer +sgo systemstatus.timer + + # aren't autoupdating this, but I do check on it somewhat regularly. m cd /a/opt/btrbk sudo make install diff --git a/dynamic-ip-update b/dynamic-ip-update index ccc7389..e10cdb7 100755 --- a/dynamic-ip-update +++ b/dynamic-ip-update @@ -11,7 +11,13 @@ main() { up4=false - read -r _ _ gateway _ < <(ip -4 route get 85.119.83.50) + if ! read -r _ _ gateway _ < <(ip -4 route get 85.119.83.50 2>/dev/null); then + # if our internet is down, just give up, no need to have an error + if [[ ! $INVOCATION_ID ]]; then + echo $0: failed to get route, giving up + fi + exit 0 + fi case $gateway in 10.2.0.1) diff --git a/epanic-clean b/epanic-clean index d75574c..35b7258 100755 --- a/epanic-clean +++ b/epanic-clean @@ -39,8 +39,13 @@ while read -r service regex; do jmin="$(date -d @$sec_min "+%F %H:%M:%S")" jmax="$(date -d @$sec_max "+%F %H:%M:%S")" description=$(systemctl cat $service | sed -rn 's/^ *Description=(.*)/\1/p') + regex="^Starting $description" + if [[ $service == spamassassin ]]; then + regex+="\|^spamd: restarting" + fi + # the sed clears out the initial time and process+pid if ! journalctl -u $service -S "$jmin" -U "$jmax" \ - | grep "Starting $description" &>/dev/null; then + | sed -r 's/^([^ ]* ){6} //' | grep "$regex" &>/dev/null; then wipe=false break fi diff --git a/filesystem/etc/cron.d/ian b/filesystem/etc/cron.d/ian index 7df6705..53dc845 100644 --- a/filesystem/etc/cron.d/ian +++ b/filesystem/etc/cron.d/ian @@ -2,8 +2,6 @@ SHELL=/bin/bash PATH=/usr/bin:/bin:/usr/local/bin:/a/exe MAILTO=root */10 * * * * iank rootsshsync |& log-once -15 rootsshsync -# this goes into bash prompt, does in cron for more efficient shell -* * * * * iank system-status |& log-once system-status # If theres any logged errors we didnt handle in 4 days, maybe we accidentally missed them, # so report if we did 4 9 * * 5 root /a/bin/ds/check-stale-alerts diff --git a/filesystem/etc/systemd/system/btrfsmaint.service b/filesystem/etc/systemd/system/btrfsmaint.service index 88705fe..3a899e2 100644 --- a/filesystem/etc/systemd/system/btrfsmaint.service +++ b/filesystem/etc/systemd/system/btrfsmaint.service @@ -4,9 +4,6 @@ After=multi-user.target [Service] Type=oneshot -# about 24 hours of failures -# it copies over its files without respecting symlinks, so -# we pass options to use different location. -ExecStart=/a/bin/log-quiet/sysd-mail-once -1 btrfsmaint /a/bin/ds/btrfsmaint +ExecStart=/usr/local/bin/sysd-mail-once -1 btrfsmaint /usr/local/bin/btrfsmaint IOSchedulingClass=idle CPUSchedulingPolicy=idle diff --git a/filesystem/etc/systemd/system/btrfsmaintstop.service b/filesystem/etc/systemd/system/btrfsmaintstop.service index e564e1c..31b4a65 100644 --- a/filesystem/etc/systemd/system/btrfsmaintstop.service +++ b/filesystem/etc/systemd/system/btrfsmaintstop.service @@ -4,4 +4,4 @@ After=multi-user.target [Service] Type=oneshot -ExecStart=/a/bin/log-quiet/sysd-mail-once -10 btrfsmaintstop /a/bin/ds/btrfsmaint check +ExecStart=/usr/local/bin/sysd-mail-once -10 btrfsmaintstop /usr/local/bin/btrfsmaint check diff --git a/filesystem/etc/systemd/system/dynamicipupdate.service b/filesystem/etc/systemd/system/dynamicipupdate.service index 84c4615..48c3d44 100644 --- a/filesystem/etc/systemd/system/dynamicipupdate.service +++ b/filesystem/etc/systemd/system/dynamicipupdate.service @@ -4,4 +4,4 @@ After=multi-user.target [Service] Type=oneshot -ExecStart=/a/bin/log-quiet/sysd-mail-once -40 dynamicipupdate /a/bin/ds/dynamic-ip-update +ExecStart=/usr/local/bin/sysd-mail-once -40 dynamicipupdate /usr/local/bin/dynamic-ip-update diff --git a/filesystem/etc/systemd/system/systemstatus.service b/filesystem/etc/systemd/system/systemstatus.service new file mode 100644 index 0000000..23afb89 --- /dev/null +++ b/filesystem/etc/systemd/system/systemstatus.service @@ -0,0 +1,11 @@ +[Unit] +Description=systemstatus +After=multi-user.target + +[Service] +Type=oneshot +ExecStart=/usr/local/bin/sysd-mail-once -3 systemstatus /usr/local/bin/system-status +IOSchedulingClass=idle +CPUSchedulingPolicy=idle +User=iank +Group=iank diff --git a/filesystem/etc/systemd/system/systemstatus.timer b/filesystem/etc/systemd/system/systemstatus.timer new file mode 100644 index 0000000..80e2f74 --- /dev/null +++ b/filesystem/etc/systemd/system/systemstatus.timer @@ -0,0 +1,11 @@ +[Unit] +Description=systemstatus + +[Timer] +# for initial run. required. +OnActiveSec=10 +# for subsequent runs. +OnUnitInactiveSec=20 + +[Install] +WantedBy=timers.target diff --git a/gen-amy-fstab b/gen-amy-fstab new file mode 100755 index 0000000..7a1ce46 --- /dev/null +++ b/gen-amy-fstab @@ -0,0 +1,54 @@ +#!/bin/bash +# Copyright (C) 2019 Ian Kelling +# SPDX-License-Identifier: Apache-2.0 + +if ! test "$BASH_VERSION"; then echo "error: shell is not bash" >&2; exit 1; fi +shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4 +set -eE -o pipefail +trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" exit status: $?, PIPESTATUS: ${PIPESTATUS[*]}" >&2' ERR +# alternatively, using https://iankelling.org/git/?p=errhandle;a=tree +# source /path/errhandle/err +# on my machine +source /a/bin/errhandle/err + +[[ $EUID == 0 ]] || exec sudo -E "${BASH_SOURCE[0]}" "$@" + +subvol=$1 # eg ubuntubionic +nr=$2 # new root + +if (( $# != 2 )); then + echo $0: error expected 2 arguments + exit 1 +fi + +if (($(nproc) > 2)); then + mopts=,compress=zstd +fi + +rm -f $nr/etc/{fs,crypt}tab +while read -r line; do + printf "%s none keyscript=decrypt_keyctl,discard,luks,initramfs\n" "$line" >>$nr/etc/crypttab +done < <(awk '{print $1,$2}' /mnt/root/root2-crypttab) +awk '$3 == "/dev/urandom" {print}' /etc/crypttab >>$nr/etc/crypttab + + +rootdev=$(awk '$2 == "/mnt/root2" {print $1}' /mnt/root/root2-fstab) +fstabstd=x-systemd.device-timeout=30s,x-systemd.mount-timeout=30s +bootdev=$(awk '$2 == "/mnt/boot2" {print $1}' /mnt/root/root2-fstab) + + +cat >> $nr/etc/fstab <>$nr/etc/fstab + + +while read -r mdname; do + cat >> $nr/etc/fstab <&2; exit 1; } + reload=false +# This file is so if we fail in the middle and rerun, we dont lose state +if [[ -e /var/local/mail-setup-reload ]]; then + reload=true +fi i() { # install file local tmp tmpdir dest="$1" local base="${dest##*/}" @@ -278,6 +280,7 @@ i() { # install file printf "%s\n" "$tmp" ir=true if [[ $dest == /etc/systemd/system/* ]]; then + touch /var/local/mail-setup-reload reload=true fi fi @@ -420,7 +423,7 @@ After=multi-user.target [Service] User=$u Type=oneshot -ExecStart=/a/bin/log-quiet/sysd-mail-once mailclean /a/bin/distro-setup/mailclean +ExecStart=/usr/local/bin/sysd-mail-once mailclean /a/bin/distro-setup/mailclean EOF # * postgrey @@ -710,7 +713,7 @@ After=multi-user.target [Service] Type=oneshot -ExecStart=/a/bin/log-quiet/sysd-mail-once mailcert /usr/local/bin/mail-cert-cron +ExecStart=/usr/local/bin/sysd-mail-once mailcert /usr/local/bin/mail-cert-cron EOF i /etc/systemd/system/mailcert.timer <<'EOF' [Unit] @@ -1869,7 +1872,7 @@ To: alerts@iankelling.org From: root@$(hostname -f) Subject: failed nextcloud update for $ncbase -For logs, run: jru $ncbase +For logs, run: jr -u $ncbase EOF fi EOFOUTER @@ -2428,6 +2431,10 @@ case $HOSTNAME in ;;& esac +# last use of $reload happens in previous block +rm -f /var/local/mail-setup-reload + + case $HOSTNAME in $MAIL_HOST|bk|je) : ;; *) @@ -2469,7 +2476,7 @@ MAILTO=alerts@iankelling.org # for now. It looks like a dns failure. #5-59/5 * * * * root mailtest-check |& log-once -1 mailtest-check #0 * * * * root mailtest-check slow |& log-once -1 mailtest-slow -*/5 * * * * root mailtest-check slow |& log-once -1 mailtest-check +*/5 * * * * root mailtest-check slow |& log-once -12 mailtest-check EOF m sudo rsync -ahhi --chown=root:root --chmod=0755 \ /b/ds/mailtest-check /b/ds/check-remote-mailqs /usr/local/bin/ diff --git a/mount-latest-subvol b/mount-latest-subvol index 7764b75..5458a95 100644 --- a/mount-latest-subvol +++ b/mount-latest-subvol @@ -24,6 +24,8 @@ usage() { Usage: ${0##*/} [OPTIONS] -h|--help Print help and exit. +-f|--force Use kill -9 to try fixing unmount errors +-v|--verbose Be more verbose Note, at source location, intentionally not executable, run and read @@ -42,6 +44,11 @@ tu() { grep -xFq "$line" "$file" || tee -a "$file"<<<"$line" done } +d() { + if $verbose; then + printf "%s\n" "$*" + fi +} m() { if $verbose; then printf "%s\n" "$*" @@ -148,16 +155,42 @@ done ret=0 ##### begin setup fstab for subvols we care about ###### -root_dev=$(awk '$2 == "/" {print $1}' /etc/mtab) -if [[ $root_dev == /dev/dm-* ]]; then - for d in /dev/mapper/*; do - if [[ $(readlink -f $d) == "$root_dev" ]]; then - root_dev=$d - break + +if [[ -e /mnt/root/root2-crypttab ]]; then + tu /etc/crypttab /dev/null; then crypt_dev=$root_dev else # if we are in a recovery boot, find the next best crypt device @@ -170,6 +203,9 @@ else # if we are in a recovery boot, find the next best crypt device fi done fi + + + # dont tax the cpus of old laptops if ((`nproc` > 2)); then mopts+=,compress=zstd @@ -206,9 +242,12 @@ if [[ $HOSTNAME == frodo ]]; then $crypt_dev /i btrfs noatime,subvol=i$mopts 0 0 EOF fi + + + ##### end setup fstab for subvols we care about ###### -# get pids that this program depends on so we dont kill them +### begin get pids that this program depends on so we dont kill them my_pids=($$ $PPID) loop_limit=30 count=0 @@ -220,11 +259,11 @@ while [[ ${my_pids[-1]} != 1 && ${my_pids[-1]} != ${my_pids[-2]} && $count -lt $ fi my_pids+=($p) done +### end get pids that this program depends on so we dont kill them for vol in q a o i; do d=/$vol if ! awk '{print $2}' /etc/fstab | grep -xF $d &>/dev/null; then - continue fi @@ -285,8 +324,26 @@ for vol in q a o i; do fi #### begin dealing with leaf vols #### - # todo: decipher /mnt/root, like we do in check-subvol-stale - cd /mnt/root + + ### begin getting root_dir + ### this is duplicated in check-subvol-stale + # note, we need $dev because $d might not be mounted, and we do this loop + # because the device in fstab for the rootfs can be different. + for devx in $(btrfs fil show $dev| sed -rn 's#.*path (/\S+)$#\1#p'); do + d devx=$devx + root_dir=$(sed -rn "s,^\s*$devx\s+(\S+).*\bsubvolid=[05]\b.*,\1,p" /etc/mtab /etc/fstab|head -n1) + if [[ $root_dir ]]; then + d root_dir=$root_dir + break + fi + done + if [[ ! $root_dir ]]; then + echo "$0: error could not find root subvol mount for $dev" >&2 + exit 1 + fi + ### end getting root_dir + + cd $root_dir if [[ -e $vol ]]; then leaf=$vol.leaf.$(date +%Y-%m-%dT%H:%M:%S%z) m mv $vol $leaf @@ -369,7 +426,72 @@ for vol in q a o i; do fi stale_dir=/nocow/btrfs-stale rm -f $stale_dir/$d +done + + +for dir in /mnt/r7/amy/{root,boot}_ubuntubionic /mnt/{root2/root,boot2/boot}_ubuntubionic; do + vol=${dir##*/} + root_dir=${dir%/*} + if [[ ! -d $root_dir ]]; then + # this only exists on host kd currently + continue + fi + # if latest is already mounted, make sure binds are mounted and move on + m check-subvol-stale -p $dir + # populated by check-subvol-stale if stale + if ! fresh_snap=$(cat /nocow/btrfs-stale/$vol 2>/dev/null); then + continue + fi + if [[ -d $dir ]]; then + if ! kill-dir TERM TERM TERM INT INT HUP HUP TERM TERM TERM INT INT HUP HUP; then + if $force; then kill-dir KILL; fi + fi + m btrfs sub del $dir + fi + m btrfs sub snapshot $fresh_snap $dir + rm -f /nocow/btrfs-stale/$vol done exit $ret + + +# Explaining this whole thing. The host amy is used by someone else, +# i back it up to my extra big partition on one computer. +# But I also want to restore it and test out the restoration on +# a computer I usually use. For this, I created a separate partition +# that has the amy encryption password, and a separate boot so +# that I could encrypt my own boot partition if I want. Then, +# I backup from this big partition into that partition in order +# to boot and run it. +# +# In order to boot and run it: + +# mount -o bind /mnt/root2/root_ubuntubionic /mnt/1 +# cd /mnt/1 +# /b/ds/gen-amy-fstab ubuntubionic . +# teeu /mnt/1/etc/default/grub <<<'GRUB_DISABLE_OS_PROBER=true' +# mount -o bind /mnt/boot2/boot_ubuntubionic boot +# mount -o bind /dev dev +# mount -o bind /proc proc +# mount -o bind /sys sys +# mkdir -p boot/efi +# mount $(awk '$2 == "/boot/efi" {print $1}' /etc/mtab) boot/efi +# chroot . +# apt install grub-efi + +# ssds=() +# for disk in $(lsblk -do name,tran -n | awk '$2 ~ "^(sata|nvme)$" { print $1 }'); do +# case $(cat /sys/block/$disk/queue/rotational) in +# 0) ssds+=(/dev/$disk) ;; +# 1) : ;; # hdd +# *) echo "$0: error: unknown /sys/block/$disk/queue/rotational: \ +# $(cat $disk/queue/rotational)" ;; +# esac +# done + +# GROOT=$(grub-probe -tdrive -d ${ssds[@]}) +# echo "GROOT=$GROOT" +# grub-install --no-floppy --modules=part_gpt "$GROOT" +# update-grub +# update-initramfs -u diff --git a/system-status b/system-status index 30c3802..31d8a12 100644 --- a/system-status +++ b/system-status @@ -12,6 +12,7 @@ status_file=/dev/shm/iank-status shopt -s nullglob shopt -s dotglob +shopt -s extglob for p in ~/.gem/ruby/*/bin; do PATH="$PATH:$p" @@ -63,7 +64,9 @@ write-status() { bouncemsg="message in /m/md/bounces/new" fi lo -1 bounce $bouncemsg - glob=(/m/md/alerts/{new,cur}/*) + # emails without the S (seen) flag. this only checks the last flag, + # but its good enough for me. + glob=(/m/md/alerts/{new,cur}/!(*,S)) if [[ -e ${glob[0]} ]]; then chars+=("A") fi @@ -247,7 +250,9 @@ fi if ! $power; then exit 0 fi -for ((i=1; i<=3; i++)); do + +# about 15 minutes +for ((i=1; i<=60; i++)); do sleep 15 write-status done