diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-27 18:33:03 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-27 18:33:03 -0500 |
| commit | 422d1098cd89beaeed81cc40488252233e2ca0ad (patch) | |
| tree | 7ea92619f7a76bc797851776cf1901d91b1e458f /README.org | |
| parent | ea494c7d0fc41bb1cab888f92408fab29c190e75 (diff) | |
| download | archangel-422d1098cd89beaeed81cc40488252233e2ca0ad.tar.gz archangel-422d1098cd89beaeed81cc40488252233e2ca0ad.zip | |
feat: consolidate zfssnapshot and zfsrollback into one subcommand-driven script
Problem: zfssnapshot and zfsrollback were two separate scripts with overlapping pre-flight checks (zfs / fzf / root) and parallel UX patterns (description sanitization in one, fzf selection in the other). Users had to remember which script was for which operation, and a "list" view meant typing the raw `zfs list -t snapshot` command. There was no path to destroy individual snapshots short of `zfs destroy` directly, which is dangerous without a confirmation flow.
Solution: rewrite zfssnapshot as a single multi-subcommand script (list, create, rollback, delete). Drop installer/zfsrollback. The new script uses a source-guard at the bottom (`if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then main "$@"; fi`) so bats can source it without triggering the install-time pre-flight checks, matching the pattern in installer/archangel.
Pure helpers (sanitize_description, validate_description, format_snapshot_name) get extracted as named functions so they're testable in isolation. The destructive flows (rollback, delete) keep the explicit "yes" confirmation prompt, the genesis-snapshot warning, and the recursive-rollback-destroys-newer-snapshots warning. Delete uses fzf --multi so the user can pick several snapshot names at once.
Updated build.sh to copy only the consolidated script. Dropped the zfsrollback profiledef permission line. Updated Makefile, README, scripts/sanity-test.sh, and testing-strategy.org to reflect the single-script layout.
Bats: 147 → 168 (+21). Coverage spans sanitize_description (normal / boundary / error), validate_description (alphanumerics, hyphens, underscores accepted; spaces, slashes, shell metacharacters, empty rejected), format_snapshot_name (timestamp + description composition), and main subcommand dispatch (list / create / rollback / delete / help / unknown). Lint clean. The zfs-, fzf-, and arch-chroot-shelling subcommand bodies stay VM-tested per testing-strategy.org.
Diffstat (limited to 'README.org')
| -rw-r--r-- | README.org | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -32,7 +32,7 @@ Archangel currently uses linux-lts for stability. Choosing linux and linux-zen k |------------------+----------------------------+----------------------| | Bootloader | ZFSBootMenu | GRUB + grub-btrfs | | Encryption | Native ZFS encryption | LUKS2 | -| Snapshot utility | zfssnapshot helper scripts | snapper | +| Snapshot utility | zfssnapshot | snapper | | Snapshot boot | Built into ZFSBootMenu | grub-btrfs menu | | RAID support | mirror, raidz1/2/3, stripe | RAID0, RAID1, RAID10 | | EFI size | 512MB | 1GB | @@ -258,14 +258,17 @@ A complete example with all options is available at ~installer/archangel.conf.ex ** ZFS Snapshot Management #+BEGIN_SRC bash +# List snapshots +zfssnapshot list + # Create a snapshot -zfssnapshot "before-experiment" +zfssnapshot create "before-experiment" -# Interactive rollback with fzf -zfsrollback +# Interactive rollback (fzf) +zfssnapshot rollback -# List snapshots -zfs list -t snapshot +# Interactive multi-select destroy (fzf) +zfssnapshot delete #+END_SRC ** Btrfs Snapshot Management @@ -347,8 +350,7 @@ archangel/ │ │ ├── disk.sh # Disk partitioning and EFI formatting │ │ ├── btrfs.sh # Btrfs-specific functions (LUKS, subvolumes, GRUB) │ │ └── raid.sh # Pure RAID-level logic (levels, validation, usable space) -│ ├── zfssnapshot # ZFS snapshot utility -│ ├── zfsrollback # ZFS rollback utility +│ ├── zfssnapshot # ZFS snapshot utility (list/create/rollback/delete) │ └── RESCUE-GUIDE.txt # Recovery tools documentation ├── tests/ │ └── unit/ # Bats unit tests for installer/lib/*.sh |
