From: Ian Kelling Date: Thu, 3 Oct 2024 10:10:10 +0000 (-0400) Subject: fix docs, improve code organization X-Git-Url: https://iankelling.org/git/?a=commitdiff_plain;h=9f49cf66c4dd21a8151cf14bb7183648522b4e66;p=distro-setup fix docs, improve code organization --- diff --git a/filesystem/usr/local/bin/check-subvol-stale b/filesystem/usr/local/bin/check-subvol-stale index 9b5e88d..3602056 100755 --- a/filesystem/usr/local/bin/check-subvol-stale +++ b/filesystem/usr/local/bin/check-subvol-stale @@ -39,9 +39,9 @@ Print the unstale subvol name into /nocow/btrfs-stale/\$subvol If latest subvols \$@ are not mounted, print a message to terminal. -Fresh is opposite of stale. To be fresh, either SUBVOL_MOUNTPOINT is a -snapshot of the latest, or the latest snapshot is snapshot of -SUBVOL_MOUNTPOINT. +Fresh is opposite of stale. To be fresh, the subvol in the root subvol +mount, aka SUBVOL_PATH, such as /mnt/root/a, is a snapshot of the latest +btrbk snapshot, or the latest btrbk snapshot is snapshot of SUBVOL_PATH. -p Args are SUBVOL_PATH, not mountpoints from which we derive that information. @@ -53,27 +53,6 @@ EOF exit $1 } -##### begin command line parsing ######## - -subvol_path=false -verbose=false -temp=$(getopt -l help,verbose hpv "$@") || usage 1 -eval set -- "$temp" -while true; do - case $1 in - -p) subvol_path=true ;; - -v|--verbose) verbose=true ;; - -h|--help) usage ;; - --) shift; break ;; - *) echo "$0: unexpected args: $*" >&2 ; usage 1 ;; - esac - shift -done - -if [[ ! $1 ]]; then - echo "$0: error: expected mountpoint argument" -fi - stale-file() { stale_dir=/nocow/btrfs-stale stale_file=$stale_dir/$vol @@ -107,12 +86,38 @@ mapper-dev() { done fi } + + +##### begin command line parsing ######## + +subvol_path=false +verbose=false +temp=$(getopt -l help,verbose hpv "$@") || usage 1 +eval set -- "$temp" +while true; do + case $1 in + -p) subvol_path=true ;; + -v|--verbose) verbose=true ;; + -h|--help) usage ;; + --) shift; break ;; + *) echo "$0: unexpected args: $*" >&2 ; usage 1 ;; + esac + shift +done + +if [[ ! $1 ]]; then + echo "$0: error: expected mountpoint argument" +fi + +##### end command line parsing ######## + + tmpf=$(mktemp) d tmpf=$tmpf for d; do if $subvol_path; then - svp=$d + svp=$d # svp = subvolume path root_dir=${d%/*} subvol_dir=${d##*/} vol=$subvol_dir