diff options
author | jim-p <jimp@pfsense.org> | 2017-07-12 14:14:29 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2017-07-12 14:16:48 -0400 |
commit | 5e79cd177be56be14861a92b860930b25f97d40c (patch) | |
tree | 83ac8824627987058cb9be4301db43487111472f | |
parent | 8711269788b3bd5ce2873fa580c80d7d393ae186 (diff) | |
download | FreeBSD-src-5e79cd177be56be14861a92b860930b25f97d40c.zip FreeBSD-src-5e79cd177be56be14861a92b860930b25f97d40c.tar.gz |
Add script to copy config.xml off an available USB drive after the installation is complete, similar to the old PFI behavior. Implements #7689
(cherry picked from commit ec316ce32d9b91fd07abc6392323f43d5365c6bd)
(cherry picked from commit e471bc56255d0ba97d8ec1a9add892d069ebff42)
-rw-r--r-- | usr.sbin/bsdinstall/scripts/Makefile | 2 | ||||
-rwxr-xr-x | usr.sbin/bsdinstall/scripts/auto | 1 | ||||
-rwxr-xr-x | usr.sbin/bsdinstall/scripts/copy_configxml_from_usb | 60 |
3 files changed, 62 insertions, 1 deletions
diff --git a/usr.sbin/bsdinstall/scripts/Makefile b/usr.sbin/bsdinstall/scripts/Makefile index 419c8bc..113c6c0 100644 --- a/usr.sbin/bsdinstall/scripts/Makefile +++ b/usr.sbin/bsdinstall/scripts/Makefile @@ -2,7 +2,7 @@ SCRIPTS= auto adduser checksum config docsinstall entropy fix_fstab hardening hostname jail \ keymap mirrorselect mount netconfig netconfig_ipv4 netconfig_ipv6 \ - rootpass script services time umount wlanconfig zfsboot + rootpass script services time umount wlanconfig zfsboot copy_configxml_from_usb BINDIR= ${LIBEXECDIR}/bsdinstall MAN= diff --git a/usr.sbin/bsdinstall/scripts/auto b/usr.sbin/bsdinstall/scripts/auto index 0d9e195..459f1a4 100755 --- a/usr.sbin/bsdinstall/scripts/auto +++ b/usr.sbin/bsdinstall/scripts/auto @@ -463,6 +463,7 @@ finalconfig() { trap error SIGINT # SIGINT is bad again bsdinstall config || error "Failed to save config" +bsdinstall copy_configxml_from_usb if [ ! -z "$BSDINSTALL_FETCHDEST" ]; then [ "$BSDINSTALL_FETCHDEST" != "$BSDINSTALL_DISTDIR" ] && \ diff --git a/usr.sbin/bsdinstall/scripts/copy_configxml_from_usb b/usr.sbin/bsdinstall/scripts/copy_configxml_from_usb new file mode 100755 index 0000000..b022a0a --- /dev/null +++ b/usr.sbin/bsdinstall/scripts/copy_configxml_from_usb @@ -0,0 +1,60 @@ +#!/bin/sh +#- +# Copyright (c) 2017 Rubicon Communications, LLC +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ + +look_for_config_xml_config_msdos() { + mkdir -p /tmp/mnt/cf + 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 + echo -n "[found msdos] " + # look for config.xml + if [ -r /tmp/mnt/cf/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 + fi + fi + done + return 1 +} + +# 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] " +else + echo -n "[Could not locate an existing config.xml file!] " +fi +echo "Done."
\ No newline at end of file |