Index: stable/9/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh =================================================================== --- stable/9/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh (revision 232414) +++ stable/9/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh (revision 232415) @@ -1,678 +1,695 @@ #!/bin/sh #- # Copyright (c) 2010 iXsystems, Inc. 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$ # Functions related to disk operations using bsdlabel # Check if we are are provided a geli password on the nextline of the config check_for_enc_pass() { CURLINE="${1}" get_next_cfg_line "${CFGF}" "${CURLINE}" echo ${VAL} | grep -q "^encpass=" 2>/dev/null if [ $? -eq 0 ] ; then # Found a password, return it get_value_from_string "${VAL}" return fi export VAL="" return }; # On check on the disk-label line if we have any extra vars for this device get_fs_line_xvars() { ACTIVEDEV="${1}" LINE="${2}" echo $LINE | grep -q ' (' 2>/dev/null if [ $? -eq 0 ] ; then # See if we are looking for ZFS specific options echo $LINE | grep -q '^ZFS' 2>/dev/null if [ $? -eq 0 ] ; then ZTYPE="NONE" ZFSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2)?|spare|log|cache):" 2>/dev/null if [ $? -eq 0 ] ; then ZTYPE=`echo $ZFSVARS | cut -f1 -d:` ZFSVARS=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"` fi # Return the ZFS options if [ "${ZTYPE}" = "NONE" ] ; then VAR="${ACTIVEDEV} ${ZFSVARS}" else VAR="${ZTYPE} ${ACTIVEDEV} ${ZFSVARS}" fi export VAR return fi # End of ZFS block # See if we are looking for UFS specific newfs options echo $LINE | grep -q '^UFS' 2>/dev/null if [ $? -eq 0 ] ; then FSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" VAR="${FSVARS}" export VAR return fi fi # End of xtra-options block # If we got here, set VAR to empty and export export VAR="" return }; # Init each zfs mirror disk with a boot sector so we can failover setup_zfs_mirror_parts() { _nZFS="" # Using mirroring, setup boot partitions on each disk _mirrline="`echo ${1} | sed 's|mirror ||g'`" for _zvars in $_mirrline do echo "Looping through _zvars: $_zvars" >>${LOGOUT} echo "$_zvars" | grep -q "${2}" 2>/dev/null if [ $? -eq 0 ] ; then continue ; fi if [ -z "$_zvars" ] ; then continue ; fi is_disk "$_zvars" >/dev/null 2>/dev/null if [ $? -eq 0 ] ; then echo "Setting up ZFS mirror disk $_zvars" >>${LOGOUT} init_gpt_full_disk "$_zvars" >/dev/null 2>/dev/null rc_halt "gpart add -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null _nZFS="$_nZFS ${_zvars}p2" else _nZFS="$_nZFS ${_zvars}" fi done echo "mirror $2 `echo $_nZFS | tr -s ' '`" } ; # Function which creates a unique label name for the specified mount gen_glabel_name() { MOUNT="$1" TYPE="$2" NUM="0" MAXNUM="20" # Check if we are doing /, and rename it if [ "$MOUNT" = "/" ] then NAME="rootfs" else # If doing a swap partition, also rename it if [ "${TYPE}" = "SWAP" ] then NAME="swap" else NAME="`echo $MOUNT | sed 's|/||g' | sed 's| ||g'`" fi fi # Loop through and break when we find our first available label while Z=1 do glabel status | grep -q "${NAME}${NUM}" 2>/dev/null if [ $? -ne 0 ] then break else NUM=$((NUM+1)) fi if [ $NUM -gt $MAXNUM ] then exit_err "Cannot allocate additional glabel name for $NAME" break fi done export VAL="${NAME}${NUM}" }; # Function to setup partitions using gpart setup_gpart_partitions() { local _dTag="$1" local _pDisk="$2" local _wSlice="$3" local _sNum="$4" local _pType="$5" FOUNDPARTS="1" # Lets read in the config file now and setup our partitions if [ "${_pType}" = "gpt" ] ; then CURPART="2" else PARTLETTER="a" CURPART="1" - rc_halt "gpart create -s BSD ${_wSlice}" + if [ "${_pType}" = "mbr" ] ; then + rc_halt "gpart create -s BSD ${_wSlice}" + fi fi while read line do # Check for data on this slice echo $line | grep -q "^${_dTag}-part=" 2>/dev/null if [ $? -eq 0 ] then FOUNDPARTS="0" # Found a slice- entry, lets get the slice info get_value_from_string "${line}" STRING="$VAL" # We need to split up the string now, and pick out the variables FS=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 1` SIZE=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 2` MNT=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 3` # Check if we have a .eli extension on this FS echo ${FS} | grep -q ".eli" 2>/dev/null if [ $? -eq 0 ] then FS="`echo ${FS} | cut -d '.' -f 1`" ENC="ON" check_for_enc_pass "${line}" if [ "${VAL}" != "" ] ; then # We have a user supplied password, save it for later ENCPASS="${VAL}" fi else ENC="OFF" fi # Check if the user tried to setup / as an encrypted partition check_for_mount "${MNT}" "/" if [ $? -eq 0 -a "${ENC}" = "ON" ] then export USINGENCROOT="0" fi # Now check that these values are sane case $FS in UFS|UFS+S|UFS+J|UFS+SUJ|ZFS|SWAP) ;; *) exit_err "ERROR: Invalid file system specified on $line" ;; esac # Check that we have a valid size number expr $SIZE + 1 >/dev/null 2>/dev/null if [ $? -ne 0 ]; then exit_err "ERROR: The size specified on $line is invalid" fi # Check that the mount-point starts with / echo "$MNT" | grep -qe "^/" -e "^none" 2>/dev/null if [ $? -ne 0 ]; then exit_err "ERROR: The mount-point specified on $line is invalid" fi if [ "$SIZE" = "0" ] then SOUT="" else SOUT="-s ${SIZE}M" fi # Check if we found a valid root partition check_for_mount "${MNT}" "/" if [ $? -eq 0 ] ; then export FOUNDROOT="1" if [ "${CURPART}" = "2" -a "$_pType" = "gpt" ] ; then export FOUNDROOT="0" fi if [ "${CURPART}" = "1" -a "$_pType" = "mbr" ] ; then export FOUNDROOT="0" fi + if [ "${CURPART}" = "1" -a "$_pType" = "gptslice" ] ; then + export FOUNDROOT="0" + fi fi check_for_mount "${MNT}" "/boot" if [ $? -eq 0 ] ; then export USINGBOOTPART="0" if [ "${CURPART}" != "2" -a "${_pType}" = "gpt" ] ; then exit_err "/boot partition must be first partition" fi if [ "${CURPART}" != "1" -a "${_pType}" = "mbr" ] ; then exit_err "/boot partition must be first partition" fi + if [ "${CURPART}" != "1" -a "${_pType}" = "gptslice" ] ; then + exit_err "/boot partition must be first partition" + fi if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" -a "${FS}" != "UFS+SUJ" ] ; then exit_err "/boot partition must be formatted with UFS" fi fi # Generate a unique label name for this mount gen_glabel_name "${MNT}" "${FS}" PLABEL="${VAL}" # Get any extra options for this fs / line if [ "${_pType}" = "gpt" ] ; then get_fs_line_xvars "${_pDisk}p${CURPART}" "${STRING}" else get_fs_line_xvars "${_wSlice}${PARTLETTER}" "${STRING}" fi XTRAOPTS="${VAR}" # Check if using zfs mirror echo ${XTRAOPTS} | grep -q "mirror" 2>/dev/null if [ $? -eq 0 -a "$FS" = "ZFS" ] ; then - if [ "${_pType}" = "gpt" ] ; then + if [ "${_pType}" = "gpt" -o "${_pType}" = "gptslice" ] ; then XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}p${CURPART}") else XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_wSlice}") fi fi # Figure out the gpart type to use case ${FS} in ZFS) PARTYPE="freebsd-zfs" ;; SWAP) PARTYPE="freebsd-swap" ;; *) PARTYPE="freebsd-ufs" ;; esac # Create the partition if [ "${_pType}" = "gpt" ] ; then if [ "$CURPART" = "2" ] ; then # If this is GPT, make sure first partition is aligned to 4k + sleep 2 rc_halt "gpart add -b 2016 ${SOUT} -t ${PARTYPE} ${_pDisk}" else + sleep 2 rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${_pDisk}" fi + elif [ "${_pType}" = "gptslice" ]; then + sleep 2 + rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${_wSlice}" else + sleep 2 rc_halt "gpart add ${SOUT} -t ${PARTYPE} -i ${CURPART} ${_wSlice}" fi # Check if this is a root / boot partition, and stamp the right loader for TESTMNT in `echo ${MNT} | sed 's|,| |g'` do if [ "${TESTMNT}" = "/" -a -z "${BOOTTYPE}" ] ; then BOOTTYPE="${PARTYPE}" fi if [ "${TESTMNT}" = "/boot" ] ; then BOOTTYPE="${PARTYPE}" fi done # Save this data to our partition config dir if [ "${_pType}" = "gpt" ] ; then _dFile="`echo $_pDisk | sed 's|/|-|g'`" echo "${FS}:${MNT}:${ENC}:${PLABEL}:GPT:${XTRAOPTS}" >${PARTDIR}/${_dFile}p${CURPART} # Clear out any headers sleep 2 dd if=/dev/zero of=${_pDisk}p${CURPART} count=2048 2>/dev/null # If we have a enc password, save it as well if [ -n "${ENCPASS}" ] ; then echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}p${CURPART}-encpass fi else - # MBR Partition + # MBR Partition or GPT slice _dFile="`echo $_wSlice | sed 's|/|-|g'`" echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}:${IMAGE}" >${PARTDIR}/${_dFile}${PARTLETTER} # Clear out any headers sleep 2 dd if=/dev/zero of=${_wSlice}${PARTLETTER} count=2048 2>/dev/null # If we have a enc password, save it as well if [ -n "${ENCPASS}" ] ; then echo "${ENCPASS}" >${PARTDIR}-enc/${_dFile}${PARTLETTER}-encpass fi fi # Increment our parts counter if [ "$_pType" = "gpt" ] ; then CURPART=$((CURPART+1)) # If this is a gpt partition, we can continue and skip the MBR part letter stuff continue else CURPART=$((CURPART+1)) if [ "$CURPART" = "3" ] ; then CURPART="4" ; fi fi # This partition letter is used, get the next one case ${PARTLETTER} in a) PARTLETTER="b" ;; b) PARTLETTER="d" ;; d) PARTLETTER="e" ;; e) PARTLETTER="f" ;; f) PARTLETTER="g" ;; g) PARTLETTER="h" ;; h) PARTLETTER="ERR" ;; *) exit_err "ERROR: bsdlabel only supports up to letter h for partitions." ;; esac fi # End of subsection locating a slice in config echo $line | grep -q "^commitDiskLabel" 2>/dev/null if [ $? -eq 0 -a "${FOUNDPARTS}" = "0" ] then # If this is the boot disk, stamp the right gptboot if [ ! -z "${BOOTTYPE}" -a "$_pType" = "gpt" ] ; then case ${BOOTTYPE} in freebsd-ufs) rc_halt "gpart bootcode -p /boot/gptboot -i 1 ${_pDisk}" ;; freebsd-zfs) rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${_pDisk}" ;; esac fi # Make sure to stamp the MBR loader if [ "$_pType" = "mbr" ] ; then rc_halt "gpart bootcode -b /boot/boot ${_wSlice}" fi # Found our flag to commit this label setup, check that we found at least 1 partition if [ "${CURPART}" = "2" ] ; then exit_err "ERROR: commitDiskLabel was called without any partition entries for it!" fi break fi done <${CFGF} }; # Reads through the config and sets up a BSDLabel for the given slice populate_disk_label() { if [ -z "${1}" ] then exit_err "ERROR: populate_disk_label() called without argument!" fi # Set some vars from the given working slice diskid="`echo $1 | cut -d ':' -f 1`" disk="`echo $1 | cut -d ':' -f 1 | sed 's|-|/|g'`" slicenum="`echo $1 | cut -d ':' -f 2`" type="`echo $1 | cut -d ':' -f 3`" # Set WRKSLICE based upon format we are using if [ "$type" = "mbr" ] ; then wrkslice="${diskid}s${slicenum}" fi - if [ "$type" = "gpt" ] ; then + if [ "$type" = "gpt" -o "$type" = "gptslice" ] ; then wrkslice="${diskid}p${slicenum}" fi if [ ! -e "${SLICECFGDIR}/${wrkslice}" ] ; then exit_err "ERROR: Missing SLICETAG data. This shouldn't happen - please let the developers know" fi disktag="`cat ${SLICECFGDIR}/${wrkslice}`" slicedev="`echo $wrkslice | sed 's|-|/|g'`" # Setup the partitions with gpart setup_gpart_partitions "${disktag}" "${disk}" "${slicedev}" "${slicenum}" "${type}" }; # Function which reads in the disk slice config, and performs it setup_disk_label() { # We are ready to start setting up the label, lets read the config and do the actions # First confirm that we have a valid WORKINGSLICES if [ -z "${WORKINGSLICES}" ]; then exit_err "ERROR: No slices were setup! Please report this to the maintainers" fi # Check that the slices we have did indeed get setup and gpart worked for i in $WORKINGSLICES do disk="`echo $i | cut -d '-' -f 1`" pnum="`echo $i | cut -d '-' -f 2`" type="`echo $i | cut -d '-' -f 3`" if [ "$type" = "mbr" -a ! -e "${disk}s${pnum}" ] ; then exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!" fi if [ "$type" = "gpt" -a ! -e "${disk}p${pnum}" ] ; then + exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!" + fi + if [ "$type" = "gptslice" -a ! -e "${disk}p${pnum}" ] ; then exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!" fi done # Setup some files which we'll be referring to export LABELLIST="${TMPDIR}/workingLabels" rm $LABELLIST >/dev/null 2>/dev/null # Set our flag to determine if we've got a valid root partition in this setup export FOUNDROOT="-1" # Check if we are using a /boot partition export USINGBOOTPART="1" # Set encryption on root check export USINGENCROOT="1" # Make the tmp directory where we'll store FS info & mount-points rm -rf ${PARTDIR} >/dev/null 2>/dev/null mkdir -p ${PARTDIR} >/dev/null 2>/dev/null rm -rf ${PARTDIR}-enc >/dev/null 2>/dev/null mkdir -p ${PARTDIR}-enc >/dev/null 2>/dev/null for i in $WORKINGSLICES do populate_disk_label "${i}" done # Check if we made a root partition if [ "$FOUNDROOT" = "-1" ] then exit_err "ERROR: No root (/) partition specified!!" fi # Check if we made a root partition if [ "$FOUNDROOT" = "1" -a "${USINGBOOTPART}" != "0" ] then exit_err "ERROR: (/) partition isn't first partition on disk!" fi if [ "${USINGENCROOT}" = "0" -a "${USINGBOOTPART}" != "0" ] then exit_err "ERROR: Can't encrypt (/) with no (/boot) partition!" fi }; check_fstab_mbr() { local SLICE local FSTAB if [ -z "$2" ] then return 1 fi SLICE="$1" FSTAB="$2/etc/fstab" if [ -f "${FSTAB}" ] then PARTLETTER=`echo "$SLICE" | sed -E 's|^.+([a-h])$|\1|'` cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/$' 2>&1 if [ $? -eq 0 ] then if [ "${PARTLETTER}" = "a" ] then FOUNDROOT="0" else FOUNDROOT="1" fi ROOTIMAGE="1" export FOUNDROOT export ROOTIMAGE fi cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/boot$' 2>&1 if [ $? -eq 0 ] then if [ "${PARTLETTER}" = "a" ] then USINGBOOTPART="0" else exit_err "/boot partition must be first partition" fi export USINGBOOTPART fi return 0 fi return 1 }; check_fstab_gpt() { local SLICE local FSTAB if [ -z "$2" ] then return 1 fi SLICE="$1" FSTAB="$2/etc/fstab" if [ -f "${FSTAB}" ] then PARTNUMBER=`echo "${SLICE}" | sed -E 's|^.+p([0-9]*)$|\1|'` cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/$' 2>&1 if [ $? -eq 0 ] then if [ "${PARTNUMBER}" = "2" ] then FOUNDROOT="0" else FOUNDROOT="1" fi ROOTIMAGE="1" export FOUNDROOT export ROOTIMAGE fi cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/boot$' 2>&1 if [ $? -eq 0 ] then if [ "${PARTNUMBER}" = "2" ] then USINGBOOTPART="0" else exit_err "/boot partition must be first partition" fi export USINGBOOTPART fi return 0 fi return 1 }; check_disk_layout() { local SLICES local TYPE local DISK local RES local F DISK="$1" TYPE="MBR" if [ -z "${DISK}" ] then return 1 fi SLICES_MBR=`ls /dev/${DISK}s[1-4]*[a-h]* 2>/dev/null` SLICES_GPT=`ls /dev/${DISK}p[0-9]* 2>/dev/null` SLICES_SLICE=`ls /dev/${DISK}[a-h]* 2>/dev/null` if [ -n "${SLICES_MBR}" ] then SLICES="${SLICES_MBR}" TYPE="MBR" RES=0 fi if [ -n "${SLICES_GPT}" ] then SLICES="${SLICES_GPT}" TYPE="GPT" RES=0 fi if [ -n "${SLICES_SLICE}" ] then SLICES="${SLICES_SLICE}" TYPE="MBR" RES=0 fi for slice in ${SLICES} do F=1 mount ${slice} /mnt 2>/dev/null if [ $? -ne 0 ] then continue fi if [ "${TYPE}" = "MBR" ] then check_fstab_mbr "${slice}" "/mnt" F="$?" elif [ "${TYPE}" = "GPT" ] then check_fstab_gpt "${slice}" "/mnt" F="$?" fi if [ ${F} -eq 0 ] then umount /mnt break fi umount /mnt done return ${RES} }; Index: stable/9/usr.sbin/pc-sysinstall/backend/functions-disk.sh =================================================================== --- stable/9/usr.sbin/pc-sysinstall/backend/functions-disk.sh (revision 232414) +++ stable/9/usr.sbin/pc-sysinstall/backend/functions-disk.sh (revision 232415) @@ -1,850 +1,909 @@ #!/bin/sh #- # Copyright (c) 2010 iXsystems, Inc. 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$ # Functions related to disk operations using gpart # See if device is a full disk or partition/slice is_disk() { for _dsk in `sysctl -n kern.disks` do [ "$_dsk" = "${1}" ] && return 0 done return 1 } # Get a MBR partitions sysid get_partition_sysid_mbr() { INPART="0" DISK="$1" PARTNUM=`echo ${2} | sed "s|${DISK}s||g"` fdisk ${DISK} >${TMPDIR}/disk-${DISK} 2>/dev/null while read i do echo "$i" | grep -q "The data for partition" 2>/dev/null if [ $? -eq 0 ] ; then INPART="0" PART="`echo ${i} | cut -d ' ' -f 5`" if [ "$PART" = "$PARTNUM" ] ; then INPART="1" fi fi # In the partition section if [ "$INPART" = "1" ] ; then echo "$i" | grep -q "^sysid" 2>/dev/null if [ $? -eq 0 ] ; then SYSID="`echo ${i} | tr -s '\t' ' ' | cut -d ' ' -f 2`" break fi fi done < ${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} export VAL="${SYSID}" }; # Get the partitions MBR label get_partition_label_mbr() { INPART="0" DISK="$1" PARTNUM=`echo ${2} | sed "s|${DISK}s||g"` fdisk ${DISK} >${TMPDIR}/disk-${DISK} 2>/dev/null while read i do echo "$i" | grep -q "The data for partition" 2>/dev/null if [ $? -eq 0 ] ; then INPART="0" PART="`echo ${i} | cut -d ' ' -f 5`" if [ "$PART" = "$PARTNUM" ] ; then INPART="1" fi fi # In the partition section if [ "$INPART" = "1" ] ; then echo "$i" | grep -q "^sysid" 2>/dev/null if [ $? -eq 0 ] ; then LABEL="`echo ${i} | tr -s '\t' ' ' | cut -d ',' -f 2-10`" break fi fi done < ${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} export VAL="${LABEL}" }; # Get a GPT partitions label get_partition_label_gpt() { DISK="${1}" PARTNUM=`echo ${2} | sed "s|${DISK}p||g"` gpart show ${DISK} >${TMPDIR}/disk-${DISK} while read i do SLICE="`echo ${i} | grep -v ${DISK} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 3`" if [ "${SLICE}" = "${PARTNUM}" ] ; then LABEL="`echo ${i} | grep -v ${DISK} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 4`" break fi done <${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} export VAL="${LABEL}" }; # Get a partitions startblock get_partition_startblock() { DISK="${1}" PARTNUM=`echo ${2} | sed "s|${DISK}p||g" | sed "s|${DISK}s||g"` gpart show ${DISK} >${TMPDIR}/disk-${DISK} while read i do SLICE="`echo ${i} | grep -v ${DISK} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 3`" if [ "$SLICE" = "${PARTNUM}" ] ; then SB="`echo ${i} | grep -v ${DISK} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 1`" break fi done <${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} export VAL="${SB}" }; # Get a partitions blocksize get_partition_blocksize() { DISK="${1}" PARTNUM=`echo ${2} | sed "s|${DISK}p||g" | sed "s|${DISK}s||g"` gpart show ${DISK} >${TMPDIR}/disk-${DISK} while read i do SLICE="`echo ${i} | grep -v ${DISK} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 3`" if [ "$SLICE" = "${PARTNUM}" ] ; then BS="`echo ${i} | grep -v ${DISK} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 2`" break fi done <${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} export VAL="${BS}" }; # Function which returns the partitions on a target disk get_disk_partitions() { gpart show ${1} >/dev/null 2>/dev/null if [ $? -ne 0 ] ; then export VAL="" return fi type=`gpart show ${1} | awk '/^=>/ { printf("%s",$5); }'` SLICES="`gpart show ${1} | grep -v ${1} | grep -v ' free ' |tr -s '\t' ' ' | cut -d ' ' -f 4 | sed '/^$/d'`" for i in ${SLICES} do case $type in MBR) name="${1}s${i}" ;; GPT) name="${1}p${i}";; *) name="${1}s${i}";; esac if [ -z "${RSLICES}" ] then RSLICES="${name}" else RSLICES="${RSLICES} ${name}" fi done export VAL="${RSLICES}" }; # Function which returns a target disks cylinders get_disk_cyl() { cyl=`diskinfo -v ${1} | grep "# Cylinders" | tr -s ' ' | cut -f 2` export VAL="${cyl}" }; # Function which returns a target disks sectors get_disk_sectors() { sec=`diskinfo -v ${1} | grep "# Sectors" | tr -s ' ' | cut -f 2` export VAL="${sec}" }; # Function which returns a target disks heads get_disk_heads() { head=`diskinfo -v ${1} | grep "# Heads" | tr -s ' ' | cut -f 2` export VAL="${head}" }; # Function which returns a target disks mediasize in sectors get_disk_mediasize() { mediasize=`diskinfo -v ${1} | grep "# mediasize in sectors" | tr -s ' ' | cut -f 2` export VAL="${mediasize}" }; # Function which exports all zpools, making them safe to overwrite potentially export_all_zpools() { # Export any zpools for i in `zpool list -H -o name` do zpool export -f ${i} done }; # Function to delete all gparts before starting an install delete_all_gpart() { echo_log "Deleting all gparts" local DISK="$1" # Check for any swaps to stop for i in `swapctl -l | grep "$DISK" | awk '{print $1}'` do swapoff ${i} >/dev/null 2>/dev/null done # Delete the gparts now for i in `gpart show ${DISK} 2>/dev/null | tr -s ' ' | cut -d ' ' -f 4` do if [ "/dev/${i}" != "${DISK}" -a "${i}" != "-" ] ; then rc_nohalt "gpart delete -i ${i} ${DISK}" fi done # Destroy the disk geom rc_nohalt "gpart destroy ${DISK}" # Make sure we clear any hidden gpt tables clear_backup_gpt_table "${DISK}" # Wipe out front of disk rc_nohalt "dd if=/dev/zero of=${DISK} count=3000" }; # Function to export all zpools before starting an install stop_all_zfs() { # Export all zpools again, so that we can overwrite these partitions potentially for i in `zpool list -H -o name` do zpool export -f ${i} done }; # Function which stops all gmirrors before doing any disk manipulation stop_all_gmirror() { local DISK="`echo ${1} | sed 's|/dev/||g'`" GPROV="`gmirror list | grep ". Name: mirror/" | cut -d '/' -f 2`" for gprov in $GPROV do gmirror list | grep -q "Name: ${DISK}" 2>/dev/null if [ $? -eq 0 ] then echo_log "Stopping mirror $gprov $DISK" rc_nohalt "gmirror remove $gprov $DISK" rc_nohalt "dd if=/dev/zero of=/dev/${DISK} count=4096" fi done }; # Make sure we don't have any geli providers active on this disk stop_all_geli() { local _geld="`echo ${1} | sed 's|/dev/||g'`" cd /dev for i in `ls ${_geld}*` do echo $i | grep -q '.eli' 2>/dev/null if [ $? -eq 0 ] then echo_log "Detaching GELI on ${i}" rc_halt "geli detach ${i}" fi done }; # Function which reads in the disk slice config, and performs it setup_disk_slice() { # Cleanup any slice / mirror dirs rm -rf ${SLICECFGDIR} >/dev/null 2>/dev/null mkdir ${SLICECFGDIR} rm -rf ${MIRRORCFGDIR} >/dev/null 2>/dev/null mkdir ${MIRRORCFGDIR} # Start with disk0 and gm0 disknum="0" gmnum="0" # Make sure all zpools are exported export_all_zpools # We are ready to start setting up the disks, lets read the config and do the actions while read line do echo $line | grep -q "^disk${disknum}=" 2>/dev/null if [ $? -eq 0 ] then # Found a disk= entry, lets get the disk we are working on get_value_from_string "${line}" strip_white_space "$VAL" DISK="$VAL" echo "${DISK}" | grep -q '^/dev/' if [ $? -ne 0 ] ; then DISK="/dev/$DISK" ; fi # Before we go further, lets confirm this disk really exists if [ ! -e "${DISK}" ] ; then exit_err "ERROR: The disk ${DISK} does not exist!" fi # Make sure we stop any gmirrors on this disk stop_all_gmirror ${DISK} # Make sure we stop any geli stuff on this disk stop_all_geli ${DISK} # Make sure we don't have any zpools loaded stop_all_zfs fi # Lets look if this device will be mirrored on another disk echo $line | grep -q "^mirror=" 2>/dev/null if [ $? -eq 0 ] then # Found a disk= entry, lets get the disk we are working on get_value_from_string "${line}" strip_white_space "$VAL" MIRRORDISK="$VAL" echo "${MIRRORDISK}" | grep -q '^/dev/' if [ $? -ne 0 ] ; then MIRRORDISK="/dev/$MIRRORDISK" ; fi # Before we go further, lets confirm this disk really exists if [ ! -e "${MIRRORDISK}" ] then exit_err "ERROR: The mirror disk ${MIRRORDISK} does not exist!" fi fi # Lets see if we have been given a mirror balance choice echo $line | grep -q "^mirrorbal=" 2>/dev/null if [ $? -eq 0 ] then # Found a disk= entry, lets get the disk we are working on get_value_from_string "${line}" strip_white_space "$VAL" MIRRORBAL="$VAL" fi echo $line | grep -q "^partition=" 2>/dev/null if [ $? -eq 0 ] then # Found a partition= entry, lets read / set it get_value_from_string "${line}" strip_white_space "$VAL" PTYPE=`echo $VAL|tr A-Z a-z` # We are using free space, figure out the slice number if [ "${PTYPE}" = "free" ] then # Lets figure out what number this slice will be LASTSLICE="`gpart show ${DISK} \ | grep -v ${DISK} \ | grep -v ' free' \ | tr -s '\t' ' ' \ | cut -d ' ' -f 4 \ | sed '/^$/d' \ | tail -n 1`" if [ -z "${LASTSLICE}" ] then LASTSLICE="1" else LASTSLICE=$((LASTSLICE+1)) fi if [ $LASTSLICE -gt 4 ] then exit_err "ERROR: BSD only supports primary partitions, and there are none availble on $DISK" fi fi fi # Check if we have an image file defined echo $line | grep -q "^image=" 2>/dev/null if [ $? -eq 0 ] ; then # Found an image= entry, lets read / set it get_value_from_string "${line}" strip_white_space "$VAL" IMAGE="$VAL" if [ ! -f "$IMAGE" ] ; then exit_err "$IMAGE file does not exist" fi fi # Check if we have a partscheme specified echo $line | grep -q "^partscheme=" 2>/dev/null if [ $? -eq 0 ] ; then # Found a partscheme= entry, lets read / set it get_value_from_string "${line}" strip_white_space "$VAL" PSCHEME="$VAL" if [ "$PSCHEME" != "GPT" -a "$PSCHEME" != "MBR" ] ; then exit_err "Unknown partition scheme: $PSCHEME" fi fi echo $line | grep -q "^bootManager=" 2>/dev/null if [ $? -eq 0 ] then # Found a bootManager= entry, lets read /set it get_value_from_string "${line}" strip_white_space "$VAL" BMANAGER="$VAL" fi echo $line | grep -q "^commitDiskPart" 2>/dev/null if [ $? -eq 0 ] then # Found our flag to commit this disk setup / lets do sanity check and do it if [ ! -z "${DISK}" -a ! -z "${PTYPE}" ] then case ${PTYPE} in all) # If we have a gmirror, lets set it up if [ -n "$MIRRORDISK" ]; then # Default to round-robin if the user didn't specify if [ -z "$MIRRORBAL" ]; then MIRRORBAL="round-robin" ; fi _mFile=`echo $DISK | sed 's|/|%|g'` echo "$MIRRORDISK:$MIRRORBAL:gm${gmnum}" >${MIRRORCFGDIR}/$_mFile init_gmirror "$gmnum" "$MIRRORBAL" "$DISK" "$MIRRORDISK" # Reset DISK to the gmirror device DISK="/dev/mirror/gm${gmnum}" gmnum=$((gmknum+1)) fi if [ "$PSCHEME" = "MBR" -o -z "$PSCHEME" ] ; then PSCHEME="MBR" tmpSLICE="${DISK}s1" else tmpSLICE="${DISK}p1" fi run_gpart_full "${DISK}" "${BMANAGER}" "${PSCHEME}" ;; s1|s2|s3|s4) tmpSLICE="${DISK}${PTYPE}" # Get the number of the slice we are working on s="`echo ${PTYPE} | awk '{print substr($0,length,1)}'`" run_gpart_slice "${DISK}" "${BMANAGER}" "${s}" ;; + p1|p2|p3|p4|p5|p6|p7|p8|p9|p10|p11|p12|p13|p14|p15|p16|p17|p18|p19|p20) + tmpSLICE="${DISK}${PTYPE}" + # Get the number of the gpt partition we are working on + s="`echo ${PTYPE} | awk '{print substr($0,length,1)}'`" + run_gpart_gpt_part "${DISK}" "${BMANAGER}" "${s}" + ;; + free) tmpSLICE="${DISK}s${LASTSLICE}" run_gpart_free "${DISK}" "${LASTSLICE}" "${BMANAGER}" ;; image) if [ -z "${IMAGE}" ] then exit_err "ERROR: partition type image specified with no image!" fi ;; *) exit_err "ERROR: Unknown PTYPE: $PTYPE" ;; esac if [ -n "${IMAGE}" ] then local DEST if [ -n "${tmpSLICE}" ] then DEST="${tmpSLICE}" else DEST="${DISK}" fi write_image "${IMAGE}" "${DEST}" check_disk_layout "${DEST}" fi # Now save which disk this is, so we can parse it later during slice partition setup if [ -z "${IMAGE}" ] then _sFile=`echo $tmpSLICE | sed 's|/|-|g'` echo "disk${disknum}" >${SLICECFGDIR}/$_sFile fi # Increment our disk counter to look for next disk and unset unset BMANAGER PTYPE DISK MIRRORDISK MIRRORBAL PSCHEME IMAGE disknum=$((disknum+1)) else exit_err "ERROR: commitDiskPart was called without procceding disk= and partition= entries!!!" fi fi done <${CFGF} }; # Init the gmirror device init_gmirror() { local _mNum=$1 local _mBal=$2 local _mDisk=$3 # Create this mirror device rc_halt "gmirror label -vb ${_mBal} gm${_mNum} ${_mDisk}" sleep 3 } # Stop all gjournals on disk / slice stop_gjournal() { _gdsk="`echo $1 | sed 's|/dev/||g'`" # Check if we need to shutdown any journals on this drive ls /dev/${_gdsk}*.journal >/dev/null 2>/dev/null if [ $? -eq 0 ] then cd /dev for i in `ls ${_gdsk}*.journal` do rawjournal="`echo ${i} | cut -d '.' -f 1`" gjournal stop -f ${rawjournal} >>${LOGOUT} 2>>${LOGOUT} gjournal clear ${rawjournal} >>${LOGOUT} 2>>${LOGOUT} done fi } ; # Function to wipe the potential backup gpt table from a disk clear_backup_gpt_table() { echo_log "Clearing gpt backup table location on disk" rc_nohalt "dd if=/dev/zero of=${1} bs=1m count=1" rc_nohalt "dd if=/dev/zero of=${1} bs=1m oseek=`diskinfo ${1} | awk '{print int($3 / (1024*1024)) - 4;}'`" } ; # Function which runs gpart and creates a single large GPT partition scheme init_gpt_full_disk() { _intDISK=$1 # Set our sysctl so we can overwrite any geom using drives sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT} # Stop any journaling stop_gjournal "${_intDISK}" # Remove any existing partitions delete_all_gpart "${_intDISK}" sleep 2 echo_log "Running gpart on ${_intDISK}" rc_halt "gpart create -s GPT ${_intDISK}" rc_halt "gpart add -b 34 -s 128 -t freebsd-boot ${_intDISK}" echo_log "Stamping boot sector on ${_intDISK}" rc_halt "gpart bootcode -b /boot/pmbr ${_intDISK}" } # Function which runs gpart and creates a single large MBR partition scheme init_mbr_full_disk() { _intDISK=$1 _intBOOT=$2 startblock="2016" # Set our sysctl so we can overwrite any geom using drives sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT} # Stop any journaling stop_gjournal "${_intDISK}" # Remove any existing partitions delete_all_gpart "${_intDISK}" sleep 2 echo_log "Running gpart on ${_intDISK}" rc_halt "gpart create -s mbr ${_intDISK}" # Lets figure out disk size in blocks # Get the cyl of this disk get_disk_cyl "${_intDISK}" cyl="${VAL}" # Get the heads of this disk get_disk_heads "${_intDISK}" head="${VAL}" # Get the tracks/sectors of this disk get_disk_sectors "${_intDISK}" sec="${VAL}" # Multiply them all together to get our total blocks totalblocks="`expr ${cyl} \* ${head} 2>/dev/null`" totalblocks="`expr ${totalblocks} \* ${sec} 2>/dev/null`" if [ -z "${totalblocks}" ] then totalblocks=`gpart show "${_intDISK}"|tail -2|head -1|awk '{ print $2 }'` fi # Now set the ending block to the total disk block size sizeblock="`expr ${totalblocks} - ${startblock}`" # Install new partition setup echo_log "Running gpart add on ${_intDISK}" rc_halt "gpart add -b ${startblock} -s ${sizeblock} -t freebsd -i 1 ${_intDISK}" sleep 2 echo_log "Cleaning up ${_intDISK}s1" rc_halt "dd if=/dev/zero of=${_intDISK}s1 count=1024" if [ "$_intBOOT" = "bsd" ] ; then echo_log "Stamping boot0 on ${_intDISK}" rc_halt "gpart bootcode -b /boot/boot0 ${_intDISK}" else echo_log "Stamping boot1 on ${_intDISK}" rc_halt "gpart bootcode -b /boot/boot1 ${_intDISK}" fi } # Function which runs gpart and creates a single large slice run_gpart_full() { DISK=$1 BOOT=$2 SCHEME=$3 if [ "$SCHEME" = "MBR" ] ; then init_mbr_full_disk "$DISK" "$BOOT" slice=`echo "${DISK}:1:mbr" | sed 's|/|-|g'` else init_gpt_full_disk "$DISK" slice=`echo "${DISK}:1:gpt" | sed 's|/|-|g'` fi + + # Lets save our slice, so we know what to look for in the config file later on + if [ -z "$WORKINGSLICES" ] + then + WORKINGSLICES="${slice}" + export WORKINGSLICES + else + WORKINGSLICES="${WORKINGSLICES} ${slice}" + export WORKINGSLICES + fi +}; + +# Function which runs gpart on a specified gpt partition +run_gpart_gpt_part() +{ + DISK=$1 + + # Set the slice we will use later + slice="${1}p${3}" + + # Set our sysctl so we can overwrite any geom using drives + sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT} + + # Get the number of the slice we are working on + slicenum="$3" + + # Stop any journaling + stop_gjournal "${slice}" + + # Make sure we have disabled swap on this drive + if [ -e "${slice}b" ] + then + swapoff ${slice}b >/dev/null 2>/dev/null + swapoff ${slice}b.eli >/dev/null 2>/dev/null + fi + + # Modify partition type + echo_log "Running gpart modify on ${DISK}" + rc_halt "gpart modify -t freebsd -i ${slicenum} ${DISK}" + sleep 2 + + # Clean up old partition + echo_log "Cleaning up $slice" + rc_halt "dd if=/dev/zero of=${DISK}p${slicenum} count=1024" + + sleep 4 + + # Init the MBR partition + rc_halt "gpart create -s BSD ${DISK}p${slicenum}" + + # Set the slice to the format we'll be using for gpart later + slice=`echo "${1}:${3}:gptslice" | sed 's|/|-|g'` # Lets save our slice, so we know what to look for in the config file later on if [ -z "$WORKINGSLICES" ] then WORKINGSLICES="${slice}" export WORKINGSLICES else WORKINGSLICES="${WORKINGSLICES} ${slice}" export WORKINGSLICES fi }; # Function which runs gpart on a specified s1-4 slice run_gpart_slice() { DISK=$1 if [ -n "$2" ] then BMANAGER="$2" fi # Set the slice we will use later slice="${1}s${3}" # Set our sysctl so we can overwrite any geom using drives sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT} # Get the number of the slice we are working on slicenum="$3" # Stop any journaling stop_gjournal "${slice}" # Make sure we have disabled swap on this drive if [ -e "${slice}b" ] then swapoff ${slice}b >/dev/null 2>/dev/null swapoff ${slice}b.eli >/dev/null 2>/dev/null fi # Modify partition type echo_log "Running gpart modify on ${DISK}" rc_halt "gpart modify -t freebsd -i ${slicenum} ${DISK}" sleep 2 # Clean up old partition echo_log "Cleaning up $slice" rc_halt "dd if=/dev/zero of=${DISK}s${slicenum} count=1024" sleep 1 if [ "${BMANAGER}" = "bsd" ] then echo_log "Stamping boot sector on ${DISK}" rc_halt "gpart bootcode -b /boot/boot0 ${DISK}" fi # Set the slice to the format we'll be using for gpart later slice=`echo "${1}:${3}:mbr" | sed 's|/|-|g'` # Lets save our slice, so we know what to look for in the config file later on if [ -z "$WORKINGSLICES" ] then WORKINGSLICES="${slice}" export WORKINGSLICES else WORKINGSLICES="${WORKINGSLICES} ${slice}" export WORKINGSLICES fi }; # Function which runs gpart and creates a new slice from free disk space run_gpart_free() { DISK=$1 SLICENUM=$2 if [ -n "$3" ] then BMANAGER="$3" fi # Set our sysctl so we can overwrite any geom using drives sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT} slice="${DISK}s${SLICENUM}" slicenum="${SLICENUM}" # Working on the first slice, make sure we have MBR setup gpart show ${DISK} >/dev/null 2>/dev/null if [ $? -ne 0 -a "$SLICENUM" = "1" ] ; then echo_log "Initializing disk, no existing MBR setup" rc_halt "gpart create -s mbr ${DISK}" fi # Lets get the starting block first if [ "${slicenum}" = "1" ] then startblock="63" else # Lets figure out where the prior slice ends checkslice=$((slicenum-1)) # Get starting block of this slice sblk=`gpart show ${DISK} | grep -v ${DISK} | tr -s '\t' ' ' | sed '/^$/d' | grep " ${checkslice} " | cut -d ' ' -f 2` blksize=`gpart show ${DISK} | grep -v ${DISK} | tr -s '\t' ' ' | sed '/^$/d' | grep " ${checkslice} " | cut -d ' ' -f 3` startblock=$((sblk+blksiz)) fi # No slice after the new slice, lets figure out the free space remaining and use it # Get the cyl of this disk get_disk_cyl "${DISK}" cyl="${VAL}" # Get the heads of this disk get_disk_heads "${DISK}" head="${VAL}" # Get the tracks/sectors of this disk get_disk_sectors "${DISK}" sec="${VAL}" # Multiply them all together to get our total blocks totalblocks=$((cyl*head)) totalblocks=$((totalblocks*sec)) # Now set the ending block to the total disk block size sizeblock=$((totalblocks-startblock)) # Install new partition setup echo_log "Running gpart on ${DISK}" rc_halt "gpart add -b ${startblock} -s ${sizeblock} -t freebsd -i ${slicenum} ${DISK}" sleep 2 echo_log "Cleaning up $slice" rc_halt "dd if=/dev/zero of=${slice} count=1024" sleep 1 if [ "${BMANAGER}" = "bsd" ] then echo_log "Stamping boot sector on ${DISK}" rc_halt "gpart bootcode -b /boot/boot0 ${DISK}" fi slice=`echo "${DISK}:${SLICENUM}:mbr" | sed 's|/|-|g'` # Lets save our slice, so we know what to look for in the config file later on if [ -z "$WORKINGSLICES" ] then WORKINGSLICES="${slice}" export WORKINGSLICES else WORKINGSLICES="${WORKINGSLICES} ${slice}" export WORKINGSLICES fi }; Index: stable/9/usr.sbin/pc-sysinstall/backend/parseconfig.sh =================================================================== --- stable/9/usr.sbin/pc-sysinstall/backend/parseconfig.sh (revision 232414) +++ stable/9/usr.sbin/pc-sysinstall/backend/parseconfig.sh (revision 232415) @@ -1,125 +1,124 @@ #!/bin/sh #- # Copyright (c) 2010 iXsystems, Inc. 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$ # Main install configuration parsing script # # Source our functions scripts . ${BACKEND}/functions.sh . ${BACKEND}/functions-bsdlabel.sh . ${BACKEND}/functions-cleanup.sh . ${BACKEND}/functions-disk.sh . ${BACKEND}/functions-extractimage.sh . ${BACKEND}/functions-installcomponents.sh . ${BACKEND}/functions-installpackages.sh . ${BACKEND}/functions-localize.sh . ${BACKEND}/functions-mountdisk.sh . ${BACKEND}/functions-networking.sh . ${BACKEND}/functions-newfs.sh . ${BACKEND}/functions-packages.sh . ${BACKEND}/functions-parse.sh . ${BACKEND}/functions-runcommands.sh . ${BACKEND}/functions-ftp.sh . ${BACKEND}/functions-unmount.sh . ${BACKEND}/functions-upgrade.sh . ${BACKEND}/functions-users.sh # Check that the config file exists if [ ! -e "${1}" ] then echo "ERROR: Install configuration $1 does not exist!" exit 1 fi # Set our config file variable CFGF="$1" # Resolve any relative pathing CFGF="`realpath ${CFGF}`" export CFGF # Start by doing a sanity check, which will catch any obvious mistakes in the config file_sanity_check "installMode installType installMedium packageType" # We passed the Sanity check, lets grab some of the universal config settings and store them check_value installMode "fresh upgrade extract" check_value installType "PCBSD FreeBSD" check_value installMedium "dvd usb ftp rsync image local" check_value packageType "uzip tar rsync split" -if_check_value_exists partition "all s1 s2 s3 s4 free image" if_check_value_exists mirrorbal "load prefer round-robin split" # We passed all sanity checks! Yay, lets start the install echo "File Sanity Check -> OK" # Lets load the various universal settings now get_value_from_cfg installMode export INSTALLMODE="${VAL}" get_value_from_cfg installType export INSTALLTYPE="${VAL}" get_value_from_cfg installMedium export INSTALLMEDIUM="${VAL}" get_value_from_cfg packageType export PACKAGETYPE="${VAL}" # Check if we are doing any networking setup start_networking # If we are not doing an upgrade, lets go ahead and setup the disk case "${INSTALLMODE}" in fresh) if [ "${INSTALLMEDIUM}" = "image" ] then install_image else install_fresh fi ;; extract) # Extracting only, make sure we have a valid target directory get_value_from_cfg installLocation export FSMNT="${VAL}" if [ -z "$FSMNT" ] ; then exit_err "Missing installLocation=" ; fi if [ ! -d "$FSMNT" ] ; then exit_err "No such directory: $FSMNT" ; fi install_extractonly ;; upgrade) install_upgrade ;; *) exit 1 ;; esac exit 0 Index: stable/9/usr.sbin/pc-sysinstall =================================================================== --- stable/9/usr.sbin/pc-sysinstall (revision 232414) +++ stable/9/usr.sbin/pc-sysinstall (revision 232415) Property changes on: stable/9/usr.sbin/pc-sysinstall ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head/usr.sbin/pc-sysinstall:r227368