From 250ecd5bc4cfcdb6a2be31d8ed8a0303179fa30d Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Tue, 14 Dec 2021 09:33:34 +0100 Subject: [PATCH] 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. --- src/man/man8/opnsense-importer.8 | 7 +++++-- src/sbin/opnsense-importer | 14 +++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/man/man8/opnsense-importer.8 b/src/man/man8/opnsense-importer.8 index d5ca0d728..2cbd18d66 100644 --- a/src/man/man8/opnsense-importer.8 +++ b/src/man/man8/opnsense-importer.8 @@ -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 diff --git a/src/sbin/opnsense-importer b/src/sbin/opnsense-importer index f56d13c44..729720a37 100755 --- a/src/sbin/opnsense-importer +++ b/src/sbin/opnsense-importer @@ -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