system: opnsense-importer -m mode

Was in need of something like this to gain access to a ZFS pool without
having to run a command sequence from the top of my head.

Comes in pretty handy when being included from a recovery install stick.
This commit is contained in:
Franco Fichtner 2021-12-14 09:33:34 +01:00
parent 67910fbfea
commit 250ecd5bc4
2 changed files with 16 additions and 5 deletions

View File

@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd April 21, 2021
.Dd December 14, 2021
.Dt OPNSENSE-IMPORTER 8
.Os
.Sh NAME
@ -32,7 +32,7 @@
.Nd OPNsense import utility
.Sh SYNOPSIS
.Nm
.Op Fl bpz
.Op Fl bmpz
.Op Ar disk
.Sh DESCRIPTION
The
@ -61,6 +61,9 @@ Run the importer in boot mode, which only triggers the import timeout
prompt when no current configuration is found in the system.
This mode is used for install media duties to allow early configuration
imports to be able to live-boot into them afterwards.
.It Fl m
Run the importer in manual shell mode to access the recovered file
system for custom repairs.
.It Fl p
Run the importer in password reset mode, which mounts the disk and
invokes the builtin root password prompt and after change adjusts

View File

@ -26,6 +26,7 @@
INSTALL="/.probe.for.install.media"
MNT="/tmp/hdrescue"
SHELL="/bin/sh"
WAIT="........."
if [ "$(id -u)" != "0" ]; then
@ -34,6 +35,7 @@ if [ "$(id -u)" != "0" ]; then
fi
DO_BOOT=
DO_MANUAL=
DO_PASSWORD=
DO_ZFS=
@ -71,11 +73,14 @@ bootstrap_and_exit()
exit "${RET}"
}
while getopts bpz OPT; do
while getopts bmpz OPT; do
case ${OPT} in
b)
DO_BOOT="-b"
;;
m)
DO_MANUAL="-m"
;;
p)
DO_PASSWORD="-p"
;;
@ -280,7 +285,10 @@ while : ; do
continue
fi
if [ -n "${DO_PASSWORD}" ]; then
if [ -n "${DO_MANUAL}" ]; then
echo "# Manual shell mode, old file system available at ${MNT}"
${SHELL}
elif [ -n "${DO_PASSWORD}" ]; then
if [ -f "${MNT}/usr/local/sbin/opnsense-shell" ]; then
mount -t devfs devfs ${MNT}/dev
chroot ${MNT} /bin/sh /etc/rc.d/ldconfig start
@ -344,7 +352,7 @@ while : ; do
fi
done
if [ -z "${DO_BOOT}" ]; then
if [ -z "${DO_BOOT}${DO_MANUAL}${DO_PASSWORD}" ]; then
echo "Please reboot."
fi