diff options
author | jim-p <jimp@pfsense.org> | 2017-07-18 11:12:49 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2017-07-18 11:13:43 -0400 |
commit | 3413d68503fa5016f5f26a428109398ffab0372e (patch) | |
tree | eb7efb78069c7ed951f9f54af9c3781eecccb77c | |
parent | 945bd18374cfa3fee7b6256b656868fcf2d134e1 (diff) | |
download | FreeBSD-src-3413d68503fa5016f5f26a428109398ffab0372e.zip FreeBSD-src-3413d68503fa5016f5f26a428109398ffab0372e.tar.gz |
Prepare installer files for "Recover config.xml" option. Issue #7708
The actual script will be in the pfSense repo under tools/installer
-rwxr-xr-x | release/rc.local | 25 | ||||
-rwxr-xr-x | usr.sbin/bsdinstall/scripts/auto | 16 | ||||
-rwxr-xr-x | usr.sbin/bsdinstall/scripts/copy_configxml_from_usb | 18 |
3 files changed, 48 insertions, 11 deletions
diff --git a/release/rc.local b/release/rc.local index 27b670f..d0b08c5 100755 --- a/release/rc.local +++ b/release/rc.local @@ -72,10 +72,23 @@ if [ -f /etc/installerconfig ]; then exit fi -dialog --backtitle "pfSense Installer" --title "Welcome" --yes-label "Install" --no-label "Rescue Shell" --yesno "Welcome to pfSense! Would you like to begin an installation or use the Rescue Shell?" 0 0 +IOPTS="\ +\"Install\" \"Install pfSense\" \ +\"Rescue Shell\" \"Launch a shell prompt to perform rescue operations\"" -case $? in -$DIALOG_OK) # Install +if [ -x /root/recover_configxml.sh ] ; then + IOPTS="${IOPTS} \"Recover config.xml\" \"Recover config.xml from a previous installation\"" +fi + +exec 3>&1 +IMODE=`echo ${IOPTS} | xargs dialog --backtitle "pfSense Installer" \ + --title "Welcome" \ + --menu "Welcome to pfSense!" \ + 0 0 0 2>&1 1>&3` || exit 1 +exec 3>&- + +case "$IMODE" in +"Install") # Install # If not netbooting, have the installer configure the network dlv=`/sbin/sysctl -n vfs.nfs.diskless_valid 2> /dev/null` if [ ${dlv:=0} -eq 0 -a ! -f /etc/diskless ]; then @@ -94,11 +107,15 @@ $DIALOG_OK) # Install . /etc/rc.local fi ;; -$DIALOG_CANCEL) # Rescue Shell +"Rescue Shell") # Rescue Shell clear echo "When finished, type 'exit' to return to the installer." /bin/sh . /etc/rc.local ;; +"Recover config.xml") # Recover config.xml from a target drive + /root/recover_configxml.sh + . /etc/rc.local + ;; esac diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto index 7cda433..e2e3d52 100755 --- a/usr.sbin/bsdinstall/scripts/auto +++ b/usr.sbin/bsdinstall/scripts/auto @@ -465,6 +465,22 @@ trap error SIGINT # SIGINT is bad again bsdinstall config || error "Failed to save config" bsdinstall copy_configxml_from_usb +# If the user recovered a config.xml from an existing disk or provided one on +# a USB disk, then copy this config.xml to the chroot +if [ -r /tmp/recovered_config/config.xml ] ; then + /bin/cp -r /tmp/recovered_config/config.xml ${BSDINSTALL_CHROOT}/cf/conf/ + # Set a flag to let the installed system know this may need extra processing + /usr/bin/touch ${BSDINSTALL_CHROOT}/cf/conf/installer_copied_config + # Only set the package sync flag if the restored config.xml contains active packages + if [ `/usr/bin/grep -c '<package>' ${BSDINSTALL_CHROOT}/cf/conf/config.xml` -gt 0 ]; then + /usr/bin/touch ${BSDINSTALL_CHROOT}/cf/conf/needs_package_sync_after_reboot + fi + # If there is an existing configuration, then there is no need to run the wizard. + if [ -r ${BSDINSTALL_CHROOT}/cf/conf/trigger_initial_wizard ]; then + rm -f ${BSDINSTALL_CHROOT}/cf/conf/trigger_initial_wizard + fi +fi + if [ -n "$DISTDIR_IS_UNIONFS" ]; then umount -f $BSDINSTALL_DISTDIR fi diff --git a/usr.sbin/bsdinstall/scripts/copy_configxml_from_usb b/usr.sbin/bsdinstall/scripts/copy_configxml_from_usb index b022a0a..d682311 100755 --- a/usr.sbin/bsdinstall/scripts/copy_configxml_from_usb +++ b/usr.sbin/bsdinstall/scripts/copy_configxml_from_usb @@ -25,24 +25,28 @@ # SUCH DAMAGE. # # $FreeBSD$ +recovery_mount=/tmp/mnt_recovery +recovery_dir=/tmp/recovered_config +mkdir -p ${recovery_mount} +mkdir -p ${recovery_dir} look_for_config_xml_config_msdos() { - mkdir -p /tmp/mnt/cf + mkdir -p ${recovery_mount} echo -n "Looking for config.xml on " for try_device in `/sbin/gpart show -p | /usr/bin/egrep '(fat32|\!11|\!12|\!14)' | /usr/bin/awk '{print $3;}'`; do if [ ! -e /dev/${try_device} ]; then continue fi echo -n "${try_device}: " - if /sbin/mount -t msdosfs /dev/${try_device} /tmp/mnt/cf 2>/dev/null ; then + if /sbin/mount -t msdosfs /dev/${try_device} ${recovery_mount} 2>/dev/null ; then echo -n "[found msdos] " # look for config.xml - if [ -r /tmp/mnt/cf/conf/config.xml ]; then + if [ -r ${recovery_mount}/conf/config.xml ]; then echo -n "[config.xml on ${try_device}] " return 0 else echo -n "[no config.xml on ${try_device}, unmounting] " - /sbin/umount /tmp/mnt/cf + /sbin/umount ${recovery_mount} fi fi done @@ -51,9 +55,9 @@ look_for_config_xml_config_msdos() { # Try to locate an existing config.xml file if look_for_config_xml_config_msdos ; then - /bin/cp -r /tmp/mnt/cf/conf/config.xml $BSDINSTALL_CHROOT/cf/conf/ - /sbin/umount /tmp/mnt/cf/ 2>&1 - echo -n "[Copied config.xml file] " + /bin/cp -r ${recovery_mount}/conf/config.xml ${recovery_dir} + /sbin/umount ${recovery_mount} 2>&1 + echo -n "[Copied config.xml file to recovery area] " else echo -n "[Could not locate an existing config.xml file!] " fi |