1209513Simp#!/bin/sh 2209513Simp#- 3209552Simp# Copyright (c) 2010 iXsystems, Inc. All rights reserved. 4209513Simp# 5209513Simp# Redistribution and use in source and binary forms, with or without 6209513Simp# modification, are permitted provided that the following conditions 7209513Simp# are met: 8209513Simp# 1. Redistributions of source code must retain the above copyright 9209513Simp# notice, this list of conditions and the following disclaimer. 10209513Simp# 2. Redistributions in binary form must reproduce the above copyright 11209513Simp# notice, this list of conditions and the following disclaimer in the 12209513Simp# documentation and/or other materials provided with the distribution. 13209513Simp# 14209513Simp# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15209513Simp# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16209513Simp# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17209513Simp# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18209513Simp# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19209513Simp# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20209513Simp# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21209513Simp# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22209513Simp# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23209513Simp# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24209513Simp# SUCH DAMAGE. 25209513Simp# 26209513Simp# $FreeBSD: releng/10.2/usr.sbin/pc-sysinstall/backend/parseconfig.sh 247705 2013-03-03 09:47:47Z jpaetzel $ 27209513Simp 28209513Simp# Main install configuration parsing script 29209513Simp# 30209513Simp 31209513Simp# Source our functions scripts 32209513Simp. ${BACKEND}/functions.sh 33209513Simp. ${BACKEND}/functions-bsdlabel.sh 34209513Simp. ${BACKEND}/functions-cleanup.sh 35209513Simp. ${BACKEND}/functions-disk.sh 36209513Simp. ${BACKEND}/functions-extractimage.sh 37209513Simp. ${BACKEND}/functions-installcomponents.sh 38211485Simp. ${BACKEND}/functions-installpackages.sh 39209513Simp. ${BACKEND}/functions-localize.sh 40209513Simp. ${BACKEND}/functions-mountdisk.sh 41209513Simp. ${BACKEND}/functions-networking.sh 42209513Simp. ${BACKEND}/functions-newfs.sh 43211485Simp. ${BACKEND}/functions-packages.sh 44209513Simp. ${BACKEND}/functions-parse.sh 45209513Simp. ${BACKEND}/functions-runcommands.sh 46211485Simp. ${BACKEND}/functions-ftp.sh 47209513Simp. ${BACKEND}/functions-unmount.sh 48209513Simp. ${BACKEND}/functions-upgrade.sh 49209513Simp. ${BACKEND}/functions-users.sh 50209513Simp 51209513Simp# Check that the config file exists 52209513Simpif [ ! -e "${1}" ] 53209513Simpthen 54209513Simp echo "ERROR: Install configuration $1 does not exist!" 55209513Simp exit 1 56209513Simpfi 57209513Simp 58209513Simp# Set our config file variable 59209513SimpCFGF="$1" 60209513Simp 61225657Sjpaetzel# Resolve any relative pathing 62225657SjpaetzelCFGF="`realpath ${CFGF}`" 63209513Simpexport CFGF 64209513Simp 65209513Simp# Start by doing a sanity check, which will catch any obvious mistakes in the config 66218776Sjpaetzelfile_sanity_check "installMode installType installMedium packageType" 67209513Simp 68209513Simp# We passed the Sanity check, lets grab some of the universal config settings and store them 69218776Sjpaetzelcheck_value installMode "fresh upgrade extract" 70209513Simpcheck_value installType "PCBSD FreeBSD" 71225657Sjpaetzelcheck_value installMedium "dvd usb ftp rsync image local" 72247705Sjpaetzelcheck_value packageType "uzip tar rsync split dist" 73209513Simpif_check_value_exists mirrorbal "load prefer round-robin split" 74209513Simp 75209513Simp# We passed all sanity checks! Yay, lets start the install 76209513Simpecho "File Sanity Check -> OK" 77209513Simp 78209513Simp# Lets load the various universal settings now 79209513Simpget_value_from_cfg installMode 80220059Sjpaetzelexport INSTALLMODE="${VAL}" 81209513Simp 82209513Simpget_value_from_cfg installType 83220059Sjpaetzelexport INSTALLTYPE="${VAL}" 84209513Simp 85209513Simpget_value_from_cfg installMedium 86220059Sjpaetzelexport INSTALLMEDIUM="${VAL}" 87209513Simp 88209513Simpget_value_from_cfg packageType 89220059Sjpaetzelexport PACKAGETYPE="${VAL}" 90209513Simp 91209513Simp# Check if we are doing any networking setup 92209513Simpstart_networking 93209513Simp 94209513Simp# If we are not doing an upgrade, lets go ahead and setup the disk 95212337Simpcase "${INSTALLMODE}" in 96212337Simp fresh) 97213650Simp if [ "${INSTALLMEDIUM}" = "image" ] 98213650Simp then 99213650Simp install_image 100213650Simp else 101213650Simp install_fresh 102213650Simp fi 103212337Simp ;; 104209513Simp 105218776Sjpaetzel extract) 106218776Sjpaetzel # Extracting only, make sure we have a valid target directory 107218776Sjpaetzel get_value_from_cfg installLocation 108220059Sjpaetzel export FSMNT="${VAL}" 109218776Sjpaetzel if [ -z "$FSMNT" ] ; then exit_err "Missing installLocation=" ; fi 110218776Sjpaetzel if [ ! -d "$FSMNT" ] ; then exit_err "No such directory: $FSMNT" ; fi 111218776Sjpaetzel 112218776Sjpaetzel install_extractonly 113218776Sjpaetzel ;; 114218776Sjpaetzel 115212337Simp upgrade) 116212337Simp install_upgrade 117212337Simp ;; 118209513Simp 119212337Simp *) 120213650Simp exit 1 121212337Simp ;; 122212337Simpesac 123209513Simp 124212337Simpexit 0 125