-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
recovery shell quality of life improvements
The recovery shell is quite powerful, but discoverability can be limited. In an attempt to start fixing that, the following has been done: * Add a `help` alias and documentation page listing a few key things that can be done in the recovery shell. * Enable tab completions for the following: set_ro_pool, set_rw_pool, mount_zfs, zfs-chroot/zfs_chroot * Only source aliases/tab completions in interactive shells so that we don't impact the normal ZBM shell environment. Closes #197
- Loading branch information
Showing
9 changed files
with
276 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[1mNAME[0m | ||
|
||
[1mzfsbootmenu[0m - Recovery Shell | ||
|
||
[1mCommon Commands[0m | ||
|
||
[33mzfsbootmenu[0m | ||
Launch the interactive boot environment menu. | ||
|
||
[33mzfs-chroot[0m [1mzfs filesystem[0m | ||
Enter a chroot of the specified boot environment. The boot environment is mounted [33mread/write[0m if the zpool is imported [33mread/write[0m. | ||
|
||
[33mset_rw_pool[0m [1mpool[0m | ||
Export, then re-import the pool [33mread/write[0m. | ||
|
||
[33mset_ro_pool[0m [1mpool[0m | ||
Export, then re-import the pool [33mread-only[0m. | ||
|
||
[33mmount_zfs[0m [1mzfs filesystem[0m | ||
Mount the filesystem at a unique location and print the mount point. | ||
|
||
[33mhelp[0m | ||
View the online help system. | ||
|
||
[33mlogs[0m | ||
View warning/error/debug logs. | ||
|
||
[1mAUTHOR[0m | ||
|
||
ZFSBootMenu Team <https://github.com/zbm-dev/zfsbootmenu> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
[1mNAME[0m | ||
|
||
[1mzfsbootmenu[0m - Recovery Shell | ||
|
||
[1mCommon Commands[0m | ||
|
||
[33mzfsbootmenu[0m | ||
Launch the interactive boot environment menu. | ||
|
||
[33mzfs-chroot[0m [1mzfs filesystem[0m | ||
Enter a chroot of the specified boot environment. | ||
The boot environment is mounted [33mread/write[0m if the | ||
zpool is imported [33mread/write[0m. | ||
|
||
[33mset_rw_pool[0m [1mpool[0m | ||
Export, then re-import the pool [33mread/write[0m. | ||
|
||
[33mset_ro_pool[0m [1mpool[0m | ||
Export, then re-import the pool [33mread-only[0m. | ||
|
||
[33mmount_zfs[0m [1mzfs filesystem[0m | ||
Mount the filesystem at a unique location and print | ||
the mount point. | ||
|
||
[33mhelp[0m | ||
View the online help system. | ||
|
||
[33mlogs[0m | ||
View warning/error/debug logs. | ||
|
||
[1mAUTHOR[0m | ||
|
||
ZFSBootMenu Team | ||
<https://github.com/zbm-dev/zfsbootmenu> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[1mNAME[0m | ||
|
||
[1mzfsbootmenu[0m - Recovery Shell | ||
|
||
[1mCommon Commands[0m | ||
|
||
[33mzfsbootmenu[0m | ||
Launch the interactive boot environment menu. | ||
|
||
[33mzfs-chroot[0m [1mzfs filesystem[0m | ||
Enter a chroot of the specified boot environment. The boot environment is mounted [33mread/write[0m | ||
if the zpool is imported [33mread/write[0m. | ||
|
||
[33mset_rw_pool[0m [1mpool[0m | ||
Export, then re-import the pool [33mread/write[0m. | ||
|
||
[33mset_ro_pool[0m [1mpool[0m | ||
Export, then re-import the pool [33mread-only[0m. | ||
|
||
[33mmount_zfs[0m [1mzfs filesystem[0m | ||
Mount the filesystem at a unique location and print the mount point. | ||
|
||
[33mhelp[0m | ||
View the online help system. | ||
|
||
[33mlogs[0m | ||
View warning/error/debug logs. | ||
|
||
[1mAUTHOR[0m | ||
|
||
ZFSBootMenu Team <https://github.com/zbm-dev/zfsbootmenu> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#!/bin/bash | ||
# shellcheck disable=SC2207 | ||
|
||
# disabling this allows completions with the @ character | ||
shopt -u hostcomplete | ||
|
||
_zfs-chroot() { | ||
local ZFS | ||
COMPREPLY=() | ||
|
||
[ "${#COMP_WORDS[@]}" != "2" ] && return | ||
|
||
for SNAP in $( zfs list -H -o name -t snapshot ) ; do | ||
ZFS+=("${SNAP}") | ||
done | ||
|
||
for FS in $( zfs list -H -o name ) ; do | ||
ZFS+=("${FS}") | ||
done | ||
|
||
COMPREPLY=( $( compgen -W "${ZFS[*]}" -- "${COMP_WORDS[1]}" ) ) | ||
} | ||
complete -F _zfs-chroot zfs-chroot | ||
complete -F _zfs-chroot zfs_chroot | ||
|
||
_set_rw_pool() { | ||
local ZPOOL | ||
COMPREPLY=() | ||
|
||
[ "${#COMP_WORDS[@]}" != "2" ] && return | ||
|
||
for POOL in $( zpool list -H -o name ) ; do | ||
if ! is_writable "${POOL}" ; then | ||
ZPOOL+=("${POOL}") | ||
fi | ||
done | ||
COMPREPLY=( $( compgen -W "${ZPOOL[*]}" -- "${COMP_WORDS[1]}" ) ) | ||
} | ||
complete -F _set_rw_pool set_rw_pool | ||
|
||
_set_ro_pool() { | ||
local ZPOOL | ||
COMPREPLY=() | ||
|
||
[ "${#COMP_WORDS[@]}" != "2" ] && return | ||
|
||
for POOL in $( zpool list -H -o name ) ; do | ||
if is_writable "${POOL}" ; then | ||
ZPOOL+=("${POOL}") | ||
fi | ||
done | ||
COMPREPLY=( $( compgen -W "${ZPOOL[*]}" -- "${COMP_WORDS[1]}" ) ) | ||
} | ||
complete -F _set_ro_pool set_ro_pool | ||
|
||
_mount_zfs() { | ||
local ZFS | ||
COMPREPLY=() | ||
|
||
[ "${#COMP_WORDS[@]}" != "2" ] && return | ||
|
||
for SNAP in $( zfs list -H -o name -t snapshot ) ; do | ||
ZFS+=("${SNAP}") | ||
done | ||
|
||
for FS in $( zfs list -H -o name ) ; do | ||
ZFS+=("${FS}") | ||
done | ||
|
||
COMPREPLY=( $( compgen -W "${ZFS[*]}" -- "${COMP_WORDS[1]}" ) ) | ||
} | ||
complete -F _mount_zfs mount_zfs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
=pod | ||
|
||
=head1 NAME | ||
|
||
B<zfsbootmenu> - Recovery Shell | ||
|
||
=head1 Common Commands | ||
|
||
=over 2 | ||
|
||
=item I<zfsbootmenu> | ||
|
||
Launch the interactive boot environment menu. | ||
|
||
=item I<zfs-chroot> B<zfs filesystem> | ||
|
||
Enter a chroot of the specified boot environment. The boot environment is mounted I<read/write> if the zpool is imported I<read/write>. | ||
|
||
=item I<set_rw_pool> B<pool> | ||
|
||
Export, then re-import the pool I<read/write>. | ||
|
||
=item I<set_ro_pool> B<pool> | ||
|
||
Export, then re-import the pool I<read-only>. | ||
|
||
=item I<mount_zfs> B<zfs filesystem> | ||
|
||
Mount the filesystem at a unique location and print the mount point. | ||
|
||
=item I<help> | ||
|
||
View the online help system. | ||
|
||
=item I<logs> | ||
|
||
View warning/error/debug logs. | ||
|
||
=back | ||
|
||
=head2 AUTHOR | ||
|
||
ZFSBootMenu Team L<https://github.com/zbm-dev/zfsbootmenu> | ||
|
||
=cut |