From eb95e8f53e56e25ce8f0898ee6936d8201bd9a29 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Tue, 26 Jun 2018 09:52:52 +0200 Subject: [PATCH] rc: allow config import from plain MSDOS drives; closes #1372 For now we only import on demand, but we could make this more automatic in the near future as this proves to be useful. --- src/sbin/opnsense-importer | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/sbin/opnsense-importer b/src/sbin/opnsense-importer index 46addc0f0..d2a1161e7 100755 --- a/src/sbin/opnsense-importer +++ b/src/sbin/opnsense-importer @@ -64,7 +64,7 @@ bootstrap_and_exit() fi # error code given or assumed ok (trap) - if [ -z "${RET}" ]; then + if [ -z "${RET}" ]; then RET=0 fi @@ -125,11 +125,11 @@ probe_for_part() DEV=${1} if [ -e "/dev/${DEV}s1a" ]; then - # MBR layout found + # MBR UFS export PART="/dev/${DEV}s1a" return 0 elif [ -e "/dev/${DEV}p3" ]; then - # GPT layout found + # GPT UFS export PART="/dev/${DEV}p3" return 0 elif [ "${DEV}" = "zroot" ]; then @@ -137,6 +137,16 @@ probe_for_part() export POOL="${DEV}" return 0 fi + elif [ -e "/dev/${DEV}s1" ]; then + # MBR MSDOS + export PART="/dev/${DEV}s1" + export MSDOS="yes" + return 0 + elif [ -e "/dev/${DEV}p1" ]; then + # GPT MSDOS + export PART="/dev/${DEV}p1" + export MSDOS="yes" + return 0 fi return 1 @@ -193,11 +203,17 @@ if [ -n "${PART}" ]; then echo "Starting import for partition '${PART}'." echo - echo -n "Running fsck..." - fsck -t ufs -y ${PART} > /dev/null - echo "done." + TYPE="ufs" - if ! mount ${PART} ${MNT}; then + if [ -z "${MSDOS}" ]; then + echo -n "Running fsck..." + fsck -t ${TYPE} -y ${PART} > /dev/null + echo "done." + else + TYPE="msdosfs" + fi + + if ! mount -t ${TYPE} ${PART} ${MNT}; then echo "The device could not be mounted." bootstrap_and_exit 1 fi