Index: head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh (revision 211730) @@ -1,634 +1,633 @@ #!/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 "^encpass=" >/dev/null 2>/dev/null if [ "$?" = "0" ] ; then # Found a password, return it get_value_from_string "${VAL}" return fi VAL="" ; export VAL return }; # On check on the disk-label line if we have any extra vars for this device # Only enabled for ZFS devices now, may add other xtra options in future for other FS's get_fs_line_xvars() { ACTIVEDEV="${1}" LINE="${2}" echo $LINE | grep ' (' >/dev/null 2>/dev/null if [ "$?" = "0" ] ; then # See if we are looking for ZFS specific options echo $LINE | grep '^ZFS' >/dev/null 2>/dev/null if [ "$?" = "0" ] ; then ZTYPE="NONE" ZFSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`" echo $ZFSVARS | grep -E "^(disk|file|mirror|raidz(1|2)?|spare|log|cache):" >/dev/null 2>/dev/null if [ "$?" = "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 - fi # End of xtra-options block # If we got here, set VAR to empty and export VAR="" 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 "${2}" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then continue ; fi - if [ -z "$_zvars" ] ; then continue ; fi +setup_zfs_mirror_parts() +{ + _nZFS="" - is_disk "$_zvars" >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then - echo "Setting up ZFS mirror disk $_zvars" >>${LOGOUT} - init_gpt_full_disk "$_zvars" >/dev/null 2>/dev/null - rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${_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 ' '`" + # 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 "${2}" >/dev/null 2>/dev/null + if [ "$?" = "0" ] ; then continue ; fi + if [ -z "$_zvars" ] ; then continue ; fi + + is_disk "$_zvars" >/dev/null 2>/dev/null + if [ "$?" = "0" ] ; then + echo "Setting up ZFS mirror disk $_zvars" >>${LOGOUT} + init_gpt_full_disk "$_zvars" >/dev/null 2>/dev/null + rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${_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 "${NAME}${NUM}" >/dev/null 2>/dev/null if [ "$?" != "0" ] then break else NUM="`expr ${NUM} + 1`" fi if [ $NUM -gt $MAXNUM ] then exit_err "Cannot allocate additional glabel name for $NAME" break fi done VAL="${NAME}${NUM}" export VAL }; # Function to setup / stamp a legacy MBR bsdlabel setup_mbr_partitions() { - DISKTAG="$1" WRKSLICE="$2" FOUNDPARTS="1" # Lets setup the BSDLABEL BSDLABEL="${TMPDIR}/bsdLabel-${WRKSLICE}" export BSDLABEL rm $BSDLABEL >/dev/null 2>/dev/null echo "# /dev/${WRKSLICE}" >>$BSDLABEL echo "8 partitions:" >>$BSDLABEL echo "# size offset fstype bsize bps/cpg" >>$BSDLABEL PARTLETTER="a" # Lets read in the config file now and populate this while read line do # Check for data on this slice echo $line | grep "^${DISKTAG}-part=" >/dev/null 2>/dev/null if [ "$?" = "0" ] then # Found a slice- entry, lets get the slice info get_value_from_string "${line}" STRING="$VAL" FOUNDPARTS="0" # 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 ".eli" >/dev/null 2>/dev/null if [ "$?" = "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 [ "${?}" = "0" -a "${ENC}" = "ON" ] then USINGENCROOT="0" ; export USINGENCROOT fi # Now check that these values are sane case $FS in - UFS|UFS+S|UFS+J|ZFS|SWAP) ;; + UFS|UFS+S|UFS+J|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 [ "$?" != "0" ]; then exit_err "ERROR: The size specified on $line is invalid" fi # Check that the mount-point starts with / echo "$MNT" | grep -e "^/" -e "^none" >/dev/null 2>/dev/null if [ "$?" != "0" ]; then exit_err "ERROR: The mount-point specified on $line is invalid" fi if [ "$SIZE" = "0" ] then SOUT="*" else SOUT="${SIZE}M" fi # OK, we passed all tests, now lets put these values into a config # If the part if [ "${PARTLETTER}" = "a" ] then if [ "$FS" = "SWAP" ] then echo "a: ${SOUT} * swap 0 0" >>${BSDLABEL} else echo "a: ${SOUT} 0 4.2BSD 0 0" >>${BSDLABEL} fi # Check if we found a valid root partition check_for_mount "${MNT}" "/" if [ "$?" = "0" ] ; then FOUNDROOT="0" ; export FOUNDROOT fi # Check if we have a "/boot" instead check_for_mount "${MNT}" "/boot" if [ "${?}" = "0" ] ; then USINGBOOTPART="0" ; export USINGBOOTPART if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" ] then exit_err "/boot partition must be formatted with UFS" fi fi else # Done with the a: partitions # Check if we found a valid root partition not on a: check_for_mount "${MNT}" "/" if [ "${?}" = "0" ] ; then FOUNDROOT="1" ; export FOUNDROOT fi # Check if we have a /boot partition, and fail since its not first check_for_mount "${MNT}" "/boot" if [ "${?}" = "0" ] ; then exit_err "/boot partition must be first partition" fi if [ "$FS" = "SWAP" ] then echo "${PARTLETTER}: ${SOUT} * swap" >>${BSDLABEL} else echo "${PARTLETTER}: ${SOUT} * 4.2BSD" >>${BSDLABEL} 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 get_fs_line_xvars "${WRKSLICE}${PARTLETTER}" "${STRING}" XTRAOPTS="${VAR}" # Check if using zfs mirror echo ${XTRAOPTS} | grep "mirror" >/dev/null 2>/dev/null if [ "$?" = "0" ] ; then XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${WRKSLICE}${PARTLETTER}") fi # Save this data to our partition config dir echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}" >${PARTDIR}/${WRKSLICE}${PARTLETTER} # If we have a enc password, save it as well if [ ! -z "${ENCPASS}" ] ; then echo "${ENCPASS}" >${PARTDIR}-enc/${WRKSLICE}${PARTLETTER}-encpass fi # This partition letter is used, get the next one case ${PARTLETTER} in - a) PARTLETTER="b" ;; - b) # When we hit b, add the special c: setup for bsdlabel - echo "c: * * unused" >>${BSDLABEL} - 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." ;; + a) PARTLETTER="b" ;; + b) # When we hit b, add the special c: setup for bsdlabel + echo "c: * * unused" >>${BSDLABEL} + 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 "^commitDiskLabel" >/dev/null 2>/dev/null if [ "$?" = "0" -a "${FOUNDPARTS}" = "0" ] then # Found our flag to commit this label setup, check that we found at least 1 partition and do it if [ "${PARTLETTER}" != "a" ] then # Check if we only had 1 partition, and make sure we add "c:" section to label if [ "${PARTLETTER}" = "b" ] then echo "c: * * unused" >>${BSDLABEL} fi echo "bsdlabel -R -B /dev/${WRKSLICE} ${BSDLABEL}" bsdlabel -R -B ${WRKSLICE} ${BSDLABEL} break else exit_err "ERROR: commitDiskLabel was called without any partition entries for it!" fi fi done <${CFGF} }; # Function to setup partitions using gpt setup_gpt_partitions() { DISKTAG="$1" DISK="$2" FOUNDPARTS="1" # Lets read in the config file now and setup our GPT partitions CURPART="2" while read line do # Check for data on this slice echo $line | grep "^${DISKTAG}-part=" >/dev/null 2>/dev/null if [ "$?" = "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 ".eli" >/dev/null 2>/dev/null if [ "$?" = "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 [ "${?}" = "0" -a "${ENC}" = "ON" ] then USINGENCROOT="0" ; export USINGENCROOT fi # Now check that these values are sane case $FS in - UFS|UFS+S|UFS+J|ZFS|SWAP) ;; + UFS|UFS+S|UFS+J|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 [ "$?" != "0" ]; then exit_err "ERROR: The size specified on $line is invalid" fi # Check that the mount-point starts with / echo "$MNT" | grep -e "^/" -e "^none" >/dev/null 2>/dev/null if [ "$?" != "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 [ "${?}" = "0" ] ; then if [ "${CURPART}" = "2" ] ; then FOUNDROOT="0" ; export FOUNDROOT else FOUNDROOT="1" ; export FOUNDROOT fi fi check_for_mount "${MNT}" "/boot" if [ "${?}" = "0" ] ; then if [ "${CURPART}" = "2" ] ; then USINGBOOTPART="0" ; export USINGBOOTPART if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" ] then exit_err "/boot partition must be formatted with UFS" fi else exit_err "/boot partition must be first partition" 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 get_fs_line_xvars "${DISK}p${CURPART}" "${STRING}" XTRAOPTS="${VAR}" # Check if using zfs mirror echo ${XTRAOPTS} | grep "mirror" >/dev/null 2>/dev/null if [ "$?" = "0" ] ; then XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${DISK}p${CURPART}") fi # Figure out the gpart type to use case ${FS} in - ZFS) PARTYPE="freebsd-zfs" ;; - SWAP) PARTYPE="freebsd-swap" ;; - *) PARTYPE="freebsd-ufs" ;; + ZFS) PARTYPE="freebsd-zfs" ;; + SWAP) PARTYPE="freebsd-swap" ;; + *) PARTYPE="freebsd-ufs" ;; esac # Create the partition rc_halt "gpart add ${SOUT} -t ${PARTYPE} ${DISK}" # 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 echo "${FS}:${MNT}:${ENC}:${PLABEL}:GPT:${XTRAOPTS}" >${PARTDIR}/${DISK}p${CURPART} # Clear out any headers sleep 2 dd if=/dev/zero of=${DISK}p${CURPART} count=2048 >/dev/null 2>/dev/null # If we have a enc password, save it as well if [ ! -z "${ENCPASS}" ] ; then echo "${ENCPASS}" >${PARTDIR}-enc/${DISK}p${CURPART}-encpass fi # Increment our parts counter CURPART="`expr ${CURPART} + 1`" fi # End of subsection locating a slice in config echo $line | grep "^commitDiskLabel" >/dev/null 2>/dev/null if [ "$?" = "0" -a "${FOUNDPARTS}" = "0" ] then # If this is the boot disk, stamp the right gptboot if [ ! -z "${BOOTTYPE}" ] ; then case ${BOOTTYPE} in - freebsd-ufs) rc_halt "gpart bootcode -p /boot/gptboot -i 1 ${DISK}" ;; - freebsd-zfs) rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${DISK}" ;; + freebsd-ufs) rc_halt "gpart bootcode -p /boot/gptboot -i 1 ${DISK}" ;; + freebsd-zfs) rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${DISK}" ;; esac 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 disk="`echo $1 | cut -d '-' -f 1`" 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="${disk}s${slicenum}" fi if [ "$type" = "gpt" ] ; then wrkslice="${disk}p${slicenum}" fi if [ -e "${SLICECFGDIR}/${wrkslice}" ] then disktag="`cat ${SLICECFGDIR}/${wrkslice}`" else exit_err "ERROR: Missing SLICETAG data. This shouldn't happen - please let the developers know" fi # Using Traditional MBR for dual-booting if [ "$type" = "mbr" ] ; then setup_mbr_partitions "${disktag}" "${wrkslice}" fi # Using entire disk mode, use GPT for this if [ "$type" = "gpt" ] ; then setup_gpt_partitions "${disktag}" "${disk}" fi }; # 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 "/dev/${disk}s${pnum}" ] ; then exit_err "ERROR: The partition ${i} doesn't exist! gpart failure!" fi if [ "$type" = "gpt" -a ! -e "/dev/${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 LABELLIST="${TMPDIR}/workingLabels" export LABELLIST rm $LABELLIST >/dev/null 2>/dev/null # Set our flag to determine if we've got a valid root partition in this setup FOUNDROOT="-1" export FOUNDROOT # Check if we are using a /boot partition USINGBOOTPART="1" export USINGBOOTPART # Set encryption on root check USINGENCROOT="1" ; export USINGENCROOT # 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 }; Index: head/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh (revision 211730) @@ -1,420 +1,418 @@ #!/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 which perform the final cleanup after an install # Finishes up with ZFS setup before unmounting zfs_cleanup_unmount() { # Loop through our FS and see if we have any ZFS partitions to cleanup for PART in `ls ${PARTDIR}` do PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`" PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`" ZPOOLNAME=$(get_zpool_name "${PART}") if [ "$PARTFS" = "ZFS" ] then # Check if we have multiple zfs mounts specified for ZMNT in `echo ${PARTMNT} | sed 's|,| |g'` do if [ "${ZMNT}" = "/" ] then # Make sure we haven't already added the zfs boot line when # Creating a dedicated "/boot" partition cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep "vfs.root.mountfrom=" >/dev/null 2>/dev/null if [ "$?" != "0" ] ; then echo "vfs.root.mountfrom=\"zfs:${ZPOOLNAME}\"" >> ${FSMNT}/boot/loader.conf fi FOUNDZFSROOT="${ZPOOLNAME}" ; export FOUNDZFSROOT fi done FOUNDZFS="1" fi done if [ ! -z "${FOUNDZFS}" ] then # Check if we need to add our ZFS flags to rc.conf, src.conf and loader.conf cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep 'zfs_load="YES"' >/dev/null 2>/dev/null if [ "$?" != "0" ] then echo 'zfs_load="YES"' >>${FSMNT}/boot/loader.conf fi cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep 'zfs_enable="YES"' >/dev/null 2>/dev/null if [ "$?" != "0" ] then echo 'zfs_enable="YES"' >>${FSMNT}/etc/rc.conf fi sleep 2 # Copy over any ZFS cache data cp /boot/zfs/* ${FSMNT}/boot/zfs/ # Copy the hostid so that our zfs cache works cp /etc/hostid ${FSMNT}/etc/hostid fi # Loop through our FS and see if we have any ZFS partitions to cleanup for PART in `ls ${PARTDIR}` do PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`" PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`" PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`" ZPOOLNAME=$(get_zpool_name "${PART}") if [ "$PARTFS" = "ZFS" ] then # Check if we have multiple zfs mounts specified for ZMNT in `echo ${PARTMNT} | sed 's|,| |g'` do PARTMNTREV="${ZMNT} ${PARTMNTREV}" done for ZMNT in ${PARTMNTREV} do if [ "${ZMNT}" != "/" ] then rc_halt "zfs set mountpoint=${ZMNT} ${ZPOOLNAME}${ZMNT}" rc_halt "zfs unmount ${ZPOOLNAME}${ZMNT}" sleep 2 fi done fi done }; # Function which performs the specific setup for using a /boot partition setup_dedicated_boot_part() { ROOTFS="${1}" ROOTFSTYPE="${2}" BOOTFS="${3}" BOOTMNT="${4}" # Set the root mount in loader.conf echo "vfs.root.mountfrom=\"${ROOTFSTYPE}:${ROOTFS}\"" >> ${FSMNT}/boot/loader.conf rc_halt "mkdir -p ${FSMNT}/${BOOTMNT}/boot" rc_halt "mv ${FSMNT}/boot/* ${FSMNT}${BOOTMNT}/boot/" rc_halt "mv ${FSMNT}${BOOTMNT}/boot ${FSMNT}/boot/" rc_halt "umount /dev/${BOOTFS}" rc_halt "mount /dev/${BOOTFS} ${FSMNT}${BOOTMNT}" rc_halt "rmdir ${FSMNT}/boot" # Strip the '/' from BOOTMNT before making symlink BOOTMNTNS="`echo ${BOOTMNT} | sed 's|/||g'`" rc_halt "chroot ${FSMNT} ln -s ${BOOTMNTNS}/boot /boot" }; # Function which creates the /etc/fstab for the installed system setup_fstab() { FSTAB="${FSMNT}/etc/fstab" rm ${FSTAB} >/dev/null 2>/dev/null # Create the header echo "# Device Mountpoint FStype Options Dump Pass" >> ${FSTAB} # Loop through the partitions, and start creating /etc/fstab for PART in `ls ${PARTDIR}` do PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`" PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`" PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`" PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`" DRIVE="`echo ${PART} | rev | cut -b 4- | rev`" # Check if this device is being mirrored if [ -e "${MIRRORCFGDIR}/${DRIVE}" ] then # This device is apart of a gmirror, lets reset PART to correct value MDRIVE="mirror/`cat ${MIRRORCFGDIR}/${DRIVE} | cut -d ':' -f 3`" TMP="`echo ${PART} | rev | cut -b -3 | rev`" PART="${MDRIVE}${TMP}" PARTLABEL="" fi # Unset EXT EXT="" # Set mount options for file-systems case $PARTFS in UFS+J) MNTOPTS="rw,noatime,async" ;; - SWAP) MNTOPTS="sw" ;; - *) MNTOPTS="rw,noatime" ;; + SWAP) MNTOPTS="sw" ;; + *) MNTOPTS="rw,noatime" ;; esac # Figure out if we are using a glabel, or the raw name for this entry if [ ! -z "${PARTLABEL}" ] then DEVICE="label/${PARTLABEL}" else # Check if using encryption if [ "${PARTENC}" = "ON" ] ; then EXT=".eli" fi if [ "${PARTFS}" = "UFS+J" ] ; then EXT="${EXT}.journal" fi DEVICE="${PART}${EXT}" fi # Set our ROOTFSTYPE for loader.conf if necessary check_for_mount "${PARTMNT}" "/" if [ "$?" = "0" ] ; then if [ "${PARTFS}" = "ZFS" ] ; then ROOTFSTYPE="zfs" XPOOLNAME=$(get_zpool_name "${PART}") ROOTFS="${ZPOOLNAME}" else ROOTFS="${DEVICE}" ROOTFSTYPE="ufs" fi fi # Only create non-zfs partitions if [ "${PARTFS}" != "ZFS" ] then # Make sure geom_journal is loaded if [ "${PARTFS}" = "UFS+J" ] ; then setup_gjournal fi # Save the BOOTFS for call at the end if [ "${PARTMNT}" = "/boot" ] ; then BOOTFS="${PART}${EXT}" BOOTMNT="${BOOT_PART_MOUNT}" PARTMNT="${BOOTMNT}" fi # Echo out the fstab entry now if [ "${PARTFS}" = "SWAP" ] then echo "/dev/${DEVICE} none swap ${MNTOPTS} 0 0" >> ${FSTAB} else echo "/dev/${DEVICE} ${PARTMNT} ufs ${MNTOPTS} 1 1" >> ${FSTAB} fi fi # End of ZFS Check done # Setup some specific PC-BSD fstab options if [ "$INSTALLTYPE" != "FreeBSD" ] then echo "procfs /proc procfs rw 0 0" >> ${FSTAB} echo "linprocfs /compat/linux/proc linprocfs rw 0 0" >> ${FSTAB} echo "tmpfs /tmp tmpfs rw,mode=1777 0 0" >> ${FSTAB} fi # If we have a dedicated /boot, run the post-install setup of it now if [ ! -z "${BOOTMNT}" ] ; then setup_dedicated_boot_part "${ROOTFS}" "${ROOTFSTYPE}" "${BOOTFS}" "${BOOTMNT}" fi }; # Setup our disk mirroring with gmirror setup_gmirror() { NUM="0" cd ${MIRRORCFGDIR} for DISK in `ls *` do MIRRORDISK="`cat ${DISK} | cut -d ':' -f 1`" MIRRORBAL="`cat ${DISK} | cut -d ':' -f 2`" # Create this mirror device gmirror label -vb $MIRRORBAL gm${NUM} /dev/${DISK} sleep 3 # Save the gm device in our config echo "${MIRRORDISK}:${MIRRORBAL}:gm${NUM}" > ${DISK} sleep 3 NUM="`expr ${NUM} + 1`" done cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep 'geom_mirror_load="YES"' >/dev/null 2>/dev/null if [ "$?" != "0" ] then echo 'geom_mirror_load="YES"' >>${FSMNT}/boot/loader.conf fi }; # Function which saves geli keys and sets up loading of them at boot setup_geli_loading() { # Make our keys dir mkdir -p ${FSMNT}/boot/keys >/dev/null 2>/dev/null cd ${GELIKEYDIR} for KEYFILE in `ls *` do # Figure out the partition name based on keyfile name removing .key PART="`echo ${KEYFILE} | cut -d '.' -f 1`" # Add the entries to loader.conf to start this geli provider at boot echo "geli_${PART}_keyfile0_load=\"YES\"" >> ${FSMNT}/boot/loader.conf echo "geli_${PART}_keyfile0_type=\"${PART}:geli_keyfile0\"" >> ${FSMNT}/boot/loader.conf echo "geli_${PART}_keyfile0_name=\"/boot/keys/${KEYFILE}\"" >> ${FSMNT}/boot/loader.conf # If we have a passphrase, set it up now if [ -e "${PARTDIR}-enc/${PART}-encpass" ] ; then cat ${PARTDIR}-enc/${PART}-encpass | geli setkey -S -n 0 -p -k ${KEYFILE} -K ${KEYFILE} ${PART} geli configure -b ${PART} fi # Copy the key to the disk cp ${KEYFILE} ${FSMNT}/boot/keys/${KEYFILE} done # Make sure we have geom_eli set to load at boot cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep 'geom_eli_load="YES"' >/dev/null 2>/dev/null if [ "$?" != "0" ] then echo 'geom_eli_load="YES"' >>${FSMNT}/boot/loader.conf fi }; # Function to generate a random hostname if none was specified gen_hostname() { RAND="`jot -r 1 1 9000`" if [ "$INSTALLTYPE" = "FreeBSD" ] then VAL="freebsd-${RAND}" else VAL="pcbsd-${RAND}" fi export VAL }; # Function which sets up the hostname for the system setup_hostname() { get_value_from_cfg hostname HOSTNAME="${VAL}" # If we don't have a hostname, make one up if [ -z "${HOSTNAME}" ] then gen_hostname HOSTNAME="${VAL}" fi # Clean up any saved hostname cat ${FSMNT}/etc/rc.conf | grep -v "hostname=" >${FSMNT}/etc/rc.conf.new mv ${FSMNT}/etc/rc.conf.new ${FSMNT}/etc/rc.conf # Set the hostname now echo_log "Setting hostname: ${HOSTNAME}" echo "hostname=\"${HOSTNAME}\"" >> ${FSMNT}/etc/rc.conf sed -i -e "s|my.domain|${HOSTNAME} ${HOSTNAME}|g" ${FSMNT}/etc/hosts }; # Check and make sure geom_journal is enabled on the system setup_gjournal() { # Make sure we have geom_journal set to load at boot cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep 'geom_journal_load="YES"' >/dev/null 2>/dev/null if [ "$?" != "0" ] then echo 'geom_journal_load="YES"' >>${FSMNT}/boot/loader.conf fi }; # Function which sets the root password from the install config set_root_pw() { get_value_from_cfg_with_spaces rootPass PW="${VAL}" # If we don't have a root pass, return if [ -z "${PW}" ] then return 0 fi echo_log "Setting root password" echo "${PW}" > ${FSMNT}/.rootpw run_chroot_cmd "cat /.rootpw | pw usermod root -h 0" rc_halt "rm ${FSMNT}/.rootpw" }; run_final_cleanup() { + # Check if we need to run any gmirror setup + ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null + if [ "$?" = "0" ] + then + # Lets setup gmirror now + setup_gmirror + fi - # Check if we need to run any gmirror setup - ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - # Lets setup gmirror now - setup_gmirror - fi + # Check if we need to save any geli keys + ls ${GELIKEYDIR}/* >/dev/null 2>/dev/null + if [ "$?" = "0" ] + then + # Lets setup geli loading + setup_geli_loading + fi - # Check if we need to save any geli keys - ls ${GELIKEYDIR}/* >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - # Lets setup geli loading - setup_geli_loading - fi + # Set a hostname on the install system + setup_hostname - # Set a hostname on the install system - setup_hostname + # Set the root_pw if it is specified + set_root_pw - # Set the root_pw if it is specified - set_root_pw - - # Generate the fstab for the installed system - setup_fstab - + # Generate the fstab for the installed system + setup_fstab }; Index: head/usr.sbin/pc-sysinstall/backend/functions-disk.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-disk.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-disk.sh (revision 211730) @@ -1,757 +1,784 @@ #!/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 - if [ "$_dsk" = "${1}" ] ; then return 0 ; fi - done +is_disk() +{ + for _dsk in `sysctl -n kern.disks` + do + if [ "$_dsk" = "${1}" ] ; then return 0 ; fi + done - return 1 + 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 "The data for partition" >/dev/null 2>/dev/null if [ "$?" = "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 "^sysid" >/dev/null 2>/dev/null if [ "$?" = "0" ] ; then SYSID="`echo ${i} | tr -s '\t' ' ' | cut -d ' ' -f 2`" break fi fi done < ${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} VAL="${SYSID}" export VAL }; # 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 "The data for partition" >/dev/null 2>/dev/null if [ "$?" = "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 "^sysid" >/dev/null 2>/dev/null if [ "$?" = "0" ] ; then LABEL="`echo ${i} | tr -s '\t' ' ' | cut -d ',' -f 2-10`" break fi fi done < ${TMPDIR}/disk-${DISK} rm ${TMPDIR}/disk-${DISK} VAL="${LABEL}" export VAL }; # 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} VAL="${LABEL}" export VAL }; # 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} VAL="${SB}" export VAL }; # 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} VAL="${BS}" export VAL }; # Function which returns the partitions on a target disk get_disk_partitions() { gpart show ${1} >/dev/null 2>/dev/null if [ "$?" != "0" ] ; then VAL="" ; export VAL return fi gpart show ${1} | grep "MBR" >/dev/null 2>/dev/null if [ "$?" = "0" ] ; then type="MBR" else type="GPT" fi 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}";; + 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 VAL="${RSLICES}" ; export VAL }; # Function which returns a target disks cylinders get_disk_cyl() { cyl=`diskinfo -v ${1} | grep "# Cylinders" | tr -s ' ' | cut -f 2` VAL="${cyl}" ; export VAL }; # Function which returns a target disks sectors get_disk_sectors() { sec=`diskinfo -v ${1} | grep "# Sectors" | tr -s ' ' | cut -f 2` VAL="${sec}" ; export VAL }; # Function which returns a target disks heads get_disk_heads() { head=`diskinfo -v ${1} | grep "# Heads" | tr -s ' ' | cut -f 2` VAL="${head}" ; export VAL }; +# 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` + + # Not sure why this is, memory disks need it though. + mediasize=`expr ${mediasize} - 10` + VAL="${mediasize}" ; export VAL +}; + # Function which exports all zpools, making them safe to overwrite potentially -export_all_zpools() { +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" DISK="$1" # Check for any swaps to stop for i in `gpart show ${DISK} 2>/dev/null | grep 'freebsd-swap' | tr -s ' ' | cut -d ' ' -f 4` do swapoff /dev/${DISK}s${i}b >/dev/null 2>/dev/null swapoff /dev/${DISK}p${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 [ "${i}" != "${DISK}" -a "${i}" != "-" ] ; then rc_nohalt "gpart delete -i ${i} ${DISK}" fi done rc_nohalt "dd if=/dev/zero of=/dev/${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() { DISK="${1}" GPROV="`gmirror list | grep ". Name: mirror/" | cut -d '/' -f 2`" for gprov in $GPROV do gmirror list | grep "Name: ${DISK}" >/dev/null 2>/dev/null if [ "$?" = "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() { _geld="${1}" cd /dev for i in `ls ${_geld}*` do echo $i | grep '.eli' >/dev/null 2>/dev/null if [ "$?" = "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 disknum="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 "^disk${disknum}=" >/dev/null 2>/dev/null if [ "$?" = "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" # Before we go further, lets confirm this disk really exists if [ ! -e "/dev/${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 "^mirror=" >/dev/null 2>/dev/null if [ "$?" = "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" # Before we go further, lets confirm this disk really exists if [ ! -e "/dev/${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 "^mirrorbal=" >/dev/null 2>/dev/null if [ "$?" = "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 "^partition=" >/dev/null 2>/dev/null if [ "$?" = "0" ] then # Found a partition= entry, lets read / set it get_value_from_string "${line}" strip_white_space "$VAL" PTYPE="$VAL" # We are using free space, figure out the slice number if [ "${PTYPE}" = "free" -o "${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="`expr $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 a partscheme specified echo $line | grep "^partscheme=" >/dev/null 2>/dev/null if [ "$?" = "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 "^bootManager=" >/dev/null 2>/dev/null if [ "$?" = "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 "^commitDiskPart" >/dev/null 2>/dev/null if [ "$?" = "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|ALL) 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}" ;; - free|FREE) tmpSLICE="${DISK}s${LASTSLICE}" - run_gpart_free "${DISK}" "${LASTSLICE}" "${BMANAGER}" ;; - *) exit_err "ERROR: Unknown PTYPE: $PTYPE" ;; + all|ALL) + 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}" + ;; + + free|FREE) + tmpSLICE="${DISK}s${LASTSLICE}" + run_gpart_free "${DISK}" "${LASTSLICE}" "${BMANAGER}" + ;; + + *) exit_err "ERROR: Unknown PTYPE: $PTYPE" ;; esac # Now save which disk this is, so we can parse it later during slice partition setup echo "disk${disknum}" >${SLICECFGDIR}/$tmpSLICE # Save any mirror config if [ ! -z "$MIRRORDISK" ] then # Default to round-robin if the user didn't specify if [ -z "$MIRRORBAL" ] then MIRRORBAL="round-robin" fi echo "$MIRRORDISK:$MIRRORBAL" >${MIRRORCFGDIR}/$DISK fi # Increment our disk counter to look for next disk and unset unset BMANAGER PTYPE DISK MIRRORDISK MIRRORBAL PSCHEME disknum="`expr $disknum + 1`" else exit_err "ERROR: commitDiskPart was called without procceding disk= and partition= entries!!!" fi fi done <${CFGF} }; # Stop all gjournals on disk / slice -stop_gjournal() { +stop_gjournal() +{ _gdsk="$1" # Check if we need to shutdown any journals on this drive ls /dev/${_gdsk}*.journal >/dev/null 2>/dev/null if [ "$?" = "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 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}" #Erase any existing bootloader echo_log "Cleaning up ${_intDISK}" rc_halt "dd if=/dev/zero of=/dev/${_intDISK} count=2048" 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="63" # 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}" #Erase any existing bootloader echo_log "Cleaning up ${_intDISK}" rc_halt "dd if=/dev/zero of=/dev/${_intDISK} count=2048" 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}`" totalblocks="`expr ${totalblocks} \* ${sec}`" - + if [ -z "${totalblocks}" ] + then + get_disk_mediasize "${_intDISK}" + totalblocks="${VAL}" + 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=/dev/${_intDISK}s1 count=1024" if [ "$_intBOOT" = "bsd" ] ; then echo_log "Stamping boot sector on ${_intDISK}" rc_halt "gpart bootcode -b /boot/boot0 ${_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="${DISK}-1-mbr" else init_gpt_full_disk "$DISK" slice="${DISK}-1-gpt" 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 s1-4 slice run_gpart_slice() { DISK=$1 if [ ! -z "$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=/dev/${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="${1}-${3}-mbr" # 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 [ ! -z "$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 [ "$?" != "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="`expr ${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="`expr ${sblk} + ${blksize}`" 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="`expr ${cyl} \* ${head}`" totalblocks="`expr ${totalblocks} \* ${sec}`" # Now set the ending block to the total disk block size sizeblock="`expr ${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=/dev/${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="${DISK}-${SLICENUM}-mbr" # 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: head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh (revision 211730) @@ -1,387 +1,399 @@ #!/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 which perform the extraction / installation of system to disk . ${BACKEND}/functions-mountoptical.sh # Performs the extraction of data to disk from a uzip or tar archive start_extract_uzip_tar() { if [ -z "$INSFILE" ] then exit_err "ERROR: Called extraction with no install file set!" fi # Check if we have a .count file, and echo it out for a front-end to use in progress bars if [ -e "${INSFILE}.count" ] then echo "INSTALLCOUNT: `cat ${INSFILE}.count`" fi # Check if we are doing an upgrade, and if so use our exclude list if [ "${INSTALLMODE}" = "upgrade" ] then TAROPTS="-X ${PROGDIR}/conf/exclude-from-upgrade" else TAROPTS="" fi echo_log "pc-sysinstall: Starting Extraction" case ${PACKAGETYPE} in - uzip) # Start by mounting the uzip image - MDDEVICE=`mdconfig -a -t vnode -o readonly -f ${INSFILE}` - mkdir -p ${FSMNT}.uzip - mount -r /dev/${MDDEVICE}.uzip ${FSMNT}.uzip - if [ "$?" != "0" ] - then - exit_err "ERROR: Failed mounting the ${INSFILE}" - fi - cd ${FSMNT}.uzip + uzip) + # Start by mounting the uzip image + MDDEVICE=`mdconfig -a -t vnode -o readonly -f ${INSFILE}` + mkdir -p ${FSMNT}.uzip + mount -r /dev/${MDDEVICE}.uzip ${FSMNT}.uzip + if [ "$?" != "0" ] + then + exit_err "ERROR: Failed mounting the ${INSFILE}" + fi + cd ${FSMNT}.uzip - # Copy over all the files now! - tar cvf - . 2>/dev/null | tar -xpv -C ${FSMNT} ${TAROPTS} -f - 2>&1 | tee -a ${FSMNT}/.tar-extract.log - if [ "$?" != "0" ] - then - cd / - echo "TAR failure occured:" >>${LOGOUT} - cat ${FSMNT}/.tar-extract.log | grep "tar:" >>${LOGOUT} - umount ${FSMNT}.uzip - mdconfig -d -u ${MDDEVICE} - exit_err "ERROR: Failed extracting the tar image" - fi + # Copy over all the files now! + tar cvf - . 2>/dev/null | tar -xpv -C ${FSMNT} ${TAROPTS} -f - 2>&1 | tee -a ${FSMNT}/.tar-extract.log + if [ "$?" != "0" ] + then + cd / + echo "TAR failure occured:" >>${LOGOUT} + cat ${FSMNT}/.tar-extract.log | grep "tar:" >>${LOGOUT} + umount ${FSMNT}.uzip + mdconfig -d -u ${MDDEVICE} + exit_err "ERROR: Failed extracting the tar image" + fi - # All finished, now lets umount and cleanup - cd / - umount ${FSMNT}.uzip - mdconfig -d -u ${MDDEVICE} - ;; - tar) tar -xpv -C ${FSMNT} -f ${INSFILE} ${TAROPTS} >&1 2>&1 - if [ "$?" != "0" ] - then - exit_err "ERROR: Failed extracting the tar image" - fi - ;; + # All finished, now lets umount and cleanup + cd / + umount ${FSMNT}.uzip + mdconfig -d -u ${MDDEVICE} + ;; + tar) + tar -xpv -C ${FSMNT} -f ${INSFILE} ${TAROPTS} >&1 2>&1 + if [ "$?" != "0" ] + then + exit_err "ERROR: Failed extracting the tar image" + fi + ;; esac # Check if this was a FTP download and clean it up now if [ "${INSTALLMEDIUM}" = "ftp" ] then echo_log "Cleaning up downloaded archive" rm ${INSFILE} rm ${INSFILE}.count >/dev/null 2>/dev/null rm ${INSFILE}.md5 >/dev/null 2>/dev/null fi echo_log "pc-sysinstall: Extraction Finished" }; # Performs the extraction of data to disk from a directory with split files start_extract_split() { if [ -z "${INSDIR}" ] then exit_err "ERROR: Called extraction with no install directory set!" fi echo_log "pc-sysinstall: Starting Extraction" # Used by install.sh DESTDIR="${FSMNT}" export DESTDIR HERE=`pwd` DIRS=`ls -d ${INSDIR}/*|grep -Ev '(uzip|kernels|src)'` for dir in ${DIRS} do - cd "${dir}" - if [ -f "install.sh" ] - then - echo_log "Extracting" `basename ${dir}` + cd "${dir}" + if [ -f "install.sh" ] + then + echo_log "Extracting" `basename ${dir}` echo "y" | sh install.sh >/dev/null if [ "$?" != "0" ] then exit_err "ERROR: Failed extracting ${dir}" fi else exit_err "ERROR: ${dir}/install.sh does not exist" fi done cd "${HERE}" KERNELS=`ls -d ${INSDIR}/*|grep kernels` cd "${KERNELS}" if [ -f "install.sh" ] then - echo_log "Extracting" `basename ${KERNELS}` + echo_log "Extracting" `basename ${KERNELS}` echo "y" | sh install.sh generic >/dev/null if [ "$?" != "0" ] then exit_err "ERROR: Failed extracting ${KERNELS}" fi - echo 'kernel="GENERIC"' > "${FSMNT}/boot/loader.conf" + mv "${FSMNT}/boot/GENERIC" "${FSMNT}/boot/kernel" else exit_err "ERROR: ${KERNELS}/install.sh does not exist" fi cd "${HERE}" SOURCE=`ls -d ${INSDIR}/*|grep src` cd "${SOURCE}" if [ -f "install.sh" ] then - echo_log "Extracting" `basename ${SOURCE}` + echo_log "Extracting" `basename ${SOURCE}` echo "y" | sh install.sh all >/dev/null if [ "$?" != "0" ] then exit_err "ERROR: Failed extracting ${SOURCE}" fi else exit_err "ERROR: ${SOURCE}/install.sh does not exist" fi cd "${HERE}" echo_log "pc-sysinstall: Extraction Finished" }; # Function which will attempt to fetch the install file before we start # the install fetch_install_file() { get_value_from_cfg ftpPath if [ -z "$VAL" ] then exit_err "ERROR: Install medium was set to ftp, but no ftpPath was provided!" fi FTPPATH="${VAL}" # Check if we have a /usr partition to save the download if [ -d "${FSMNT}/usr" ] then OUTFILE="${FSMNT}/usr/.fetch-${INSFILE}" else OUTFILE="${FSMNT}/.fetch-${INSFILE}" fi # Do the fetch of the archive now fetch_file "${FTPPATH}/${INSFILE}" "${OUTFILE}" "1" # Check to see if there is a .count file for this install fetch_file "${FTPPATH}/${INSFILE}.count" "${OUTFILE}.count" "0" # Check to see if there is a .md5 file for this install fetch_file "${FTPPATH}/${INSFILE}.md5" "${OUTFILE}.md5" "0" # Done fetching, now reset the INSFILE to our downloaded archived INSFILE="${OUTFILE}" ; export INSFILE }; # Function which will download freebsd install files fetch_split_files() { - get_value_from_cfg ftpHost + get_ftpHost if [ -z "$VAL" ] then exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!" fi FTPHOST="${VAL}" - get_value_from_cfg ftpDir + get_ftpDir if [ -z "$VAL" ] then exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!" fi FTPDIR="${VAL}" # Check if we have a /usr partition to save the download if [ -d "${FSMNT}/usr" ] then OUTFILE="${FSMNT}/usr/.fetch-${INSFILE}" else OUTFILE="${FSMNT}/.fetch-${INSFILE}" fi + DIRS="base catpages dict doc games info manpages proflibs kernels src" + if [ "${FBSD_ARCH}" = "amd64" ] + then + DIRS="${DIRS} lib32" + fi + + for d in ${DIRS} + do + mkdir -p "${OUTFILE}/${d}" + done + + NETRC="${OUTFILE}/.netrc" cat<"${NETRC}" machine ${FTPHOST} login anonymous password anonymous macdef INSTALL bin prompt EOF - DIRS="base catpages dict doc games info manpages proflibs kernels src" - if [ "${FBSD_ARCH}" = "amd64" ] - then - DIRS="${DIRS} lib32" - fi - for d in ${DIRS} do - cat<>"${NETRC}" + cat<>"${NETRC}" cd ${FTPDIR}/${d} lcd ${OUTFILE}/${d} mreget * EOF done - cat<>"${NETRC}" + cat<>"${NETRC}" bye EOF # Fetch the files via ftp echo "$ INSTALL" | ftp -N "${NETRC}" "${FTPHOST}" # Done fetching, now reset the INSFILE to our downloaded archived INSFILE="${OUTFILE}" ; export INSFILE } # Function which does the rsync download from the server specifed in cfg start_rsync_copy() { # Load our rsync config values get_value_from_cfg rsyncPath if [ -z "${VAL}" ]; then exit_err "ERROR: rsyncPath is unset! Please check your config and try again." fi RSYNCPATH="${VAL}" ; export RSYNCPATH get_value_from_cfg rsyncHost if [ -z "${VAL}" ]; then exit_err "ERROR: rsyncHost is unset! Please check your config and try again." fi RSYNCHOST="${VAL}" ; export RSYNCHOST get_value_from_cfg rsyncUser if [ -z "${VAL}" ]; then exit_err "ERROR: rsyncUser is unset! Please check your config and try again." fi RSYNCUSER="${VAL}" ; export RSYNCUSER get_value_from_cfg rsyncPort if [ -z "${VAL}" ]; then exit_err "ERROR: rsyncPort is unset! Please check your config and try again." fi RSYNCPORT="${VAL}" ; export RSYNCPORT COUNT="1" while z=1 do if [ ${COUNT} -gt ${RSYNCTRIES} ] then exit_err "ERROR: Failed rsync command!" break fi rsync -avvzHsR \ --rsync-path="rsync --fake-super" \ -e "ssh -p ${RSYNCPORT}" \ ${RSYNCUSER}@${RSYNCHOST}:${RSYNCPATH}/./ ${FSMNT} if [ "$?" != "0" ] then echo "Rsync failed! Tries: ${COUNT}" else break fi COUNT="`expr ${COUNT} + 1`" done }; # Entrance function, which starts the installation process init_extraction() { # Figure out what file we are using to install from via the config get_value_from_cfg installFile if [ ! -z "${VAL}" ] then INSFILE="${VAL}" ; export INSFILE else # If no installFile specified, try our defaults if [ "$INSTALLTYPE" = "FreeBSD" ] then case $PACKAGETYPE in - uzip) INSFILE="${FBSD_UZIP_FILE}" ;; - tar) INSFILE="${FBSD_TAR_FILE}" ;; - split) - INSDIR="${FBSD_BRANCH_DIR}" + uzip) INSFILE="${FBSD_UZIP_FILE}" ;; + tar) INSFILE="${FBSD_TAR_FILE}" ;; + split) + INSDIR="${FBSD_BRANCH_DIR}" - # This is to trick opt_mount into not failing - INSFILE="${INSDIR}" - ;; + # This is to trick opt_mount into not failing + INSFILE="${INSDIR}" + ;; esac else case $PACKAGETYPE in - uzip) INSFILE="${UZIP_FILE}" ;; - tar) INSFILE="${TAR_FILE}" ;; + uzip) INSFILE="${UZIP_FILE}" ;; + tar) INSFILE="${TAR_FILE}" ;; esac fi export INSFILE fi # Lets start by figuring out what medium we are using case ${INSTALLMEDIUM} in - dvd|usb) # Lets start by mounting the disk - opt_mount - if [ ! -z "${INSDIR}" ] - then - INSDIR="${CDMNT}/${INSDIR}" ; export INSDIR - start_extract_split + dvd|usb) + # Lets start by mounting the disk + opt_mount + if [ ! -z "${INSDIR}" ] + then + INSDIR="${CDMNT}/${INSDIR}" ; export INSDIR + start_extract_split - else - INSFILE="${CDMNT}/${INSFILE}" ; export INSFILE - start_extract_uzip_tar - fi - ;; - ftp) - if [ "$PACKAGETYPE" = "split" ] - then - fetch_split_files + else + INSFILE="${CDMNT}/${INSFILE}" ; export INSFILE + start_extract_uzip_tar + fi + ;; - INSDIR="${INSFILE}" ; export INSDIR - start_extract_split - else - fetch_install_file - start_extract_uzip_tar - fi - ;; - rsync) start_rsync_copy - ;; - *) exit_err "ERROR: Unknown install medium" ;; + ftp|sftp) + if [ "$PACKAGETYPE" = "split" ] + then + fetch_split_files + + INSDIR="${INSFILE}" ; export INSDIR + start_extract_split + else + fetch_install_file + start_extract_uzip_tar + fi + ;; + + rsync) start_rsync_copy ;; + img) + ;; + *) exit_err "ERROR: Unknown install medium" ;; esac }; Index: head/usr.sbin/pc-sysinstall/backend/functions-ftp.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-ftp.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-ftp.sh (revision 211730) @@ -1,394 +1,417 @@ #!/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 which runs commands on the system . ${BACKEND}/functions.sh . ${BACKEND}/functions-parse.sh DEFAULT_FTP_SERVER="ftp.freebsd.org" MAIN_FTP_SERVERS="\ Main Site: ftp.freebsd.org" IPV6_FTP_SERVERS="\ IPv6 Main Site: ftp.freebsd.org|\ IPv6 Ireland: ftp3.ie.freebsd.org|\ IPv6 Israel: ftp.il.freebsd.org|\ IPv6 Japan: ftp2.jp.freebsd.org|\ IPv6 USA: ftp4.us.freebsd.org|\ IPv6 Turkey: ftp2.tr.freebsd.org" PRIMARY_FTP_SERVERS="\ Primary: ftp1.freebsd.org|\ Primary #2: ftp2.freebsd.org|\ Primary #3: ftp3.freebsd.org|\ Primary #4: ftp4.freebsd.org|\ Primary #5: ftp5.freebsd.org|\ Primary #6: ftp6.freebsd.org|\ Primary #7: ftp7.freebsd.org|\ Primary #8: ftp8.freebsd.org|\ Primary #9: ftp9.freebsd.org|\ Primary #10: ftp10.freebsd.org|\ Primary #11: ftp11.freebsd.org|\ Primary #12: ftp12.freebsd.org|\ Primary #13: ftp13.freebsd.org|\ Primary #14: ftp14.freebsd.org" ARGENTINA_FTP_SERVERS="\ Argentina: ftp.ar.freebsd.org" AUSTRALIA_FTP_SERVERS="\ Australia: ftp.au.freebsd.org|\ Australia #2: ftp2.au.freebsd.org|\ Australia #3: ftp3.au.freebsd.org" AUSTRIA_FTP_SERVERS="\ Austria: ftp.at.freebsd.org|\ Austria #2: ftp2.at.freebsd.org" BRAZIL_FTP_SERVERS="\ Brazil: ftp.br.freebsd.org|\ Brazil #2: ftp2.br.freebsd.org|\ Brazil #3: ftp3.br.freebsd.org|\ Brazil #4: ftp4.br.freebsd.org|\ Brazil #5: ftp5.br.freebsd.org|\ Brazil #6: ftp6.br.freebsd.org|\ Brazil #7: ftp7.br.freebsd.org" CANADA_FTP_SERVERS="\ Canada: ftp.ca.freebsd.org" CHINA_FTP_SERVERS="\ China: ftp.cn.freebsd.org|\ China #2: ftp2.cn.freebsd.org" CROATIA_FTP_SERVERS="\ Croatia: ftp.hr.freebsd.org" CZECH_REPUBLIC_FTP_SERVERS="\ Czech Republic: ftp.cz.freebsd.org" DENMARK_FTP_SERVERS="\ Denmark: ftp.dk.freebsd.org|\ Denmark #2: ftp2.dk.freebsd.org" ESTONIA_FTP_SERVERS="\ Estonia: ftp.ee.freebsd.org" FINLAND_FTP_SERVERS="\ Finland: ftp.fi.freebsd.org" FRANCE_FTP_SERVERS="\ France: ftp.fr.freebsd.org|\ France #2: ftp2.fr.freebsd.org|\ France #3: ftp3.fr.freebsd.org|\ France #5: ftp5.fr.freebsd.org|\ France #6: ftp6.fr.freebsd.org|\ France #8: ftp8.fr.freebsd.org" GERMANY_FTP_SERVERS="\ Germany: ftp.de.freebsd.org|\ Germany #2: ftp2.de.freebsd.org|\ Germany #3: ftp3.de.freebsd.org|\ Germany #4: ftp4.de.freebsd.org|\ Germany #5: ftp5.de.freebsd.org|\ Germany #6: ftp6.de.freebsd.org|\ Germany #7: ftp7.de.freebsd.org|\ Germany #8: ftp8.de.freebsd.org" GREECE_FTP_SERVERS="\ Greece: ftp.gr.freebsd.org|\ Greece #2: ftp2.gr.freebsd.org" HUNGARY_FTP_SERVERS="\ Hungary: ftp.hu.freebsd.org" ICELAND_FTP_SERVERS="\ Iceland: ftp.is.freebsd.org" IRELAND_FTP_SERVERS="\ Ireland: ftp.ie.freebsd.org|\ Ireland #2: ftp2.ie.freebsd.org|\ Ireland #3: ftp3.ie.freebsd.org" ISRAEL_FTP_SERVERS="\ Israel: ftp.il.freebsd.org" ITALY_FTP_SERVERS="\ Italy: ftp.it.freebsd.org" JAPAN_FTP_SERVERS="\ Japan: ftp.jp.freebsd.org|\ Japan #2: ftp2.jp.freebsd.org|\ Japan #3: ftp3.jp.freebsd.org|\ Japan #4: ftp4.jp.freebsd.org|\ Japan #5: ftp5.jp.freebsd.org|\ Japan #6: ftp6.jp.freebsd.org|\ Japan #7: ftp7.jp.freebsd.org|\ Japan #8: ftp8.jp.freebsd.org|\ Japan #9: ftp9.jp.freebsd.org" KOREA_FTP_SERVERS="\ Korea: ftp.kr.freebsd.org|\ Korea #2: ftp2.kr.freebsd.org" LITHUANIA_FTP_SERVERS="\ Lithuania: ftp.lt.freebsd.org" NETHERLANDS_FTP_SERVERS="\ Netherlands: ftp.nl.freebsd.org|\ Netherlands #2: ftp2.nl.freebsd.org" NORWAY_FTP_SERVERS="\ Norway: ftp.no.freebsd.org|\ Norway #3: ftp3.no.freebsd.org" POLAND_FTP_SERVERS="\ Poland: ftp.pl.freebsd.org|\ Poland #2: ftp2.pl.freebsd.org|\ Poland #5: ftp5.pl.freebsd.org" PORTUGAL_FTP_SERVERS="\ Portugal: ftp.pt.freebsd.org|\ Portugal #2: ftp2.pt.freebsd.org|\ Portugal #4: ftp4.pt.freebsd.org" ROMANIA_FTP_SERVERS="\ Romania: ftp.ro.freebsd.org" RUSSIA_FTP_SERVERS="\ Russia: ftp.ru.freebsd.org|\ Russia #2: ftp2.ru.freebsd.org|\ Russia #3: ftp3.ru.freebsd.org|\ Russia #4: ftp4.ru.freebsd.org" SINGAPORE_FTP_SERVERS="\ Singapore: ftp.sg.freebsd.org" SLOVAK_REPUBLIC_FTP_SERVERS="\ Slovak Republic: ftp.sk.freebsd.org" SLOVENIA_FTP_SERVERS="\ Slovenia: ftp.si.freebsd.org|\ Slovenia #2: ftp2.si.freebsd.org" SOUTH_AFRICA_FTP_SERVERS="\ South Africa: ftp.za.freebsd.org|\ South Africa #2: ftp2.za.freebsd.org|\ South Africa #3: ftp3.za.freebsd.org|\ South Africa #4: ftp4.za.freebsd.org" SPAIN_FTP_SERVERS="\ Spain: ftp.es.freebsd.org|\ Spain #2: ftp2.es.freebsd.org|\ Spain #3: ftp3.es.freebsd.org" SWEDEN_FTP_SERVERS="\ Sweden: ftp.se.freebsd.org|\ Sweden #2: ftp2.se.freebsd.org|\ Sweden #3: ftp3.se.freebsd.org|\ Sweden #5: ftp5.se.freebsd.org" SWITZERLAND_FTP_SERVERS="\ Switzerland: ftp.ch.freebsd.org|\ Switzerland #2: ftp2.ch.freebsd.org" TAIWAN_FTP_SERVERS="\ Taiwan: ftp.tw.freebsd.org|\ Taiwan #2: ftp2.tw.freebsd.org|\ Taiwan #3: ftp3.tw.freebsd.org|\ Taiwan #4: ftp4.tw.freebsd.org|\ Taiwan #6: ftp6.tw.freebsd.org|\ Taiwan #11: ftp11.tw.freebsd.org" TURKEY_FTP_SERVERS="\ Turkey: ftp.tr.freebsd.org|\ Turkey #2: ftp2.tr.freebsd.org" UK_FTP_SERVERS="\ UK: ftp.uk.freebsd.org|\ UK #2: ftp2.uk.freebsd.org|\ UK #3: ftp3.uk.freebsd.org|\ UK #4: ftp4.uk.freebsd.org|\ UK #5: ftp5.uk.freebsd.org|\ UK #6: ftp6.uk.freebsd.org" UKRAINE_FTP_SERVERS="\ Ukraine: ftp.ua.freebsd.org|\ Ukraine #2: ftp2.ua.freebsd.org|\ Ukraine #5: ftp5.ua.freebsd.org|\ Ukraine #6: ftp6.ua.freebsd.org|\ Ukraine #7: ftp7.ua.freebsd.org|\ Ukraine #8: ftp8.ua.freebsd.org" USA_FTP_SERVERS="\ USA #1: ftp1.us.freebsd.org|\ USA #2: ftp2.us.freebsd.org|\ USA #3: ftp3.us.freebsd.org|\ USA #4: ftp4.us.freebsd.org|\ USA #5: ftp5.us.freebsd.org|\ USA #6: ftp6.us.freebsd.org|\ USA #7: ftp7.us.freebsd.org|\ USA #8: ftp8.us.freebsd.org|\ USA #9: ftp9.us.freebsd.org|\ USA #10: ftp10.us.freebsd.org|\ USA #11: ftp11.us.freebsd.org|\ USA #12: ftp12.us.freebsd.org|\ USA #13: ftp13.us.freebsd.org|\ USA #14: ftp14.us.freebsd.org|\ USA #15: ftp15.us.freebsd.org" show_mirrors() { MIRRORS="${1}" if [ -n "${MIRRORS}" ] then SAVE_IFS="${IFS}" IFS="|" for m in ${MIRRORS} do echo "$m" done IFS="${SAVE_IFS}" fi }; set_ftp_mirror() { - MIRROR="${1}" - echo "${MIRROR}" > "${CONFDIR}/mirrors.conf" + MIRROR="${1}" + echo "${MIRROR}" > "${CONFDIR}/mirrors.conf" }; get_ftp_mirror() { - MIRROR="${DEFAULT_FTP_SERVER}" - if [ -f "${CONFDIR}/mirrors.conf" ] - then - MIRROR=`cat "${CONFDIR}/mirrors.conf"` - fi + MIRROR="${DEFAULT_FTP_SERVER}" + if [ -f "${CONFDIR}/mirrors.conf" ] + then + MIRROR=`cat "${CONFDIR}/mirrors.conf"` + fi - VAL="${MIRROR}" - export VAL + VAL="${MIRROR}" + export VAL +}; + + +get_ftpHost() +{ + get_value_from_cfg ftpPath + ftpPath="$VAL" + + ftpHost=`echo "${ftpPath}" | sed -E 's|^(ftp://)([^/]*)(.*)|\2|'` + VAL="${ftpHost}" + + export VAL +}; + +get_ftpDir() +{ + get_value_from_cfg ftpPath + ftpPath="$VAL" + + ftpDir=`echo "${ftpPath}" | sed -E 's|^(ftp://)([^/]*)(.*)|\3|'` + VAL="${ftpDir}" + + export VAL }; get_ftp_mirrors() { COUNTRY="${1}" if [ -n "$COUNTRY" ] then COUNTRY=`echo $COUNTRY|tr A-Z a-z` case "${COUNTRY}" in argentina*) VAL="${ARGENTINA_FTP_SERVERS}" ;; australia*) VAL="${AUSTRALIA_FTP_SERVERS}" ;; austria*) VAL="${AUSTRIA_FTP_SERVERS}" ;; brazil*) VAL="${BRAZIL_FTP_SERVERS}" ;; canada*) VAL="${CANADA_FTP_SERVERS}" ;; china*) VAL="${CHINA_FTP_SERVERS}" ;; croatia*) VAL="${CROATIA_FTP_SERVERS}" ;; czech*) VAL="${CZECH_REPUBLIC_FTP_SERVERS}" ;; denmark*) VAL="${DENMARK_FTP_SERVERS}" ;; estonia*) VAL="${ESTONIA_FTP_SERVERS}" ;; finland*) VAL="${FINLAND_FTP_SERVERS}" ;; france*) VAL="${FRANCE_FTP_SERVERS}" ;; germany*) VAL="${GERMANY_FTP_SERVERS}" ;; greece*) VAL="${GREECE_FTP_SERVERS}" ;; hungary*) VAL="${HUNGARY_FTP_SERVERS}" ;; iceland*) VAL="${ICELAND_FTP_SERVERS}" ;; ireland*) VAL="${IRELAND_FTP_SERVERS}" ;; israel*) VAL="${ISRAEL_FTP_SERVERS}" ;; italy*) VAL="${ITALY_FTP_SERVERS}" ;; japan*) VAL="${JAPAN_FTP_SERVERS}" ;; korea*) VAL="${KOREA_FTP_SERVERS}" ;; lithuania*) VAL="${LITHUANIA_FTP_SERVERS}" ;; netherlands*) VAL="${NETHERLANDS_FTP_SERVERS}" ;; norway*) VAL="${NORWAY_FTP_SERVERS}" ;; poland*) VAL="${POLAND_FTP_SERVERS}" ;; portugal*) VAL="${PORTUGAL_FTP_SERVERS}" ;; romania*) VAL="${ROMAINIA_FTP_SERVERS}" ;; russia*) VAL="${RUSSIA_FTP_SERVERS}" ;; singapore*) VAL="${SINGAPORE_FTP_SERVERS}" ;; slovak*) VAL="${SLOVAK_REPUBLIC_FTP_SERVERS}" ;; slovenia*) VAL="${SLOVENIA_FTP_SERVERS}" ;; *africa*) VAL="${SOUTH_AFRICA_FTP_SERVERS}" ;; spain*) VAL="${SPAIN_FTP_SERVERS}" ;; sweden*) VAL="${SWEDEN_FTP_SERVERS}" ;; switzerland*) VAL="${SWITZERLAND_FTP_SERVERS}" ;; taiwan*) VAL="${TAIWAN_FTP_SERVERS}" ;; turkey*) VAL="${TURKEY_FTP_SERVERS}" ;; ukraine*) VAL="${UKRAINE_FTP_SERVERS}" ;; uk*) VAL="${UK_FTP_SERVERS}" ;; usa*) VAL="${USA_FTP_SERVERS}" ;; esac else VAL="${MAIN_FTP_SERVERS}" VAL="${VAL}|${IPV6_FTP_SERVERS}" VAL="${VAL}|${PRIMARY_FTP_SERVERS}" VAL="${VAL}|${ARGENTINA_FTP_SERVERS}" VAL="${VAL}|${AUSTRALIA_FTP_SERVERS}" VAL="${VAL}|${AUSTRIA_FTP_SERVERS}" VAL="${VAL}|${BRAZIL_FTP_SERVERS}" VAL="${VAL}|${CANADA_FTP_SERVERS}" VAL="${VAL}|${CHINA_FTP_SERVERS}" VAL="${VAL}|${CROATIA_FTP_SERVERS}" VAL="${VAL}|${CZECH_REPUBLIC_FTP_SERVERS}" VAL="${VAL}|${DENMARK_FTP_SERVERS}" VAL="${VAL}|${ESTONIA_FTP_SERVERS}" VAL="${VAL}|${FINLAND_FTP_SERVERS}" VAL="${VAL}|${FRANCE_FTP_SERVERS}" VAL="${VAL}|${GERMANY_FTP_SERVERS}" VAL="${VAL}|${GREECE_FTP_SERVERS}" VAL="${VAL}|${HUNGARY_FTP_SERVERS}" VAL="${VAL}|${ICELAND_FTP_SERVERS}" VAL="${VAL}|${IRELAND_FTP_SERVERS}" VAL="${VAL}|${ISRAEL_FTP_SERVERS}" VAL="${VAL}|${ITALY_FTP_SERVERS}" VAL="${VAL}|${JAPAN_FTP_SERVERS}" VAL="${VAL}|${KOREA_FTP_SERVERS}" VAL="${VAL}|${LITHUANIA_FTP_SERVERS}" VAL="${VAL}|${NETHERLANDS_FTP_SERVERS}" VAL="${VAL}|${NORWAY_FTP_SERVERS}" VAL="${VAL}|${POLAND_FTP_SERVERS}" VAL="${VAL}|${PORTUGAL_FTP_SERVERS}" VAL="${VAL}|${ROMANIA_FTP_SERVERS}" VAL="${VAL}|${RUSSIA_FTP_SERVERS}" VAL="${VAL}|${SINGAPORE_FTP_SERVERS}" VAL="${VAL}|${SLOVAK_REPUBLIC_FTP_SERVERS}" VAL="${VAL}|${SLOVENIA_FTP_SERVERS}" VAL="${VAL}|${SOUTH_AFRICA_FTP_SERVERS}" VAL="${VAL}|${SPAIN_FTP_SERVERS}" VAL="${VAL}|${SWEDEN_FTP_SERVERS}" VAL="${VAL}|${SWITZERLAND_FTP_SERVERS}" VAL="${VAL}|${TAIWAN_FTP_SERVERS}" VAL="${VAL}|${TURKEY_FTP_SERVERS}" VAL="${VAL}|${UKRAINE_FTP_SERVERS}" VAL="${VAL}|${UK_FTP_SERVERS}" VAL="${VAL}|${USA_FTP_SERVERS}" fi export VAL }; Index: head/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh (revision 211730) @@ -1,166 +1,165 @@ #!/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 which check and load any optional modules specified in the config . ${BACKEND}/functions.sh . ${BACKEND}/functions-parse.sh copy_component() { COMPONENT="$1" FAILED="0" CFILES="" # Check the type, and set the components subdir properly TYPE="`grep 'type:' ${COMPDIR}/${COMPONENT}/component.cfg | cut -d ' ' -f 2`" if [ "${TYPE}" = "PBI" ] then SUBDIR="PBI" else SUBDIR="components" fi # Lets start by downloading / copying the files this component needs while read line do CFILE="`echo $line | cut -d ':' -f 1`" CFILEMD5="`echo $line | cut -d ':' -f 2`" CFILE2MD5="`echo $line | cut -d ':' -f 3`" - case ${INSTALLMEDIUM} in - dvd|usb) # On both dvd / usb, we can just copy the file - cp ${CDMNT}/${COMPFILEDIR}/${SUBDIR}/${CFILE} \ - ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT} + dvd|usb) + # On both dvd / usb, we can just copy the file + cp ${CDMNT}/${COMPFILEDIR}/${SUBDIR}/${CFILE} \ + ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT} RESULT="$?" - ;; - ftp) get_value_from_cfg ftpPath - if [ -z "$VAL" ] - then - exit_err "ERROR: Install medium was set to ftp, but no ftpPath was provided!" - fi - FTPPATH="${VAL}" + ;; - fetch_file "${FTPPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE}" "${FSMNT}/${COMPTMPDIR}/${CFILE}" "0" - RESULT="$?" - ;; + ftp|sftp) + get_value_from_cfg ftpPath + if [ -z "$VAL" ] + then + exit_err "ERROR: Install medium was set to ftp, but no ftpPath was provided!" + fi + FTPPATH="${VAL}" + + fetch_file "${FTPPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE}" "${FSMNT}/${COMPTMPDIR}/${CFILE}" "0" + RESULT="$?" + ;; esac if [ "${RESULT}" != "0" ] then echo_log "WARNING: Failed to copy ${CFILE}" FAILED="1" else # Now lets check the MD5 to confirm the file is valid CHECKMD5=`md5 -q ${FSMNT}/${COMPTMPDIR}/${CFILE}` if [ "${CHECKMD5}" != "${CFILEMD5}" -a "${CHECKMD5}" != "${CFILE2MD5}" ] then echo_log "WARNING: ${CFILE} failed md5 checksum" FAILED="1" else if [ -z "${CFILES}" ] then CFILES="${CFILE}" else CFILES="${CFILES},${CFILE}" fi fi fi done < ${COMPDIR}/${COMPONENT}/distfiles if [ "${FAILED}" = "0" ] then # Now install the component run_component_install ${COMPONENT} ${CFILES} fi }; run_component_install() { COMPONENT="$1" CFILES="$1" # Lets install this component now # Start by making a wrapper script which sets the variables # for the component to use echo "#!/bin/sh COMPTMPDIR=\"${COMPTMPDIR}\" export COMPTMPDIR CFILE=\"${CFILE}\" export CFILE sh ${COMPTMPDIR}/install.sh " >${FSMNT}/.componentwrapper.sh - chmod 755 ${FSMNT}/.componentwrapper.sh + chmod 755 ${FSMNT}/.componentwrapper.sh - # Copy over the install script for this component - cp ${COMPDIR}/${COMPONENT}/install.sh ${FSMNT}/${COMPTMPDIR}/ + # Copy over the install script for this component + cp ${COMPDIR}/${COMPONENT}/install.sh ${FSMNT}/${COMPTMPDIR}/ - echo_log "INSTALL COMPONENT: ${i}" - chroot ${FSMNT} /.componentwrapper.sh >>${LOGOUT} 2>>${LOGOUT} - rm ${FSMNT}/.componentwrapper.sh + echo_log "INSTALL COMPONENT: ${i}" + chroot ${FSMNT} /.componentwrapper.sh >>${LOGOUT} 2>>${LOGOUT} + rm ${FSMNT}/.componentwrapper.sh - }; # Check for any modules specified, and begin loading them install_components() { - # First, lets check and see if we even have any optional modules - get_value_from_cfg installComponents - if [ ! -z "${VAL}" ] - then - # Lets start by cleaning up the string and getting it ready to parse - strip_white_space ${VAL} - COMPONENTS=`echo ${VAL} | sed -e "s|,| |g"` - for i in $COMPONENTS - do - if [ ! -e "${COMPDIR}/${i}/install.sh" -o ! -e "${COMPDIR}/${i}/distfiles" ] - then - echo_log "WARNING: Component ${i} doesn't seem to exist" - else + # First, lets check and see if we even have any optional modules + get_value_from_cfg installComponents + if [ ! -z "${VAL}" ] + then + # Lets start by cleaning up the string and getting it ready to parse + strip_white_space ${VAL} + COMPONENTS=`echo ${VAL} | sed -e "s|,| |g"` + for i in $COMPONENTS + do + if [ ! -e "${COMPDIR}/${i}/install.sh" -o ! -e "${COMPDIR}/${i}/distfiles" ] + then + echo_log "WARNING: Component ${i} doesn't seem to exist" + else - # Make the tmpdir on the disk - mkdir -p ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT} + # Make the tmpdir on the disk + mkdir -p ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT} - # Start by grabbing the component files - copy_component ${i} + # Start by grabbing the component files + copy_component ${i} - # Remove the tmpdir now - rm -rf ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT} - - fi - done - - fi + # Remove the tmpdir now + rm -rf ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT} + fi + done + fi }; Index: head/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh (revision 211730) @@ -1,125 +1,125 @@ #!/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 which check and load any optional packages specified in the config . ${BACKEND}/functions.sh . ${BACKEND}/functions-parse.sh # Recursively determine all dependencies for this package determine_package_dependencies() { - local PKGNAME="${1}" - local DEPFILE="${2}" + local PKGNAME="${1}" + local DEPFILE="${2}" - grep "${PKGNAME}" "${DEPFILE}" >/dev/null - if [ "$?" -ne "0" ] - then - echo "${PKGNAME}" >> "${DEPFILE}" - get_package_dependencies "${PKGNAME}" "1" - local DEPS="${VAL}" + grep "${PKGNAME}" "${DEPFILE}" >/dev/null + if [ "$?" -ne "0" ] + then + echo "${PKGNAME}" >> "${DEPFILE}" + get_package_dependencies "${PKGNAME}" "1" - for d in ${DEPS} - do - determine_package_dependencies "${d}" "${DEPFILE}" - done - fi + local DEPS="${VAL}" + for d in ${DEPS} + do + determine_package_dependencies "${d}" "${DEPFILE}" + done + fi }; # Fetch packages dependencies from a file fetch_package_dependencies() { - local DEPFILE - local DEPS - local SAVEDIR + local DEPFILE + local DEPS + local SAVEDIR - DEPFILE="${1}" - DEPS=`cat "${DEPFILE}"` - SAVEDIR="${2}" + DEPFILE="${1}" + DEPS=`cat "${DEPFILE}"` + SAVEDIR="${2}" - for d in ${DEPS} - do - get_package_short_name "${d}" - SNAME="${VAL}" + for d in ${DEPS} + do + get_package_short_name "${d}" + SNAME="${VAL}" - get_package_category "${SNAME}" - CATEGORY="${VAL}" + get_package_category "${SNAME}" + CATEGORY="${VAL}" - fetch_package "${CATEGORY}" "${d}" "${SAVEDIR}" - done + fetch_package "${CATEGORY}" "${d}" "${SAVEDIR}" + done }; # Check for any packages specified, and begin loading them install_packages() { - # First, lets check and see if we even have any packages to install - get_value_from_cfg installPackages - if [ ! -z "${VAL}" ] - then - HERE=`pwd` - rc_nohalt "mkdir -p ${FSMNT}/${PKGTMPDIR}" - rc_nohalt "cd ${FSMNT}/${PKGTMPDIR}" + # First, lets check and see if we even have any packages to install + get_value_from_cfg installPackages + if [ ! -z "${VAL}" ] + then + HERE=`pwd` + rc_nohalt "mkdir -p ${FSMNT}/${PKGTMPDIR}" + rc_nohalt "cd ${FSMNT}/${PKGTMPDIR}" - if [ ! -f "${CONFDIR}/INDEX" ] - then - get_package_index - fi + if [ ! -f "${CONFDIR}/INDEX" ] + then + get_package_index + fi - if [ ! -f "${CONFDIR}/INDEX.parsed" ] - then - parse_package_index - fi + if [ ! -f "${CONFDIR}/INDEX.parsed" ] + then + parse_package_index + fi - # Lets start by cleaning up the string and getting it ready to parse - strip_white_space ${VAL} - PACKAGES=`echo ${VAL} | sed -e "s|,| |g"` - for i in $PACKAGES - do - if get_package_name "${i}" - then - PKGNAME="${VAL}" - DEPFILE="${FSMNT}/${PKGTMPDIR}/.${PKGNAME}.deps" + # Lets start by cleaning up the string and getting it ready to parse + strip_white_space ${VAL} + PACKAGES=`echo ${VAL} | sed -e "s|,| |g"` + for i in $PACKAGES + do + if get_package_name "${i}" + then + PKGNAME="${VAL}" + DEPFILE="${FSMNT}/${PKGTMPDIR}/.${PKGNAME}.deps" - rc_nohalt "touch ${DEPFILE}" - determine_package_dependencies "${PKGNAME}" "${DEPFILE}" - fetch_package_dependencies "${DEPFILE}" "${FSMNT}/${PKGTMPDIR}" + rc_nohalt "touch ${DEPFILE}" + determine_package_dependencies "${PKGNAME}" "${DEPFILE}" + fetch_package_dependencies "${DEPFILE}" "${FSMNT}/${PKGTMPDIR}" - # If the package is not already installed, install it! - if ! run_chroot_cmd "pkg_info -e ${PKGNAME}" - then - rc_nohalt "pkg_add -C ${FSMNT} ${PKGTMPDIR}/${PKGNAME}.tbz" - fi + # If the package is not already installed, install it! + if ! run_chroot_cmd "pkg_info -e ${PKGNAME}" + then + rc_nohalt "pkg_add -C ${FSMNT} ${PKGTMPDIR}/${PKGNAME}.tbz" + fi - rc_nohalt "rm ${DEPFILE}" - fi + rc_nohalt "rm ${DEPFILE}" + fi - rc_nohalt "cd ${HERE}" - done + rc_nohalt "cd ${HERE}" + done - #rm -rf "${FSMNT}/${PKGTMPDIR}" - fi + rm -rf "${FSMNT}/${PKGTMPDIR}" + fi }; Index: head/usr.sbin/pc-sysinstall/backend/functions-localize.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-localize.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-localize.sh (revision 211730) @@ -1,474 +1,511 @@ #!/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 which runs commands on the system . ${BACKEND}/functions.sh . ${BACKEND}/functions-parse.sh # Function which localizes a FreeBSD install localize_freebsd() { sed -i.bak "s/lang=en_US/lang=${LOCALE}/g" ${FSMNT}/etc/login.conf rm ${FSMNT}/etc/login.conf.bak }; # Function which localizes a PC-BSD install localize_pcbsd() { #Change the skel files ########################################################################## sed -i.bak "s/Country=us/Country=${COUNTRY}/g" ${FSMNT}/usr/share/skel/.kde4/share/config/kdeglobals sed -i.bak "s/Country=us/Country=${COUNTRY}/g" ${FSMNT}/root/.kde4/share/config/kdeglobals sed -i.bak "s/Language=en_US/Language=${SETLANG}:${LOCALE}/g" ${FSMNT}/usr/share/skel/.kde4/share/config/kdeglobals sed -i.bak "s/Language=en_US/Language=${SETLANG}:${LOCALE}/g" ${FSMNT}/root/.kde4/share/config/kdeglobals #Change KDM Langs ########################################################################## sed -i.bak "s/Language=en_US/Language=${LOCALE}.UTF-8/g" ${FSMNT}/usr/local/kde4/share/config/kdm/kdmrc # Check if we have a localized splash screen and copy it if [ -e "${FSMNT}/usr/PCBSD/splash-screens/loading-screen-${SETLANG}.pcx" ] then cp ${FSMNT}/usr/PCBSD/splash-screens/loading-screen-${SETLANG}.pcx ${FSMNT}/boot/loading-screen.pcx fi }; localize_x_keyboard() { - KEYMOD="$1" - KEYLAY="$2" - KEYVAR="$3" - COUNTRY="$4" - OPTION="grp:alt_shift_toggle" - SETXKBMAP="" + KEYMOD="$1" + KEYLAY="$2" + KEYVAR="$3" + COUNTRY="$4" + OPTION="grp:alt_shift_toggle" + SETXKBMAP="" - if [ "${COUNTRY}" = "NONE" -o "${COUNTRY}" = "us" -o "${COUNTRY}" = "C" ] ; then - #In this case we don't need any additional language - COUNTRY="" - OPTION="" - else - COUNTRY=",${COUNTRY}" - fi + if [ "${COUNTRY}" = "NONE" -o "${COUNTRY}" = "us" -o "${COUNTRY}" = "C" ] ; then + #In this case we don't need any additional language + COUNTRY="" + OPTION="" + else + COUNTRY=",${COUNTRY}" + fi - if [ "${KEYMOD}" != "NONE" ] - then - SETXKBMAP="-model ${KEYMOD}" - KXMODEL="${KEYMOD}" - else - KXMODEL="pc104" - fi + if [ "${KEYMOD}" != "NONE" ] + then + SETXKBMAP="-model ${KEYMOD}" + KXMODEL="${KEYMOD}" + else + KXMODEL="pc104" + fi - if [ "${KEYLAY}" != "NONE" ] - then - localize_key_layout "$KEYLAY" - SETXKBMAP="${SETXKBMAP} -layout ${KEYLAY}" - KXLAYOUT="${KEYLAY}" - else - KXLAYOUT="us" - fi + if [ "${KEYLAY}" != "NONE" ] + then + localize_key_layout "$KEYLAY" + SETXKBMAP="${SETXKBMAP} -layout ${KEYLAY}" + KXLAYOUT="${KEYLAY}" + else + KXLAYOUT="us" + fi - if [ "${KEYVAR}" != "NONE" ] - then - SETXKBMAP="${SETXKBMAP} -variant ${KEYVAR}" - KXVAR="(${KEYVAR})" - else - KXVAR="" - fi + if [ "${KEYVAR}" != "NONE" ] + then + SETXKBMAP="${SETXKBMAP} -variant ${KEYVAR}" + KXVAR="(${KEYVAR})" + else + KXVAR="" + fi - # Setup .xprofile with our setxkbmap call now - if [ ! -z "${SETXKBMAP}" ] - then - if [ ! -e "${FSMNT}/usr/share/skel/.xprofile" ] - then - echo "#!/bin/sh" >${FSMNT}/usr/share/skel/.xprofile - fi + # Setup .xprofile with our setxkbmap call now + if [ ! -z "${SETXKBMAP}" ] + then + if [ ! -e "${FSMNT}/usr/share/skel/.xprofile" ] + then + echo "#!/bin/sh" >${FSMNT}/usr/share/skel/.xprofile + fi - # Save the keyboard layout for user / root X logins - echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/share/skel/.xprofile - chmod 755 ${FSMNT}/usr/share/skel/.xprofile - cp ${FSMNT}/usr/share/skel/.xprofile ${FSMNT}/root/.xprofile + # Save the keyboard layout for user / root X logins + echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/share/skel/.xprofile + chmod 755 ${FSMNT}/usr/share/skel/.xprofile + cp ${FSMNT}/usr/share/skel/.xprofile ${FSMNT}/root/.xprofile - # Save it for KDM - echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/local/kde4/share/config/kdm/Xsetup - fi + # Save it for KDM + echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/local/kde4/share/config/kdm/Xsetup + fi # Create the kxkbrc configuration using these options - echo "[Layout] + echo "[Layout] DisplayNames=${KXLAYOUT}${COUNTRY} IndicatorOnly=false LayoutList=${KXLAYOUT}${KXVAR}${COUNTRY} Model=${KXMODEL} Options=${OPTION} ResetOldOptions=true ShowFlag=true ShowSingle=false SwitchMode=WinClass Use=true " >${FSMNT}/usr/share/skel/.kde4/share/config/kxkbrc }; localize_key_layout() { KEYLAYOUT="$1" # Set the keylayout in rc.conf case ${KEYLAYOUT} in am) KEYLAYOUT_CONSOLE="hy.armscii-8" ;; ch) KEYLAYOUT_CONSOLE="swissgerman.iso" ;; cz) KEYLAYOUT_CONSOLE="cz.iso2" ;; de) KEYLAYOUT_CONSOLE="german.iso" ;; dk) KEYLAYOUT_CONSOLE="danish.iso" ;; ee) KEYLAYOUT_CONSOLE="estonian.iso" ;; es) KEYLAYOUT_CONSOLE="spanish.iso" ;; fi) KEYLAYOUT_CONSOLE="finnish.iso" ;; is) KEYLAYOUT_CONSOLE="icelandic.iso" ;; jp) KEYLAYOUT_CONSOLE="jp.106" ;; nl) KEYLAYOUT_CONSOLE="dutch.iso.acc" ;; no) KEYLAYOUT_CONSOLE="norwegian.iso" ;; pl) KEYLAYOUT_CONSOLE="pl_PL.ISO8859-2" ;; ru) KEYLAYOUT_CONSOLE="ru.koi8-r" ;; sk) KEYLAYOUT_CONSOLE="sk.iso2" ;; se) KEYLAYOUT_CONSOLE="swedish.iso" ;; tr) KEYLAYOUT_CONSOLE="tr.iso9.q" ;; gb) KEYLAYOUT_CONSOLE="uk.iso" ;; *) if [ ! -z "${KEYLAYOUT}" ] then KEYLAYOUT_CONSOLE="${KEYLAYOUT}.iso" fi ;; esac if [ ! -z "${KEYLAYOUT_CONSOLE}" ] then echo "keymap=\"${KEYLAYOUT_CONSOLE}\"" >>${FSMNT}/etc/rc.conf fi }; # Function which prunes other l10n files from the KDE install localize_prune_langs() { get_value_from_cfg localizeLang KEEPLANG="$VAL" if [ -z "$KEEPLANG" ] ; then KEEPLANG="en" fi export KEEPLANG echo_log "Pruning other l10n files, keeping ${KEEPLANG}" # Create the script to do uninstalls echo '#!/bin/sh for i in `pkg_info | grep "kde-l10n" | cut -d " " -f 1` do echo "$i" | grep "${KEEPLANG}-kde" if [ "$?" != "0" ] ; then pkg_delete ${i} fi done ' > ${FSMNT}/.pruneLangs.sh chmod 755 ${FSMNT}/.pruneLangs.sh chroot ${FSMNT} /.pruneLangs.sh >/dev/null 2>/dev/null rm ${FSMNT}/.pruneLangs.sh }; # Function which sets COUNTRY SETLANG and LOCALE based upon $1 localize_get_codes() { TARGETLANG="${1}" # Setup the presets for the specific lang case $TARGETLANG in - af) COUNTRY="C" - SETLANG="af" - LOCALE="af_ZA" - ;; - ar) COUNTRY="C" - SETLANG="ar" - LOCALE="en_US" - ;; - az) COUNTRY="C" - SETLANG="az" - LOCALE="en_US" - ;; - ca) COUNTRY="es" - SETLANG="es:ca" - LOCALE="ca_ES" - ;; - be) COUNTRY="be" - SETLANG="be" - LOCALE="be_BY" - ;; - bn) COUNTRY="bn" - SETLANG="bn" - LOCALE="en_US" - ;; - bg) COUNTRY="bg" - SETLANG="bg" - LOCALE="bg_BG" - ;; - cs) COUNTRY="cz" - SETLANG="cs" - LOCALE="cs_CZ" - ;; - da) COUNTRY="dk" - SETLANG="da" - LOCALE="da_DK" - ;; - de) COUNTRY="de" - SETLANG="de" - LOCALE="de_DE" - ;; - en_GB) COUNTRY="gb" - SETLANG="en_GB:cy" - LOCALE="en_GB" - ;; - el) COUNTRY="gr" - SETLANG="el:gr" - LOCALE="el_GR" - ;; - es) COUNTRY="es" - SETLANG="es" - LOCALE="es_ES" - ;; - es_LA) COUNTRY="us" - SETLANG="es:en_US" - LOCALE="es_ES" - ;; - et) COUNTRY="ee" - SETLANG="et" - LOCALE="et_EE" - ;; - fr) COUNTRY="fr" - SETLANG="fr" - LOCALE="fr_FR" - ;; - he) COUNTRY="il" - SETLANG="he:ar" - LOCALE="he_IL" - ;; - hr) COUNTRY="hr" - SETLANG="hr" - LOCALE="hr_HR" - ;; - hu) COUNTRY="hu" - SETLANG="hu" - LOCALE="hu_HU" - ;; - it) COUNTRY="it" - SETLANG="it" - LOCALE="it_IT" - ;; - ja) COUNTRY="jp" - SETLANG="ja" - LOCALE="ja_JP" - ;; - ko) COUNTRY="kr" - SETLANG="ko" - LOCALE="ko_KR" - ;; - nl) COUNTRY="nl" - SETLANG="nl" - LOCALE="nl_NL" - ;; - nn) COUNTRY="no" - SETLANG="nn" - LOCALE="en_US" - ;; - pa) COUNTRY="pa" - SETLANG="pa" - LOCALE="en_US" - ;; - pl) COUNTRY="pl" - SETLANG="pl" - LOCALE="pl_PL" - ;; - pt) COUNTRY="pt" - SETLANG="pt" - LOCALE="pt_PT" - ;; - pt_BR) COUNTRY="br" - SETLANG="pt_BR" - LOCALE="pt_BR" - ;; - ru) COUNTRY="ru" - SETLANG="ru" - LOCALE="ru_RU" - ;; - sl) COUNTRY="si" - SETLANG="sl" - LOCALE="sl_SI" - ;; - sk) COUNTRY="sk" - SETLANG="sk" - LOCALE="sk_SK" - ;; - sv) COUNTRY="se" - SETLANG="sv" - LOCALE="sv_SE" - ;; - uk) COUNTRY="ua" - SETLANG="uk" - LOCALE="uk_UA" - ;; - vi) COUNTRY="vn" - SETLANG="vi" - LOCALE="en_US" - ;; - zh_CN) COUNTRY="cn" - SETLANG="zh_CN" - LOCALE="zh_CN" - ;; - zh_TW) COUNTRY="tw" - SETLANG="zh_TW" - LOCALE="zh_TW" - ;; - *) COUNTRY="C" + af) + COUNTRY="C" + SETLANG="af" + LOCALE="af_ZA" + ;; + ar) + COUNTRY="C" + SETLANG="ar" + LOCALE="en_US" + ;; + az) + COUNTRY="C" + SETLANG="az" + LOCALE="en_US" + ;; + ca) + COUNTRY="es" + SETLANG="es:ca" + LOCALE="ca_ES" + ;; + be) + COUNTRY="be" + SETLANG="be" + LOCALE="be_BY" + ;; + bn) + COUNTRY="bn" + SETLANG="bn" + LOCALE="en_US" + ;; + bg) + COUNTRY="bg" + SETLANG="bg" + LOCALE="bg_BG" + ;; + cs) + COUNTRY="cz" + SETLANG="cs" + LOCALE="cs_CZ" + ;; + da) + COUNTRY="dk" + SETLANG="da" + LOCALE="da_DK" + ;; + de) + COUNTRY="de" + SETLANG="de" + LOCALE="de_DE" + ;; + en_GB) + COUNTRY="gb" + SETLANG="en_GB:cy" + LOCALE="en_GB" + ;; + el) + COUNTRY="gr" + SETLANG="el:gr" + LOCALE="el_GR" + ;; + es) + COUNTRY="es" + SETLANG="es" + LOCALE="es_ES" + ;; + es_LA) + COUNTRY="us" + SETLANG="es:en_US" + LOCALE="es_ES" + ;; + et) + COUNTRY="ee" + SETLANG="et" + LOCALE="et_EE" + ;; + fr) + COUNTRY="fr" + SETLANG="fr" + LOCALE="fr_FR" + ;; + he) + COUNTRY="il" + SETLANG="he:ar" + LOCALE="he_IL" + ;; + hr) + COUNTRY="hr" + SETLANG="hr" + LOCALE="hr_HR" + ;; + hu) + COUNTRY="hu" + SETLANG="hu" + LOCALE="hu_HU" + ;; + it) + COUNTRY="it" + SETLANG="it" + LOCALE="it_IT" + ;; + ja) + COUNTRY="jp" + SETLANG="ja" + LOCALE="ja_JP" + ;; + ko) + COUNTRY="kr" + SETLANG="ko" + LOCALE="ko_KR" + ;; + nl) + COUNTRY="nl" + SETLANG="nl" + LOCALE="nl_NL" + ;; + nn) + COUNTRY="no" + SETLANG="nn" + LOCALE="en_US" + ;; + pa) + COUNTRY="pa" + SETLANG="pa" + LOCALE="en_US" + ;; + pl) + COUNTRY="pl" + SETLANG="pl" + LOCALE="pl_PL" + ;; + pt) + COUNTRY="pt" + SETLANG="pt" + LOCALE="pt_PT" + ;; + pt_BR) + COUNTRY="br" + SETLANG="pt_BR" + LOCALE="pt_BR" + ;; + ru) + COUNTRY="ru" + SETLANG="ru" + LOCALE="ru_RU" + ;; + sl) + COUNTRY="si" + SETLANG="sl" + LOCALE="sl_SI" + ;; + sk) + COUNTRY="sk" + SETLANG="sk" + LOCALE="sk_SK" + ;; + sv) + COUNTRY="se" + SETLANG="sv" + LOCALE="sv_SE" + ;; + uk) + COUNTRY="ua" + SETLANG="uk" + LOCALE="uk_UA" + ;; + vi) + COUNTRY="vn" + SETLANG="vi" + LOCALE="en_US" + ;; + zh_CN) + COUNTRY="cn" + SETLANG="zh_CN" + LOCALE="zh_CN" + ;; + zh_TW) + COUNTRY="tw" + SETLANG="zh_TW" + LOCALE="zh_TW" + ;; + *) + COUNTRY="C" SETLANG="${TARGETLANG}" LOCALE="en_US" ;; esac - export COUNTRY SETLANG LOCALE + export COUNTRY SETLANG LOCALE }; # Function which sets the timezone on the system set_timezone() { TZONE="$1" cp ${FSMNT}/usr/share/zoneinfo/${TZONE} ${FSMNT}/etc/localtime }; # Function which enables / disables NTP set_ntp() { ENABLED="$1" if [ "$ENABLED" = "yes" -o "${ENABLED}" = "YES" ] then cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep 'ntpd_enable="YES"' >/dev/null 2>/dev/null if [ "$?" != "0" ] then echo 'ntpd_enable="YES"' >>${FSMNT}/etc/rc.conf echo 'ntpd_sync_on_start="YES"' >>${FSMNT}/etc/rc.conf fi else cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep 'ntpd_enable="YES"' >/dev/null 2>/dev/null if [ "$?" != "0" ] then sed -i.bak 's|ntpd_enable="YES"||g' ${FSMNT}/etc/rc.conf fi fi }; # Starts checking for localization directives run_localize() { KEYLAYOUT="NONE" KEYMOD="NONE" KEYVAR="NONE" while read line do # Check if we need to do any localization echo $line | grep "^localizeLang=" >/dev/null 2>/dev/null if [ "$?" = "0" ] then # Set our country / lang / locale variables get_value_from_string "$line" localize_get_codes ${VAL} get_value_from_string "$line" # If we are doing PC-BSD install, localize it as well as FreeBSD base if [ "${INSTALLTYPE}" != "FreeBSD" ] then localize_pcbsd "$VAL" fi localize_freebsd "$VAL" fi # Check if we need to do any keylayouts echo $line | grep "^localizeKeyLayout=" >/dev/null 2>/dev/null if [ "$?" = "0" ] ; then get_value_from_string "$line" KEYLAYOUT="$VAL" fi # Check if we need to do any key models echo $line | grep "^localizeKeyModel=" >/dev/null 2>/dev/null if [ "$?" = "0" ] ; then get_value_from_string "$line" KEYMOD="$VAL" fi # Check if we need to do any key variant echo $line | grep "^localizeKeyVariant=" >/dev/null 2>/dev/null if [ "$?" = "0" ] ; then get_value_from_string "$line" KEYVAR="$VAL" fi # Check if we need to set a timezone echo $line | grep "^timeZone=" >/dev/null 2>/dev/null if [ "$?" = "0" ] ; then get_value_from_string "$line" set_timezone "$VAL" fi # Check if we need to set a timezone echo $line | grep "^enableNTP=" >/dev/null 2>/dev/null if [ "$?" = "0" ] ; then get_value_from_string "$line" set_ntp "$VAL" fi done <${CFGF} if [ "${INSTALLTYPE}" != "FreeBSD" ] ; then # Do our X keyboard localization localize_x_keyboard "${KEYMOD}" "${KEYLAYOUT}" "${KEYVAR}" "${COUNTRY}" fi # Check if we want to prunt any other KDE lang files to save some disk space get_value_from_cfg localizePrune if [ "${VAL}" = "yes" -o "${VAL}" = "YES" ] ; then localize_prune_langs fi # Update the login.conf db, even if we didn't localize, its a good idea to make sure its up2date run_chroot_cmd "/usr/bin/cap_mkdb /etc/login.conf" >/dev/null 2>/dev/null }; Index: head/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh (revision 211730) @@ -1,190 +1,181 @@ #!/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 mounting the newly formatted disk partitions # Mounts all the specified partition to the mount-point mount_partition() { if [ -z "${1}" -o -z "${2}" -o -z "${3}" ] then exit_err "ERROR: Missing arguments for mount_partition" fi PART="${1}" PARTFS="${2}" MNTPOINT="${3}" MNTFLAGS="${4}" # Setup the MNTOPTS if [ -z "${MNTOPTS}" ] then MNTFLAGS="-o rw" else MNTFLAGS="-o rw,${MNTFLAGS}" fi #We are on ZFS, lets setup this mount-point if [ "${PARTFS}" = "ZFS" ] then - ZPOOLNAME=$(get_zpool_name "${PART}") + ZPOOLNAME=$(get_zpool_name "${PART}") - # Check if we have multiple zfs mounts specified - for ZMNT in `echo ${MNTPOINT} | sed 's|,| |g'` - do - # First make sure we create the mount point - if [ ! -d "${FSMNT}${ZMNT}" ] ; then - mkdir -p ${FSMNT}${ZMNT} >>${LOGOUT} 2>>${LOGOUT} - fi + # Check if we have multiple zfs mounts specified + for ZMNT in `echo ${MNTPOINT} | sed 's|,| |g'` + do + # First make sure we create the mount point + if [ ! -d "${FSMNT}${ZMNT}" ] ; then + mkdir -p ${FSMNT}${ZMNT} >>${LOGOUT} 2>>${LOGOUT} + fi - if [ "${ZMNT}" = "/" ] ; then - ZNAME="" - else - ZNAME="${ZMNT}" - echo_log "zfs create -p ${ZPOOLNAME}${ZNAME}" - rc_halt "zfs create -p ${ZPOOLNAME}${ZNAME}" - fi - sleep 2 - rc_halt "zfs set mountpoint=${FSMNT}${ZNAME} ${ZPOOLNAME}${ZNAME}" + if [ "${ZMNT}" = "/" ] ; then + ZNAME="" + else + ZNAME="${ZMNT}" + echo_log "zfs create -p ${ZPOOLNAME}${ZNAME}" + rc_halt "zfs create -p ${ZPOOLNAME}${ZNAME}" + fi + sleep 2 + rc_halt "zfs set mountpoint=${FSMNT}${ZNAME} ${ZPOOLNAME}${ZNAME}" - # Disable atime for this zfs partition, speed increase - rc_nohalt "zfs set atime=off ${ZPOOLNAME}${ZNAME}" - done + # Disable atime for this zfs partition, speed increase + rc_nohalt "zfs set atime=off ${ZPOOLNAME}${ZNAME}" + done else - # If we are not on ZFS, lets do the mount now + # If we are not on ZFS, lets do the mount now # First make sure we create the mount point if [ ! -d "${FSMNT}${MNTPOINT}" ] then mkdir -p ${FSMNT}${MNTPOINT} >>${LOGOUT} 2>>${LOGOUT} fi echo_log "mount ${MNTFLAGS} /dev/${PART} -> ${FSMNT}${MNTPOINT}" sleep 2 rc_halt "mount ${MNTFLAGS} /dev/${PART} ${FSMNT}${MNTPOINT}" fi }; # Mounts all the new file systems to prepare for installation mount_all_filesystems() { - # Make sure our mount point exists - mkdir -p ${FSMNT} >/dev/null 2>/dev/null + # Make sure our mount point exists + mkdir -p ${FSMNT} >/dev/null 2>/dev/null - # First lets find and mount the / partition - ######################################################### - for PART in `ls ${PARTDIR}` - do - if [ ! -e "/dev/${PART}" ] - then - exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?" - fi + # First lets find and mount the / partition + ######################################################### + for PART in `ls ${PARTDIR}` + do + if [ ! -e "/dev/${PART}" ] + then + exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?" + fi PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`" PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`" PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`" if [ "${PARTENC}" = "ON" ] then EXT=".eli" else EXT="" fi # Check for root partition for mounting, including ZFS "/,/usr" type echo "$PARTMNT" | grep "/," >/dev/null if [ "$?" = "0" -o "$PARTMNT" = "/" ] then case ${PARTFS} in - UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" - ;; - UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" - ;; - UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" - ;; - ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT} - ;; - *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;; + UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;; + UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;; + UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" ;; + ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT} ;; + *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;; esac - fi - - done + done - # Now that we've mounted "/" lets do any other remaining mount-points - ################################################################## - for PART in `ls ${PARTDIR}` - do - if [ ! -e "/dev/${PART}" ] - then - exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?" - fi + # Now that we've mounted "/" lets do any other remaining mount-points + ################################################################## + for PART in `ls ${PARTDIR}` + do + if [ ! -e "/dev/${PART}" ] + then + exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?" + fi - PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`" - PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`" - PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`" + PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`" + PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`" + PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`" - if [ "${PARTENC}" = "ON" ] - then - EXT=".eli" - else - EXT="" - fi + if [ "${PARTENC}" = "ON" ] + then + EXT=".eli" + else + EXT="" + fi - # Check if we've found "/" again, don't need to mount it twice - echo "$PARTMNT" | grep "/," >/dev/null - if [ "$?" != "0" -a "$PARTMNT" != "/" ] - then + # Check if we've found "/" again, don't need to mount it twice + echo "$PARTMNT" | grep "/," >/dev/null + if [ "$?" != "0" -a "$PARTMNT" != "/" ] + then case ${PARTFS} in - UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" - ;; - UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" - ;; - UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" - ;; - ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT} - ;; - SWAP) # Lets enable this swap now - if [ "$PARTENC" = "ON" ] - then - echo_log "Enabling encrypted swap on /dev/${PART}" - rc_halt "geli onetime -d -e 3des ${PART}" - sleep 5 - rc_halt "swapon /dev/${PART}.eli" - else - echo_log "swapon ${PART}" - sleep 5 - rc_halt "swapon /dev/${PART}" - fi - ;; + UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;; + UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;; + UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" ;; + ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT} ;; + SWAP) + # Lets enable this swap now + if [ "$PARTENC" = "ON" ] + then + echo_log "Enabling encrypted swap on /dev/${PART}" + rc_halt "geli onetime -d -e 3des ${PART}" + sleep 5 + rc_halt "swapon /dev/${PART}.eli" + else + echo_log "swapon ${PART}" + sleep 5 + rc_halt "swapon /dev/${PART}" + fi + ;; *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;; - esac - fi - done + esac + fi + done }; Index: head/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh (revision 211730) @@ -1,153 +1,153 @@ #!/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 which perform mounting / unmounting and switching of # optical / usb media . ${BACKEND}/functions.sh . ${BACKEND}/functions-parse.sh # Displays an optical failure message opt_fail() { - # If we got here, we must not have a DVD/USB we can find :( - get_value_from_cfg installInteractive - if [ "${VAL}" = "yes" ] - then - # We are running interactive, and didn't find a DVD, prompt user again - echo_log "DISK ERROR: Unable to find installation disk!" - echo_log "Please insert the installation disk and press enter." - read tmp - else - exit_err "ERROR: Unable to locate installation DVD/USB" - fi + # If we got here, we must not have a DVD/USB we can find :( + get_value_from_cfg installInteractive + if [ "${VAL}" = "yes" ] + then + # We are running interactive, and didn't find a DVD, prompt user again + echo_log "DISK ERROR: Unable to find installation disk!" + echo_log "Please insert the installation disk and press enter." + read tmp + else + exit_err "ERROR: Unable to locate installation DVD/USB" + fi }; # Performs the extraction of data to disk opt_mount() { - FOUND="0" + FOUND="0" - # Ensure we have a directory where its supposed to be - if [ ! -d "${CDMNT}" ] - then - mkdir -p ${CDMNT} - fi + # Ensure we have a directory where its supposed to be + if [ ! -d "${CDMNT}" ] + then + mkdir -p ${CDMNT} + fi - # Start by checking if we already have a cd mounted at CDMNT - mount | grep "${CDMNT} " >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - if [ -e "${CDMNT}/${INSFILE}" ] - then - echo "MOUNTED" >${TMPDIR}/cdmnt - echo_log "FOUND DVD: MOUNTED" - FOUND="1" - return - fi + # Start by checking if we already have a cd mounted at CDMNT + mount | grep "${CDMNT} " >/dev/null 2>/dev/null + if [ "$?" = "0" ] + then + if [ -e "${CDMNT}/${INSFILE}" ] + then + echo "MOUNTED" >${TMPDIR}/cdmnt + echo_log "FOUND DVD: MOUNTED" + FOUND="1" + return + fi - # failed to find optical disk - opt_fail - return - fi + # failed to find optical disk + opt_fail + return + fi -# Setup our loop to search for installation media - while - z=1 - do + # Setup our loop to search for installation media + while + z=1 + do - # Loop though and look for an installation disk - for i in `ls -1 /dev/acd* /dev/cd* /dev/scd* /dev/rscd* 2>/dev/null` - do - # Find the CD Device - /sbin/mount_cd9660 $i ${CDMNT} + # Loop though and look for an installation disk + for i in `ls -1 /dev/acd* /dev/cd* /dev/scd* /dev/rscd* 2>/dev/null` + do + # Find the CD Device + /sbin/mount_cd9660 $i ${CDMNT} - # Check the package type to see if we have our install data - if [ -e "${CDMNT}/${INSFILE}" ] - then - echo "${i}" >${TMPDIR}/cdmnt - echo_log "FOUND DVD: ${i}" - FOUND="1" - break - fi - /sbin/umount ${CDMNT} >/dev/null 2>/dev/null - done + # Check the package type to see if we have our install data + if [ -e "${CDMNT}/${INSFILE}" ] + then + echo "${i}" >${TMPDIR}/cdmnt + echo_log "FOUND DVD: ${i}" + FOUND="1" + break + fi + /sbin/umount ${CDMNT} >/dev/null 2>/dev/null + done - # If no DVD found, try USB - if [ "$FOUND" != "1" ] - then - # Loop though and look for an installation disk - for i in `ls -1 /dev/da* 2>/dev/null` - do - # Check if we can mount this device UFS - /sbin/mount -r $i ${CDMNT} + # If no DVD found, try USB + if [ "$FOUND" != "1" ] + then + # Loop though and look for an installation disk + for i in `ls -1 /dev/da* 2>/dev/null` + do + # Check if we can mount this device UFS + /sbin/mount -r $i ${CDMNT} - # Check the package type to see if we have our install data - if [ -e "${CDMNT}/${INSFILE}" ] - then - echo "${i}" >${TMPDIR}/cdmnt - echo_log "FOUND USB: ${i}" - FOUND="1" - break - fi - /sbin/umount ${CDMNT} >/dev/null 2>/dev/null + # Check the package type to see if we have our install data + if [ -e "${CDMNT}/${INSFILE}" ] + then + echo "${i}" >${TMPDIR}/cdmnt + echo_log "FOUND USB: ${i}" + FOUND="1" + break + fi + /sbin/umount ${CDMNT} >/dev/null 2>/dev/null - # Also check if it is a FAT mount - /sbin/mount -r -t msdosfs $i ${CDMNT} + # Also check if it is a FAT mount + /sbin/mount -r -t msdosfs $i ${CDMNT} - # Check the package type to see if we have our install data - if [ -e "${CDMNT}/${INSFILE}" ] - then - echo "${i}" >${TMPDIR}/cdmnt - echo_log "FOUND USB: ${i}" - FOUND="1" - break - fi - /sbin/umount ${CDMNT} >/dev/null 2>/dev/null - done - fi # End of USB Check + # Check the package type to see if we have our install data + if [ -e "${CDMNT}/${INSFILE}" ] + then + echo "${i}" >${TMPDIR}/cdmnt + echo_log "FOUND USB: ${i}" + FOUND="1" + break + fi + /sbin/umount ${CDMNT} >/dev/null 2>/dev/null + done + fi # End of USB Check - if [ "$FOUND" = "1" ] - then - break - fi + if [ "$FOUND" = "1" ] + then + break + fi - # Failed to find a disk, take action now - opt_fail + # Failed to find a disk, take action now + opt_fail - done + done }; # Function to unmount optical media opt_umount() { /sbin/umount ${CDMNT} >/dev/null 2>/dev/null }; Index: head/usr.sbin/pc-sysinstall/backend/functions-networking.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-networking.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-networking.sh (revision 211730) @@ -1,356 +1,357 @@ #!/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 which perform our networking setup # Function which creates a kde4 .desktop file for the PC-BSD net tray create_desktop_nettray() { NIC="${1}" echo "#!/usr/bin/env xdg-open [Desktop Entry] Exec=/usr/local/kde4/bin/pc-nettray ${NIC} Icon=network StartupNotify=false Type=Application" > ${FSMNT}/usr/share/skel/.kde4/Autostart/tray-${NIC}.desktop chmod 744 ${FSMNT}/usr/share/skel/.kde4/Autostart/tray-${NIC}.desktop }; # Function which checks is a nic is wifi or not check_is_wifi() { NIC="$1" ifconfig ${NIC} | grep "802.11" >/dev/null 2>/dev/null if [ "$?" = "0" ] then return 0 else return 1 fi }; # Function to get the first available wired nic, used for lagg0 setup get_first_wired_nic() { rm ${TMPDIR}/.niclist >/dev/null 2>/dev/null # start by getting a list of nics on this system ${QUERYDIR}/detect-nics.sh > ${TMPDIR}/.niclist if [ -e "${TMPDIR}/.niclist" ] then while read line do NIC="`echo $line | cut -d ':' -f 1`" check_is_wifi ${NIC} if [ "$?" != "0" ] then - VAL="${NIC}" ; export VAL - return + VAL="${NIC}" ; export VAL + return fi done < ${TMPDIR}/.niclist fi VAL="" ; export VAL return }; # Function which simply enables plain dhcp on all detected nics, not fancy lagg interface enable_plain_dhcp_all() { rm ${TMPDIR}/.niclist >/dev/null 2>/dev/null # start by getting a list of nics on this system ${QUERYDIR}/detect-nics.sh > ${TMPDIR}/.niclist if [ -e "${TMPDIR}/.niclist" ] then echo "# Auto-Enabled NICs from pc-sysinstall" >>${FSMNT}/etc/rc.conf WLANCOUNT="0" while read line do NIC="`echo $line | cut -d ':' -f 1`" DESC="`echo $line | cut -d ':' -f 2`" echo_log "Setting $NIC to DHCP on the system." check_is_wifi ${NIC} if [ "$?" = "0" ] then # We have a wifi device, setup a wlan* entry for it WLAN="wlan${WLANCOUNT}" echo "wlans_${NIC}=\"${WLAN}\"" >>${FSMNT}/etc/rc.conf echo "ifconfig_${WLAN}=\"DHCP\"" >>${FSMNT}/etc/rc.conf CNIC="${WLAN}" WLANCOUNT="`expr ${WLANCOUNT} + 1`" else echo "ifconfig_${NIC}=\"DHCP\"" >>${FSMNT}/etc/rc.conf CNIC="${NIC}" fi done < ${TMPDIR}/.niclist fi }; # Function which enables fancy lagg dhcp on specified wifi enable_lagg_dhcp() { WIFINIC="$1" # Get the first wired nic get_first_wired_nic WIRENIC=$VAL LAGGPORT="laggport ${WIFINIC}" echo "# Auto-Enabled NICs from pc-sysinstall" >>${FSMNT}/etc/rc.conf if [ ! -z "$WIRENIC" ] then echo "ifconfig_${WIRENIC}=\"up\"" >> ${FSMNT}/etc/rc.conf echo "ifconfig_${WIFINIC}=\"\`ifconfig ${WIRENIC} ether\`\"" >> ${FSMNT}/etc/rc.conf echo "ifconfig_${WIFINIC}=\"ether \${ifconfig_${WIFINIC}##*ether }\"" >> ${FSMNT}/etc/rc.conf LAGGPORT="laggport ${WIRENIC} ${LAGGPORT}" fi echo "wlans_${WIFINIC}=\"wlan0\"" >> ${FSMNT}/etc/rc.conf echo "cloned_interfaces=\"lagg0\"" >> ${FSMNT}/etc/rc.conf echo "ifconfig_lagg0=\"laggproto failover ${LAGGPORT} DHCP\"" >> ${FSMNT}/etc/rc.conf }; # Function which detects available nics, and runs them to DHCP on the save_auto_dhcp() { rm ${TMPDIR}/.niclist >/dev/null 2>/dev/null # start by getting a list of nics on this system ${QUERYDIR}/detect-nics.sh > ${TMPDIR}/.niclist if [ -e "${TMPDIR}/.niclist" ] then while read line do NIC="`echo $line | cut -d ':' -f 1`" DESC="`echo $line | cut -d ':' -f 2`" check_is_wifi "${NIC}" if [ "$?" = "0" ] then # We have a wifi device, lets do fancy lagg interface enable_lagg_dhcp "${NIC}" return fi done < ${TMPDIR}/.niclist fi # Got here, looks like no wifi, so lets simply enable plain-ole-dhcp enable_plain_dhcp_all }; # Function which saves a manual nic setup to the installed system save_manual_nic() { # Get the target nic NIC="$1" get_value_from_cfg netSaveIP NETIP="${VAL}" if [ "$NETIP" = "DHCP" ] then echo_log "Setting $NIC to DHCP on the system." echo "ifconfig_${NIC}=\"DHCP\"" >>${FSMNT}/etc/rc.conf return 0 fi # If we get here, we have a manual setup, lets do so now # Set the manual IP IFARGS="inet ${NETIP}" # Check if we have a netmask to set get_value_from_cfg netSaveMask NETMASK="${VAL}" if [ ! -z "${NETMASK}" ] then IFARGS="${IFARGS} netmask ${NETMASK}" fi echo "# Auto-Enabled NICs from pc-sysinstall" >>${FSMNT}/etc/rc.conf echo "ifconfig_${NIC}=\"${IFARGS}\"" >>${FSMNT}/etc/rc.conf # Check if we have a default router to set get_value_from_cfg netSaveDefaultRouter NETROUTE="${VAL}" if [ ! -z "${NETROUTE}" ] then echo "defaultrouter=\"${NETROUTE}\"" >>${FSMNT}/etc/rc.conf fi # Check if we have a nameserver to enable get_value_from_cfg netSaveNameServer NAMESERVER="${VAL}" if [ ! -z "${NAMESERVER}" ] then echo "nameserver ${NAMESERVER}" >${FSMNT}/etc/resolv.conf fi }; # Function which determines if a nic is active / up is_nic_active() { ifconfig ${1} | grep "status: active" >/dev/null 2>/dev/null if [ "$?" = "0" ] ; then return 0 else return 1 fi }; # Function which detects available nics, and runs DHCP on them until # a success is found enable_auto_dhcp() { # start by getting a list of nics on this system ${QUERYDIR}/detect-nics.sh > ${TMPDIR}/.niclist while read line do NIC="`echo $line | cut -d ':' -f 1`" DESC="`echo $line | cut -d ':' -f 2`" is_nic_active "${NIC}" if [ "$?" = "0" ] ; then - echo_log "Trying DHCP on $NIC $DESC" - dhclient ${NIC} >/dev/null 2>/dev/null - if [ "$?" = "0" ] ; then - # Got a valid DHCP IP, we can return now - WRKNIC="$NIC" ; export WRKNIC - return 0 - fi + echo_log "Trying DHCP on $NIC $DESC" + dhclient ${NIC} >/dev/null 2>/dev/null + if [ "$?" = "0" ] ; then + # Got a valid DHCP IP, we can return now + WRKNIC="$NIC" ; export WRKNIC + return 0 + fi fi done < ${TMPDIR}/.niclist }; # Get the mac address of a target NIC -get_nic_mac() { - FOUNDMAC="`ifconfig ${1} | grep 'ether' | tr -d '\t' | cut -d ' ' -f 2`" - export FOUNDMAC +get_nic_mac() +{ + FOUNDMAC="`ifconfig ${1} | grep 'ether' | tr -d '\t' | cut -d ' ' -f 2`" + export FOUNDMAC } # Function which performs the manual setup of a target nic in the cfg enable_manual_nic() { # Get the target nic NIC="$1" # Check that this NIC exists rc_halt "ifconfig ${NIC}" get_value_from_cfg netIP NETIP="${VAL}" if [ "$NETIP" = "DHCP" ] then echo_log "Enabling DHCP on $NIC" rc_halt "dhclient ${NIC}" return 0 fi # If we get here, we have a manual setup, lets do so now # Set the manual IP rc_halt "ifconfig ${NIC} ${NETIP}" # Check if we have a netmask to set get_value_from_cfg netMask NETMASK="${VAL}" if [ ! -z "${NETMASK}" ] then rc_halt "ifconfig ${NIC} netmask ${NETMASK}" fi # Check if we have a default router to set get_value_from_cfg netDefaultRouter NETROUTE="${VAL}" if [ ! -z "${NETROUTE}" ] then rc_halt "route add default ${NETROUTE}" fi # Check if we have a nameserver to enable get_value_from_cfg netNameServer NAMESERVER="${VAL}" if [ ! -z "${NAMESERVER}" ] then echo "nameserver ${NAMESERVER}" >/etc/resolv.conf fi }; # Function which parses the cfg and enables networking per specified start_networking() { # Check if we have any networking requested get_value_from_cfg netDev if [ -z "${VAL}" ] then return 0 fi NETDEV="${VAL}" if [ "$NETDEV" = "AUTO-DHCP" ] then enable_auto_dhcp else enable_manual_nic ${NETDEV} fi }; # Function which checks the cfg and enables the specified networking on # the installed system save_networking_install() { # Check if we have any networking requested to save get_value_from_cfg netSaveDev if [ -z "${VAL}" ] then return 0 fi NETDEV="${VAL}" if [ "$NETDEV" = "AUTO-DHCP" ] then save_auto_dhcp else save_manual_nic ${NETDEV} fi }; Index: head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-newfs.sh (revision 211730) @@ -1,182 +1,192 @@ #!/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 newfs # Function which performs the ZFS magic setup_zfs_filesystem() { PART="$1" PARTFS="$2" PARTMNT="$3" EXT="$4" PARTGEOM="$5" ZPOOLOPTS="$6" ROOTSLICE="`echo ${PART} | rev | cut -b 2- | rev`" ZPOOLNAME=$(get_zpool_name "${PART}") # Sleep a few moments, let the disk catch its breath sleep 5 sync # Check if we have some custom zpool arguments and use them if so if [ ! -z "${ZPOOLOPTS}" ] ; then rc_halt "zpool create -m none -f ${ZPOOLNAME} ${ZPOOLOPTS}" else # No zpool options, create pool on single device rc_halt "zpool create -m none -f ${ZPOOLNAME} ${PART}${EXT}" fi # Disable atime for this zfs partition, speed increase rc_nohalt "zfs set atime=off ${ZPOOLNAME}" # Check if we have multiple zfs mounts specified for i in `echo ${PARTMNT} | sed 's|,| |g'` do # Check if we ended up with needing a zfs bootable partition if [ "${i}" = "/" -o "${i}" = "/boot" ] then if [ "$HAVEBOOT" = "YES" ] ; then continue ; fi if [ "${PARTGEOM}" = "MBR" ] then # Lets stamp the proper ZFS boot loader echo_log "Setting up ZFS boot loader support" rc_halt "zpool set bootfs=${ZPOOLNAME} ${ZPOOLNAME}" rc_halt "zpool export ${ZPOOLNAME}" rc_halt "dd if=/boot/zfsboot of=/dev/${ROOTSLICE} count=1" rc_halt "dd if=/boot/zfsboot of=/dev/${PART}${EXT} skip=1 seek=1024" rc_halt "zpool import ${ZPOOLNAME}" fi fi done }; # Runs newfs on all the partiions which we've setup with bsdlabel setup_filesystems() { - # Create the keydir - rm -rf ${GELIKEYDIR} >/dev/null 2>/dev/null - mkdir ${GELIKEYDIR} + # Create the keydir + rm -rf ${GELIKEYDIR} >/dev/null 2>/dev/null + mkdir ${GELIKEYDIR} - # Lets go ahead and read through the saved partitions we created, and determine if we need to run - # newfs on any of them - for PART in `ls ${PARTDIR}` - do - if [ ! -e "/dev/${PART}" ] - then - exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?" - fi + # Lets go ahead and read through the saved partitions we created, and determine if we need to run + # newfs on any of them + for PART in `ls ${PARTDIR}` + do + if [ ! -e "/dev/${PART}" ] + then + exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?" + fi - PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`" - PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`" - PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`" - PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`" - PARTGEOM="`cat ${PARTDIR}/${PART} | cut -d ':' -f 5`" - PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 6`" + PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`" + PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`" + PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`" + PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`" + PARTGEOM="`cat ${PARTDIR}/${PART} | cut -d ':' -f 5`" + PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 6`" - # Make sure journaling isn't enabled on this device - if [ -e "/dev/${PART}.journal" ] - then - rc_nohalt "gjournal stop -f ${PART}.journal" - rc_nohalt "gjournal clear ${PART}" - fi + # Make sure journaling isn't enabled on this device + if [ -e "/dev/${PART}.journal" ] + then + rc_nohalt "gjournal stop -f ${PART}.journal" + rc_nohalt "gjournal clear ${PART}" + fi - # Setup encryption if necessary - if [ "${PARTENC}" = "ON" -a "${PARTFS}" != "SWAP" ] - then - echo_log "Creating geli provider for ${PART}" - rc_halt "dd if=/dev/random of=${GELIKEYDIR}/${PART}.key bs=64 count=1" - rc_halt "geli init -b -s 4096 -P -K ${GELIKEYDIR}/${PART}.key /dev/${PART}" - rc_halt "geli attach -p -k ${GELIKEYDIR}/${PART}.key /dev/${PART}" + # Setup encryption if necessary + if [ "${PARTENC}" = "ON" -a "${PARTFS}" != "SWAP" ] + then + echo_log "Creating geli provider for ${PART}" + rc_halt "dd if=/dev/random of=${GELIKEYDIR}/${PART}.key bs=64 count=1" + rc_halt "geli init -b -s 4096 -P -K ${GELIKEYDIR}/${PART}.key /dev/${PART}" + rc_halt "geli attach -p -k ${GELIKEYDIR}/${PART}.key /dev/${PART}" - EXT=".eli" - else - # No Encryption - EXT="" - fi + EXT=".eli" + else + # No Encryption + EXT="" + fi - case ${PARTFS} in - UFS) echo_log "NEWFS: /dev/${PART} - ${PARTFS}" - sleep 2 - rc_halt "newfs /dev/${PART}${EXT}" - sleep 2 - rc_halt "sync" - rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}" - rc_halt "sync" + case ${PARTFS} in + UFS) + echo_log "NEWFS: /dev/${PART} - ${PARTFS}" + sleep 2 + rc_halt "newfs /dev/${PART}${EXT}" + sleep 2 + rc_halt "sync" + rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}" + rc_halt "sync" - # Set flag that we've found a boot partition - if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then - HAVEBOOT="YES" - fi - sleep 2 - ;; - UFS+S) echo_log "NEWFS: /dev/${PART} - ${PARTFS}" - sleep 2 - rc_halt "newfs -U /dev/${PART}${EXT}" - sleep 2 - rc_halt "sync" - rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}" - rc_halt "sync" - # Set flag that we've found a boot partition - if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then - HAVEBOOT="YES" - fi - sleep 2 - ;; - UFS+J) echo_log "NEWFS: /dev/${PART} - ${PARTFS}" - sleep 2 - rc_halt "newfs /dev/${PART}${EXT}" - sleep 2 - rc_halt "gjournal label -f /dev/${PART}${EXT}" - sleep 2 - rc_halt "newfs -O 2 -J /dev/${PART}${EXT}.journal" - sleep 2 - rc_halt "sync" - rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal" - rc_halt "sync" - # Set flag that we've found a boot partition - if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then - HAVEBOOT="YES" - fi - sleep 2 - ;; - ZFS) echo_log "NEWFS: /dev/${PART} - ${PARTFS}" - setup_zfs_filesystem "${PART}" "${PARTFS}" "${PARTMNT}" "${EXT}" "${PARTGEOM}" "${PARTXTRAOPTS}" - ;; - SWAP) rc_halt "sync" - rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}" - rc_halt "sync" - sleep 2 - ;; - *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;; - esac + # Set flag that we've found a boot partition + if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then + HAVEBOOT="YES" + fi + sleep 2 + ;; - done + UFS+S) + echo_log "NEWFS: /dev/${PART} - ${PARTFS}" + sleep 2 + rc_halt "newfs -U /dev/${PART}${EXT}" + sleep 2 + rc_halt "sync" + rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}" + rc_halt "sync" + # Set flag that we've found a boot partition + if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then + HAVEBOOT="YES" + fi + sleep 2 + ;; + + UFS+J) + echo_log "NEWFS: /dev/${PART} - ${PARTFS}" + sleep 2 + rc_halt "newfs /dev/${PART}${EXT}" + sleep 2 + rc_halt "gjournal label -f /dev/${PART}${EXT}" + sleep 2 + rc_halt "newfs -O 2 -J /dev/${PART}${EXT}.journal" + sleep 2 + rc_halt "sync" + rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal" + rc_halt "sync" + # Set flag that we've found a boot partition + if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then + HAVEBOOT="YES" + fi + sleep 2 + ;; + + ZFS) + echo_log "NEWFS: /dev/${PART} - ${PARTFS}" + setup_zfs_filesystem "${PART}" "${PARTFS}" "${PARTMNT}" "${EXT}" "${PARTGEOM}" "${PARTXTRAOPTS}" + ;; + + SWAP) + rc_halt "sync" + rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}" + rc_halt "sync" + sleep 2 + ;; + + *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;; + esac + + done }; Index: head/usr.sbin/pc-sysinstall/backend/functions-packages.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-packages.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-packages.sh (revision 211730) @@ -1,380 +1,374 @@ #!/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 which runs commands on the system . ${BACKEND}/functions.sh . ${BACKEND}/functions-parse.sh . ${BACKEND}/functions-ftp.sh get_package_index_by_ftp() { - local INDEX_FILE - local FTP_SERVER + local INDEX_FILE + local FTP_SERVER - FTP_SERVER="${1}" - INDEX_FILE="INDEX" - USE_BZIP2=0 + FTP_SERVER="${1}" + INDEX_FILE="INDEX" + USE_BZIP2=0 - if [ -f "/usr/bin/bzip2" ] - then - INDEX_FILE="${INDEX_FILE}.bz2" - USE_BZIP2=1 - fi + if [ -f "/usr/bin/bzip2" ] + then + INDEX_FILE="${INDEX_FILE}.bz2" + USE_BZIP2=1 + fi - INDEX_PATH="${CONFDIR}/${INDEX_FILE}" - fetch_file "${FTP_SERVER}/${INDEX_FILE}" "${INDEX_PATH}" "1" - if [ -f "${INDEX_PATH}" ] && [ "${USE_BZIP2}" -eq "1" ] - then - bzip2 -d "${INDEX_PATH}" - fi + INDEX_PATH="${CONFDIR}/${INDEX_FILE}" + fetch_file "${FTP_SERVER}/${INDEX_FILE}" "${INDEX_PATH}" "1" + if [ -f "${INDEX_PATH}" ] && [ "${USE_BZIP2}" -eq "1" ] + then + bzip2 -d "${INDEX_PATH}" + fi }; get_package_index_by_fs() { - local INDEX_FILE + local INDEX_FILE - INDEX_FILE="${CDMNT}/packages/INDEX" - fetch_file "${INDEX_FILE}" "${CONFDIR}/" "0" + INDEX_FILE="${CDMNT}/packages/INDEX" + fetch_file "${INDEX_FILE}" "${CONFDIR}/" "0" }; get_package_index_size() { - if [ -f "${CONFDIR}/INDEX" ] - then - SIZE=`ls -l ${CONFDIR}/INDEX | awk '{ print $5 }'` - else - get_ftp_mirror - FTPHOST="${VAL}" + if [ -f "${CONFDIR}/INDEX" ] + then + SIZE=`ls -l ${CONFDIR}/INDEX | awk '{ print $5 }'` + else + get_ftp_mirror + FTPHOST="${VAL}" - FTPDIR="/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}" - FTPPATH="ftp://${FTPHOST}${FTPDIR}/packages" + FTPDIR="/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}" + FTPPATH="ftp://${FTPHOST}${FTPDIR}/packages" - fetch -s "${FTPPATH}/INDEX.bz2" - fi + fetch -s "${FTPPATH}/INDEX.bz2" + fi }; get_package_index() { - RES=0 + RES=0 - if [ -z "${INSTALLMODE}" ] - then - get_ftp_mirror - FTPHOST="${VAL}" + if [ -z "${INSTALLMODE}" ] + then + get_ftp_mirror + FTPHOST="${VAL}" - FTPDIR="/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}" - FTPPATH="ftp://${FTPHOST}${FTPDIR}/packages" + FTPDIR="/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}" + FTPPATH="ftp://${FTPHOST}${FTPDIR}/packages" - get_package_index_by_ftp "${FTPPATH}" + get_package_index_by_ftp "${FTPPATH}" - else - get_value_from_cfg ftpHost - if [ -z "$VAL" ] - then - exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!" - fi - FTPHOST="${VAL}" + else + get_value_from_cfg ftpHost + if [ -z "$VAL" ] + then + exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!" + fi - get_value_from_cfg ftpDir - if [ -z "$VAL" ] - then - exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!" - fi - FTPDIR="${VAL}" + FTPHOST="${VAL}" - FTPPATH="ftp://${FTPHOST}${FTPDIR}" + get_value_from_cfg ftpDir + if [ -z "$VAL" ] + then + exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!" + fi - case "${INSTALLMEDIUM}" in - usb|dvd) get_package_index_by_fs - ;; - ftp) get_package_index_by_ftp "${FTPPATH}" - ;; - *) RES=1 - ;; - esac + FTPDIR="${VAL}" + FTPPATH="ftp://${FTPHOST}${FTPDIR}" - fi + case "${INSTALLMEDIUM}" in + usb|dvd) get_package_index_by_fs ;; + ftp|sftp) get_package_index_by_ftp "${FTPPATH}" ;; + *) RES=1 ;; + esac - return ${RES} + fi + + return ${RES} }; parse_package_index() { - INDEX_FILE="${PKGDIR}/INDEX" + INDEX_FILE="${PKGDIR}/INDEX" - exec 3<&0 - exec 0<"${INDEX_FILE}" + exec 3<&0 + exec 0<"${INDEX_FILE}" - while read -r line - do - PKGNAME="" - CATEGORY="" - PACKAGE="" - DESC="" - DEPS="" - i=0 + while read -r line + do + PKGNAME="" + CATEGORY="" + PACKAGE="" + DESC="" + DEPS="" + i=0 - SAVE_IFS="${IFS}" - IFS="|" + SAVE_IFS="${IFS}" + IFS="|" - for part in ${line} - do - if [ "${i}" -eq "0" ] - then - PKGNAME="${part}" + for part in ${line} + do + if [ "${i}" -eq "0" ] + then + PKGNAME="${part}" - elif [ "${i}" -eq "1" ] - then - PACKAGE=`basename "${part}"` + elif [ "${i}" -eq "1" ] + then + PACKAGE=`basename "${part}"` - elif [ "${i}" -eq "3" ] - then - DESC="${part}" + elif [ "${i}" -eq "3" ] + then + DESC="${part}" - elif [ "${i}" -eq "6" ] - then - CATEGORY=`echo "${part}" | cut -f1 -d' '` + elif [ "${i}" -eq "6" ] + then + CATEGORY=`echo "${part}" | cut -f1 -d' '` - elif [ "${i}" -eq "8" ] - then - DEPS="${part}" - fi + elif [ "${i}" -eq "8" ] + then + DEPS="${part}" + fi - i=$((i+1)) - done + i=$((i+1)) + done - echo "${CATEGORY}|${PACKAGE}|${DESC}" >> "${INDEX_FILE}.parsed" - echo "${PACKAGE}|${PKGNAME}|${DEPS}" >> "${INDEX_FILE}.deps" + echo "${CATEGORY}|${PACKAGE}|${DESC}" >> "${INDEX_FILE}.parsed" + echo "${PACKAGE}|${PKGNAME}|${DEPS}" >> "${INDEX_FILE}.deps" - IFS="${SAVE_IFS}" - done + IFS="${SAVE_IFS}" + done - exec 0<&3 + exec 0<&3 }; show_package_file() { - PKGFILE="${1}" + PKGFILE="${1}" - echo "Available Packages:" + echo "Available Packages:" - exec 3<&0 - exec 0<"${PKGFILE}" + exec 3<&0 + exec 0<"${PKGFILE}" - while read -r line - do - CATEGORY=`echo "${line}" | cut -f1 -d'|'` - PACKAGE=`echo "${line}" | cut -f2 -d'|'` - DESC=`echo "${line}" | cut -f3 -d'|'` + while read -r line + do + CATEGORY=`echo "${line}" | cut -f1 -d'|'` + PACKAGE=`echo "${line}" | cut -f2 -d'|'` + DESC=`echo "${line}" | cut -f3 -d'|'` - echo "${CATEGORY}/${PACKAGE}:${DESC}" - done + echo "${CATEGORY}/${PACKAGE}:${DESC}" + done - exec 0<&3 + exec 0<&3 }; show_packages_by_category() { - CATEGORY="${1}" - INDEX_FILE="${PKGDIR}/INDEX.parsed" - TMPFILE="/tmp/.pkg.cat" + CATEGORY="${1}" + INDEX_FILE="${PKGDIR}/INDEX.parsed" + TMPFILE="/tmp/.pkg.cat" - grep "^${CATEGORY}|" "${INDEX_FILE}" > "${TMPFILE}" - show_package_file "${TMPFILE}" - rm "${TMPFILE}" + grep "^${CATEGORY}|" "${INDEX_FILE}" > "${TMPFILE}" + show_package_file "${TMPFILE}" + rm "${TMPFILE}" }; show_package_by_name() { - CATEGORY="${1}" - PACKAGE="${2}" - INDEX_FILE="${PKGDIR}/INDEX.parsed" - TMPFILE="/tmp/.pkg.cat.pak" + CATEGORY="${1}" + PACKAGE="${2}" + INDEX_FILE="${PKGDIR}/INDEX.parsed" + TMPFILE="/tmp/.pkg.cat.pak" - grep "^${CATEGORY}|${PACKAGE}" "${INDEX_FILE}" > "${TMPFILE}" - show_package_file "${TMPFILE}" - rm "${TMPFILE}" + grep "^${CATEGORY}|${PACKAGE}" "${INDEX_FILE}" > "${TMPFILE}" + show_package_file "${TMPFILE}" + rm "${TMPFILE}" }; show_packages() { - show_package_file "${PKGDIR}/INDEX.parsed" + show_package_file "${PKGDIR}/INDEX.parsed" }; get_package_dependencies() { - PACKAGE="${1}" - LONG="${2:-0}" - RES=0 + PACKAGE="${1}" + LONG="${2:-0}" + RES=0 - INDEX_FILE="${PKGDIR}/INDEX.deps" - REGEX="^${PACKAGE}|" + INDEX_FILE="${PKGDIR}/INDEX.deps" + REGEX="^${PACKAGE}|" - if [ "${LONG}" -ne "0" ] - then - REGEX="^.*|${PACKAGE}|" - fi + if [ "${LONG}" -ne "0" ] + then + REGEX="^.*|${PACKAGE}|" + fi - LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null` - DEPS=`echo "${LINE}"|cut -f3 -d'|'` + LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null` + DEPS=`echo "${LINE}"|cut -f3 -d'|'` - VAL="${DEPS}" - export VAL + VAL="${DEPS}" + export VAL - if [ -z "${VAL}" ] - then - RES=1 - fi + if [ -z "${VAL}" ] + then + RES=1 + fi - return ${RES} + return ${RES} }; get_package_name() { - PACKAGE="${1}" - RES=0 + PACKAGE="${1}" + RES=0 - INDEX_FILE="${PKGDIR}/INDEX.deps" - REGEX="^${PACKAGE}|" + INDEX_FILE="${PKGDIR}/INDEX.deps" + REGEX="^${PACKAGE}|" - LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null` - NAME=`echo "${LINE}"|cut -f2 -d'|'` + LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null` + NAME=`echo "${LINE}"|cut -f2 -d'|'` - VAL="${NAME}" - export VAL + VAL="${NAME}" + export VAL - if [ -z "${VAL}" ] - then - RES=1 - fi + if [ -z "${VAL}" ] + then + RES=1 + fi - return ${RES} + return ${RES} }; get_package_short_name() { - PACKAGE="${1}" - RES=0 + PACKAGE="${1}" + RES=0 - INDEX_FILE="${PKGDIR}/INDEX.deps" - REGEX="^.*|${PACKAGE}|" + INDEX_FILE="${PKGDIR}/INDEX.deps" + REGEX="^.*|${PACKAGE}|" - LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null` - NAME=`echo "${LINE}"|cut -f1 -d'|'` + LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null` + NAME=`echo "${LINE}"|cut -f1 -d'|'` - VAL="${NAME}" - export VAL + VAL="${NAME}" + export VAL - if [ -z "${VAL}" ] - then - RES=1 - fi + if [ -z "${VAL}" ] + then + RES=1 + fi - return ${RES} + return ${RES} }; get_package_category() { - PACKAGE="${1}" - INDEX_FILE="${PKGDIR}/INDEX.parsed" - RES=0 + PACKAGE="${1}" + INDEX_FILE="${PKGDIR}/INDEX.parsed" + RES=0 - LINE=`grep "|${PACKAGE}|" "${INDEX_FILE}" 2>/dev/null` - NAME=`echo "${LINE}"|cut -f1 -d'|'` + LINE=`grep "|${PACKAGE}|" "${INDEX_FILE}" 2>/dev/null` + NAME=`echo "${LINE}"|cut -f1 -d'|'` - VAL="${NAME}" - export VAL + VAL="${NAME}" + export VAL - if [ -z "${VAL}" ] - then - RES=1 - fi + if [ -z "${VAL}" ] + then + RES=1 + fi - return ${RES} + return ${RES} }; fetch_package_by_ftp() { - CATEGORY="${1}" - PACKAGE="${2}" - SAVEDIR="${3}" + CATEGORY="${1}" + PACKAGE="${2}" + SAVEDIR="${3}" - get_value_from_cfg ftpHost - if [ -z "$VAL" ] - then - exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!" - fi - FTPHOST="${VAL}" + get_value_from_cfg ftpHost + if [ -z "$VAL" ] + then + exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!" + fi + FTPHOST="${VAL}" - get_value_from_cfg ftpDir - if [ -z "$VAL" ] - then - exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!" - fi - FTPDIR="${VAL}" + get_value_from_cfg ftpDir + if [ -z "$VAL" ] + then + exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!" + fi + FTPDIR="${VAL}" - PACKAGE="${PACKAGE}.tbz" - FTP_SERVER="ftp://${FTPHOST}${FTPDIR}" + PACKAGE="${PACKAGE}.tbz" + FTP_SERVER="ftp://${FTPHOST}${FTPDIR}" - if [ ! -f "${SAVEDIR}/${PACKAGE}" ] - then - PKGPATH="${CATEGORY}/${PACKAGE}" - FTP_PATH="${FTP_HOST}/packages/${PKGPATH}" - fetch_file "${FTP_PATH}" "${SAVEDIR}/" "0" - fi + if [ ! -f "${SAVEDIR}/${PACKAGE}" ] + then + PKGPATH="${CATEGORY}/${PACKAGE}" + FTP_PATH="${FTP_HOST}/packages/${PKGPATH}" + fetch_file "${FTP_PATH}" "${SAVEDIR}/" "0" + fi }; fetch_package_by_fs() { - CATEGORY="${1}" - PACKAGE="${2}" - SAVEDIR="${3}" + CATEGORY="${1}" + PACKAGE="${2}" + SAVEDIR="${3}" - PACKAGE="${PACKAGE}.tbz" - if [ ! -f "${SAVEDIR}/${PACKAGE}" ] - then - fetch_file "${CDMNT}/packages/${CATEGORY}/${PACKAGE}" "${SAVEDIR}/" "0" - fi + PACKAGE="${PACKAGE}.tbz" + if [ ! -f "${SAVEDIR}/${PACKAGE}" ] + then + fetch_file "${CDMNT}/packages/${CATEGORY}/${PACKAGE}" "${SAVEDIR}/" "0" + fi }; fetch_package() { - CATEGORY="${1}" - PACKAGE="${2}" - SAVEDIR="${3}" + CATEGORY="${1}" + PACKAGE="${2}" + SAVEDIR="${3}" - case "${INSTALLMEDIUM}" in - usb|dvd) - fetch_package_by_fs "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" - ;; - ftp) - fetch_package_by_ftp "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" - ;; - esac + case "${INSTALLMEDIUM}" in + usb|dvd) fetch_package_by_fs "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;; + ftp|sftp) fetch_package_by_ftp "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;; + esac }; Index: head/usr.sbin/pc-sysinstall/backend/functions-parse.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-parse.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-parse.sh (revision 211730) @@ -1,231 +1,231 @@ #!/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.sh # Library of functions which pc-sysinstall may call upon for parsing the config # which gets the value of a setting in the provided line get_value_from_string() { if [ ! -z "${1}" ] then VAL="`echo ${1} | cut -d '=' -f 2`" export VAL else echo "Error: Did we forgot to supply a string to parse?" exit 1 fi }; # Get the value from the cfg file including spaces get_value_from_cfg_with_spaces() { if [ ! -z "${1}" ] then VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2` export VAL else exit_err "Error: Did we forgot to supply a setting to grab?" fi }; # Get the value from the cfg file get_value_from_cfg() { if [ ! -z "${1}" ] then VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '` export VAL else exit_err "Error: Did we forgot to supply a setting to grab?" fi }; # Checks the value of a setting in the provided line with supplied possibilities # 1 = setting we are checking, 2 = list of valid values if_check_value_exists() { if [ ! -z "${1}" -a ! -z "${2}" ] then # Get the first occurance of the setting from the config, strip out whitespace VAL=`grep "^${1}" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '` if [ -z "${VAL}" ] then # This value doesn't exist, lets return return 0 fi VALID="1" for i in ${2} do if [ "$VAL" = "${i}" ] then VALID="0" fi done if [ "$VALID" = "1" ] then exit_err "Error: ${1} is set to unknown value $VAL" fi else exit_err "Error: Did we forgot to supply a string to parse and setting to grab?" fi }; # Checks the value of a setting in the provided line with supplied possibilities # 1 = setting we are checking, 2 = list of valid values check_value() { if [ ! -z "${1}" -a ! -z "${2}" ] then # Get the first occurance of the setting from the config, strip out whitespace VAL=`grep "^${1}" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '` VALID="1" for i in ${2} do if [ "$VAL" = "${i}" ] then VALID="0" fi done if [ "$VALID" = "1" ] then exit_err "Error: ${1} is set to unknown value $VAL" fi else exit_err "Error: Did we forgot to supply a string to parse and setting to grab?" fi }; # Checks for the presense of the supplied arguements in the config file # 1 = values to confirm exist file_sanity_check() { if [ ! -z "$CFGF" -a ! -z "$1" ] then for i in $1 do - grep "^${i}=" $CFGF >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - LN=`grep "^${i}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '` - if [ -z "${LN}" ] - then - echo "Error: Config fails sanity test! ${i}= is empty" - exit 1 - fi - else - echo "Error: Config fails sanity test! Missing ${i}=" - exit 1 - fi + grep "^${i}=" $CFGF >/dev/null 2>/dev/null + if [ "$?" = "0" ] + then + LN=`grep "^${i}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '` + if [ -z "${LN}" ] + then + echo "Error: Config fails sanity test! ${i}= is empty" + exit 1 + fi + else + echo "Error: Config fails sanity test! Missing ${i}=" + exit 1 + fi done else echo "Error: Missing config file, and / or values to sanity check for!" exit 1 fi }; # Function which merges the contents of a new config into the specified old one # Only works with = type configurations merge_config() { OLDCFG="${1}" NEWCFG="${2}" FINALCFG="${3}" # Copy our oldcfg to the new one, which will be used as basis cp ${OLDCFG} ${FINALCFG} # Remove blank lines from new file cat ${NEWCFG} | sed '/^$/d' > ${FINALCFG}.tmp # Set our marker if we've found any FOUNDMERGE="NO" while read newline do echo ${newline} | grep "^#" >/dev/null 2>/dev/null if [ "$?" != "0" ] ; then VAL="`echo ${newline} | cut -d '=' -f 1`" cat ${OLDCFG} | grep ${VAL} >/dev/null 2>/dev/null if [ "$?" != "0" ] ; then if [ "${FOUNDMERGE}" = "NO" ] ; then echo "" >> ${FINALCFG} echo "# Auto-merged values from newer ${NEWCFG}" >> ${FINALCFG} FOUNDMERGE="YES" fi echo "${newline}" >> ${FINALCFG} fi fi done < ${FINALCFG}.tmp rm ${FINALCFG}.tmp }; # Loop to check for a specified mount-point in a list check_for_mount() { MNTS="${1}" FINDMNT="${2}" # Check if we found a valid root partition for CHECKMNT in `echo ${MNTS} | sed 's|,| |g'` do if [ "${CHECKMNT}" = "${FINDMNT}" ] ; then return 0 fi done return 1 }; # Function which returns the next line in the specified config file get_next_cfg_line() { CURFILE="$1" CURLINE="$2" FOUND="1" while read line do if [ "$FOUND" = "0" ] ; then VAL="$line" ; export VAL return fi if [ "$line" = "${CURLINE}" ] ; then FOUND="0" fi done <${CURFILE} # Got here, couldn't find this line or at end of file, set VAL to "" VAL="" ; export VAL }; Index: head/usr.sbin/pc-sysinstall/backend/functions-unmount.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-unmount.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-unmount.sh (revision 211730) @@ -1,206 +1,207 @@ #!/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 which unmount all mounted disk filesystems # Unmount all mounted partitions under specified dir -umount_all_dir() { - _udir="$1" - _umntdirs=`mount | sort -r | grep "on $_udir" | cut -d ' ' -f 3` - for _ud in $_umntdirs - do - umount -f ${_ud} - done +umount_all_dir() +{ + _udir="$1" + _umntdirs=`mount | sort -r | grep "on $_udir" | cut -d ' ' -f 3` + for _ud in $_umntdirs + do + umount -f ${_ud} + done } # Script that adds our gmirror devices for syncing start_gmirror_sync() { cd ${MIRRORCFGDIR} for DISK in `ls *` do MIRRORDISK="`cat ${DISK} | cut -d ':' -f 1`" MIRRORBAL="`cat ${DISK} | cut -d ':' -f 2`" MIRRORNAME="`cat ${DISK} | cut -d ':' -f 3`" # Start the mirroring service rc_halt "gmirror insert ${MIRRORNAME} /dev/${MIRRORDISK}" done }; # Unmounts all our mounted file-systems unmount_all_filesystems() { - # Copy the logfile to disk before we unmount - cp ${LOGOUT} ${FSMNT}/root/pc-sysinstall.log - cd / + # Copy the logfile to disk before we unmount + cp ${LOGOUT} ${FSMNT}/root/pc-sysinstall.log + cd / - # Start by unmounting any ZFS partitions - zfs_cleanup_unmount + # Start by unmounting any ZFS partitions + zfs_cleanup_unmount - # Lets read our partition list, and unmount each - ################################################################## - for PART in `ls ${PARTDIR}` - do - - PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`" - PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`" - PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`" - PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`" + # Lets read our partition list, and unmount each + ################################################################## + for PART in `ls ${PARTDIR}` + do + + PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`" + PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`" + PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`" + PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`" - if [ "${PARTENC}" = "ON" ] - then - EXT=".eli" - else - EXT="" - fi + if [ "${PARTENC}" = "ON" ] + then + EXT=".eli" + else + EXT="" + fi - #if [ "${PARTFS}" = "SWAP" ] - #then - # rc_nohalt "swapoff /dev/${PART}${EXT}" - #fi + #if [ "${PARTFS}" = "SWAP" ] + #then + # rc_nohalt "swapoff /dev/${PART}${EXT}" + #fi - # Check if we've found "/", and unmount that last - if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ] - then - rc_halt "umount -f /dev/${PART}${EXT}" + # Check if we've found "/", and unmount that last + if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ] + then + rc_halt "umount -f /dev/${PART}${EXT}" - # Re-check if we are missing a label for this device and create it again if so - if [ ! -e "/dev/label/${PARTLABEL}" ] - then - case ${PARTFS} in - UFS) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;; - UFS+S) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;; - UFS+J) glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal ;; - *) ;; - esac - fi - fi + # Re-check if we are missing a label for this device and create it again if so + if [ ! -e "/dev/label/${PARTLABEL}" ] + then + case ${PARTFS} in + UFS) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;; + UFS+S) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;; + UFS+J) glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal ;; + *) ;; + esac + fi + fi - # Check if we've found "/" and make sure the label exists - if [ "$PARTMNT" = "/" -a "${PARTFS}" != "ZFS" ] - then - if [ ! -e "/dev/label/${PARTLABEL}" ] - then - case ${PARTFS} in - UFS) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;; - UFS+S) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;; - UFS+J) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal" ;; - *) ;; - esac - fi - fi - done + # Check if we've found "/" and make sure the label exists + if [ "$PARTMNT" = "/" -a "${PARTFS}" != "ZFS" ] + then + if [ ! -e "/dev/label/${PARTLABEL}" ] + then + case ${PARTFS} in + UFS) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;; + UFS+S) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;; + UFS+J) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal" ;; + *) ;; + esac + fi + fi + done - # Last lets the /mnt partition - ######################################################### - rc_nohalt "umount -f ${FSMNT}" + # Last lets the /mnt partition + ######################################################### + rc_nohalt "umount -f ${FSMNT}" - # If are using a ZFS on "/" set it to legacy - if [ ! -z "${FOUNDZFSROOT}" ] - then - rc_halt "zfs set mountpoint=legacy ${FOUNDZFSROOT}" - fi + # If are using a ZFS on "/" set it to legacy + if [ ! -z "${FOUNDZFSROOT}" ] + then + rc_halt "zfs set mountpoint=legacy ${FOUNDZFSROOT}" + fi - # If we need to relabel "/" do it now - if [ ! -z "${ROOTRELABEL}" ] - then - ${ROOTRELABEL} - fi + # If we need to relabel "/" do it now + if [ ! -z "${ROOTRELABEL}" ] + then + ${ROOTRELABEL} + fi - # Unmount our CDMNT - rc_nohalt "umount -f ${CDMNT}" >/dev/null 2>/dev/null + # Unmount our CDMNT + rc_nohalt "umount -f ${CDMNT}" >/dev/null 2>/dev/null - # Check if we need to run any gmirror syncing - ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - # Lets start syncing now - start_gmirror_sync - fi + # Check if we need to run any gmirror syncing + ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null + if [ "$?" = "0" ] + then + # Lets start syncing now + start_gmirror_sync + fi }; # Unmounts any filesystems after a failure unmount_all_filesystems_failure() { cd / # if we did a fresh install, start unmounting if [ "${INSTALLMODE}" = "fresh" ] then # Lets read our partition list, and unmount each ################################################################## if [ -d "${PARTDIR}" ] then for PART in `ls ${PARTDIR}` do - PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`" - PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`" - PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`" + PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`" + PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`" + PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`" - #if [ "${PARTFS}" = "SWAP" ] - #then - # if [ "${PARTENC}" = "ON" ] - # then - # rc_nohalt "swapoff /dev/${PART}.eli" - # else - # rc_nohalt "swapoff /dev/${PART}" - # fi - #fi + #if [ "${PARTFS}" = "SWAP" ] + #then + # if [ "${PARTENC}" = "ON" ] + # then + # rc_nohalt "swapoff /dev/${PART}.eli" + # else + # rc_nohalt "swapoff /dev/${PART}" + # fi + #fi - # Check if we've found "/" again, don't need to mount it twice - if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ] - then - rc_nohalt "umount -f /dev/${PART}" - rc_nohalt "umount -f ${FSMNT}${PARTMNT}" - fi - done + # Check if we've found "/" again, don't need to mount it twice + if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ] + then + rc_nohalt "umount -f /dev/${PART}" + rc_nohalt "umount -f ${FSMNT}${PARTMNT}" + fi + done - # Last lets the /mnt partition - ######################################################### - rc_nohalt "umount -f ${FSMNT}" + # Last lets the /mnt partition + ######################################################### + rc_nohalt "umount -f ${FSMNT}" - fi - else - # We are doing a upgrade, try unmounting any of these filesystems - chroot ${FSMNT} /sbin/umount -a >>${LOGOUT} >>${LOGOUT} - umount -f ${FSMNT}/usr >>${LOGOUT} 2>>${LOGOUT} - umount -f ${FSMNT}/dev >>${LOGOUT} 2>>${LOGOUT} - umount -f ${FSMNT} >>${LOGOUT} 2>>${LOGOUT} - rc_nohalt "sh ${TMPDIR}/.upgrade-unmount" fi + else + # We are doing a upgrade, try unmounting any of these filesystems + chroot ${FSMNT} /sbin/umount -a >>${LOGOUT} >>${LOGOUT} + umount -f ${FSMNT}/usr >>${LOGOUT} 2>>${LOGOUT} + umount -f ${FSMNT}/dev >>${LOGOUT} 2>>${LOGOUT} + umount -f ${FSMNT} >>${LOGOUT} 2>>${LOGOUT} + rc_nohalt "sh ${TMPDIR}/.upgrade-unmount" + fi - # Unmount our CDMNT - rc_nohalt "umount ${CDMNT}" + # Unmount our CDMNT + rc_nohalt "umount ${CDMNT}" }; Index: head/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh (revision 211730) @@ -1,247 +1,247 @@ #!/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 which perform the mounting / unmount for upgrades . ${PROGDIR}/backend/functions-unmount.sh mount_target_slice() { MPART="${1}" # Import any zpools zpool import -o altroot=${FSMNT} -a umount_all_dir "${FSMNT}" # Set a variable of files we want to make backups of before doing upgrade BKFILES="/etc/rc.conf /boot/loader.conf" if [ -e "/dev/${MPART}" ] ; then rc_nohalt "mount /dev/${MPART} ${FSMNT}" if [ "$?" != "0" ] ; then - # Check if we have ZFS tank name - rc_halt "mount -t zfs ${MPART} ${FSMNT}" + # Check if we have ZFS tank name + rc_halt "mount -t zfs ${MPART} ${FSMNT}" fi else # Check if we have ZFS tank name rc_halt "mount -t zfs ${MPART} ${FSMNT}" fi # Mount devfs in chroot mount -t devfs devfs ${FSMNT}/dev # Check if we have any ZFS partitions to mount zfs mount -a # Mount all the fstab goodies on disk chroot ${FSMNT} /sbin/mount -a >>${LOGOUT} 2>>${LOGOUT} chroot ${FSMNT} umount /proc >/dev/null 2>/dev/null chroot ${FSMNT} umount /compat/linux/proc >/dev/null 2>/dev/null # Now before we start the upgrade, make sure we set our noschg flags echo_log "Cleaning up old filesystem... Please wait..." rc_halt "chflags -R noschg ${FSMNT}" # Make backup copies of some files for i in ${BKFILES} do cp ${FSMNT}${i} ${FSMNT}${i}.preUpgrade >/dev/null 2>/dev/null done # Remove some old dirs rm -rf ${FSMNT}/etc/rc.d >/dev/null 2>/dev/null # If we are doing PC-BSD install, lets cleanup old pkgs on disk if [ "$INSTALLTYPE" != "FreeBSD" ] then echo_log "Removing old packages, this may take a while... Please wait..." echo '#/bin/sh for i in `pkg_info -E \*` do echo "Uninstalling package: ${i}" pkg_delete -f ${i} >/dev/null 2>/dev/null done ' >${FSMNT}/.cleanPkgs.sh chmod 755 ${FSMNT}/.cleanPkgs.sh chroot ${FSMNT} /.cleanPkgs.sh rm ${FSMNT}/.cleanPkgs.sh run_chroot_cmd "pkg_delete -f \*" >/dev/null 2>/dev/null run_chroot_cmd "rm -rf /usr/PCBSD" >/dev/null 2>/dev/null run_chroot_cmd "rm -rf /PCBSD" >/dev/null 2>/dev/null run_chroot_cmd "rm -rf /var/db/pkgs" >/dev/null 2>/dev/null run_chroot_cmd "rm -rf /usr/local32" >/dev/null 2>/dev/null run_chroot_cmd "rm -rf /usr/sbin" >/dev/null 2>/dev/null run_chroot_cmd "rm -rf /usr/lib" >/dev/null 2>/dev/null run_chroot_cmd "rm -rf /usr/bin" >/dev/null 2>/dev/null run_chroot_cmd "rm -rf /boot/kernel" >/dev/null 2>/dev/null run_chroot_cmd "rm -rf /sbin" >/dev/null 2>/dev/null run_chroot_cmd "rm -rf /bin" >/dev/null 2>/dev/null run_chroot_cmd "rm -rf /lib" >/dev/null 2>/dev/null run_chroot_cmd "rm -rf /libexec" >/dev/null 2>/dev/null fi -} +}; # Mount the target upgrade partitions mount_upgrade() { # Make sure we remove the old upgrade-mount script rm -rf ${TMPDIR}/.upgrade-unmount >/dev/null 2>/dev/null # We are ready to start mounting, lets read the config and do it while read line do - echo $line | grep "^disk0=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then + echo $line | grep "^disk0=" >/dev/null 2>/dev/null + if [ "$?" = "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" - fi + # Found a disk= entry, lets get the disk we are working on + get_value_from_string "${line}" + strip_white_space "$VAL" + DISK="$VAL" + fi - echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - # Found our flag to commit this disk setup / lets do sanity check and do it - if [ ! -z "${DISK}" ] - then + echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null + if [ "$?" = "0" ] + then + # Found our flag to commit this disk setup / lets do sanity check and do it + if [ ! -z "${DISK}" ] + then - # Start mounting this slice - mount_target_slice "${DISK}" + # Start mounting this slice + mount_target_slice "${DISK}" - # Increment our disk counter to look for next disk and unset - unset DISK - break - else - exit_err "ERROR: commitDiskPart was called without procceding disk= and partition= entries!!!" - fi - fi + # Increment our disk counter to look for next disk and unset + unset DISK + break + else + exit_err "ERROR: commitDiskPart was called without procceding disk= and partition= entries!!!" + fi + fi done <${CFGF} }; copy_skel_files_upgrade() { - # Now make sure we fix any user profile scripts, which cause problems from 7.x->8.x - echo '#!/bin/sh + # Now make sure we fix any user profile scripts, which cause problems from 7.x->8.x + echo '#!/bin/sh cd /home for i in `ls` do # Backup the old profile dirs if [ -d "${i}" ] then mv /home/${i}/.kde4 /home/${i}/.kde4.preUpgrade >/dev/null 2>/dev/null mv /home/${i}/.kde /home/${i}/.kde.preUpgrade >/dev/null 2>/dev/null mv /home/${i}/.fluxbox /home/${i}/.fluxbox.preUpgrade >/dev/null 2>/dev/null # Copy over the skel directories tar cv --exclude "./dot.*" -f - -C /usr/share/skel . 2>/dev/null | tar xvf - -C /home/${i} 2>/dev/null for j in `ls /usr/share/skel/dot*` do dname=`echo ${j} | sed s/dot//` cp /usr/share/skel/${j} /home/${i}/${dname} done chown -R ${i}:${i} /home/${i} fi done ' >${FSMNT}/.fixUserProfile.sh - chmod 755 ${FSMNT}/.fixUserProfile.sh - chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null - rm ${FSMNT}/.fixUserProfile.sh + chmod 755 ${FSMNT}/.fixUserProfile.sh + chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null + rm ${FSMNT}/.fixUserProfile.sh - # if the user wants to keep their original .kde4 profile - ########################################################################### - get_value_from_cfg "upgradeKeepDesktopProfile" - if [ "$VAL" = "YES" -o "$VAL" = "yes" ] ; then - echo '#!/bin/sh + # if the user wants to keep their original .kde4 profile + ########################################################################### + get_value_from_cfg "upgradeKeepDesktopProfile" + if [ "$VAL" = "YES" -o "$VAL" = "yes" ] ; then + echo '#!/bin/sh cd /home for i in `ls` do # Import the old config again if [ -d "${i}/.kde4.preUpgrade" ] then # Copy over the skel directories tar cv -f - -C /home/${i}/.kde4.preUpgrade . 2>/dev/null | tar xvf - -C /home/${i}/.kde4 2>/dev/null chown -R ${i}:${i} /home/${i}/.kde4 fi done ' >${FSMNT}/.fixUserProfile.sh - chmod 755 ${FSMNT}/.fixUserProfile.sh - chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null - rm ${FSMNT}/.fixUserProfile.sh + chmod 755 ${FSMNT}/.fixUserProfile.sh + chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null + rm ${FSMNT}/.fixUserProfile.sh - fi + fi }; # Function which merges some configuration files with the new defaults merge_old_configs() { # Merge the loader.conf with old cp ${FSMNT}/boot/loader.conf ${FSMNT}/boot/loader.conf.new merge_config "${FSMNT}/boot/loader.conf.preUpgrade" "${FSMNT}/boot/loader.conf.new" "${FSMNT}/boot/loader.conf" rm ${FSMNT}/boot/loader.conf.new # Merge the rc.conf with old cp ${FSMNT}/etc/rc.conf ${FSMNT}/etc/rc.conf.new merge_config "${FSMNT}/etc/rc.conf.preUpgrade" "${FSMNT}/etc/rc.conf.new" "${FSMNT}/etc/rc.conf" rm ${FSMNT}/etc/rc.conf.new }; # Function which unmounts all the mounted file-systems unmount_upgrade() { - # If on PC-BSD, make sure we copy any fixed skel files - if [ "$INSTALLTYPE" != "FreeBSD" ] ; then - copy_skel_files_upgrade - fi + # If on PC-BSD, make sure we copy any fixed skel files + if [ "$INSTALLTYPE" != "FreeBSD" ] ; then + copy_skel_files_upgrade + fi - cd / + cd / - # Unmount FS - umount_all_dir "${FSMNT}" + # Unmount FS + umount_all_dir "${FSMNT}" - # Run our saved unmount script for these file-systems - rc_nohalt "umount -f ${FSMNT}" + # Run our saved unmount script for these file-systems + rc_nohalt "umount -f ${FSMNT}" - umount ${CDMNT} + umount ${CDMNT} }; Index: head/usr.sbin/pc-sysinstall/backend/functions-users.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions-users.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions-users.sh (revision 211730) @@ -1,175 +1,175 @@ #!/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 which runs commands on the system . ${BACKEND}/functions.sh . ${BACKEND}/functions-parse.sh # Function which checks and sets up auto-login for a user if specified check_autologin() { get_value_from_cfg autoLoginUser if [ ! -z "${VAL}" -a "${INSTALLTYPE}" = "PCBSD" ] then AUTOU="${VAL}" # Add the auto-login user line sed -i.bak "s/AutoLoginUser=/AutoLoginUser=${AUTOU}/g" ${FSMNT}/usr/local/kde4/share/config/kdm/kdmrc # Add the auto-login user line sed -i.bak "s/AutoLoginEnable=false/AutoLoginEnable=true/g" ${FSMNT}/usr/local/kde4/share/config/kdm/kdmrc fi }; # Function which actually runs the adduser command on the filesystem add_user() { ARGS="${1}" if [ -e "${FSMNT}/.tmpPass" ] then # Add a user with a supplied password run_chroot_cmd "cat /.tmpPass | pw useradd ${ARGS}" rc_halt "rm ${FSMNT}/.tmpPass" else # Add a user with no password run_chroot_cmd "cat /.tmpPass | pw useradd ${ARGS}" fi }; # Function which reads in the config, and adds any users specified setup_users() { # We are ready to start setting up the users, lets read the config while read line do - echo $line | grep "^userName=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - get_value_from_string "${line}" - USERNAME="$VAL" - fi + echo $line | grep "^userName=" >/dev/null 2>/dev/null + if [ "$?" = "0" ] + then + get_value_from_string "${line}" + USERNAME="$VAL" + fi - echo $line | grep "^userComment=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - get_value_from_string "${line}" - USERCOMMENT="$VAL" - fi + echo $line | grep "^userComment=" >/dev/null 2>/dev/null + if [ "$?" = "0" ] + then + get_value_from_string "${line}" + USERCOMMENT="$VAL" + fi - echo $line | grep "^userPass=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - get_value_from_string "${line}" - USERPASS="$VAL" - fi + echo $line | grep "^userPass=" >/dev/null 2>/dev/null + if [ "$?" = "0" ] + then + get_value_from_string "${line}" + USERPASS="$VAL" + fi - echo $line | grep "^userShell=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - get_value_from_string "${line}" - strip_white_space "$VAL" - USERSHELL="$VAL" - fi + echo $line | grep "^userShell=" >/dev/null 2>/dev/null + if [ "$?" = "0" ] + then + get_value_from_string "${line}" + strip_white_space "$VAL" + USERSHELL="$VAL" + fi - echo $line | grep "^userHome=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - get_value_from_string "${line}" - USERHOME="$VAL" - fi + echo $line | grep "^userHome=" >/dev/null 2>/dev/null + if [ "$?" = "0" ] + then + get_value_from_string "${line}" + USERHOME="$VAL" + fi - echo $line | grep "^userGroups=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - get_value_from_string "${line}" - USERGROUPS="$VAL" - fi + echo $line | grep "^userGroups=" >/dev/null 2>/dev/null + if [ "$?" = "0" ] + then + get_value_from_string "${line}" + USERGROUPS="$VAL" + fi - echo $line | grep "^commitUser" >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then - # Found our flag to commit this user, lets check and do it - if [ ! -z "${USERNAME}" ] - then + echo $line | grep "^commitUser" >/dev/null 2>/dev/null + if [ "$?" = "0" ] + then + # Found our flag to commit this user, lets check and do it + if [ ! -z "${USERNAME}" ] + then - # Now add this user to the system, by building our args list - ARGS="-n ${USERNAME}" + # Now add this user to the system, by building our args list + ARGS="-n ${USERNAME}" - if [ ! -z "${USERCOMMENT}" ] - then - ARGS="${ARGS} -c \"${USERCOMMENT}\"" - fi + if [ ! -z "${USERCOMMENT}" ] + then + ARGS="${ARGS} -c \"${USERCOMMENT}\"" + fi - if [ ! -z "${USERPASS}" ] - then - ARGS="${ARGS} -h 0" - echo "${USERPASS}" >${FSMNT}/.tmpPass - else - ARGS="${ARGS} -h -" - rm ${FSMNT}/.tmpPass 2>/dev/null 2>/dev/null - fi + if [ ! -z "${USERPASS}" ] + then + ARGS="${ARGS} -h 0" + echo "${USERPASS}" >${FSMNT}/.tmpPass + else + ARGS="${ARGS} -h -" + rm ${FSMNT}/.tmpPass 2>/dev/null 2>/dev/null + fi - if [ ! -z "${USERSHELL}" ] - then - ARGS="${ARGS} -s \"${USERSHELL}\"" - else - ARGS="${ARGS} -s \"/nonexistant\"" - fi + if [ ! -z "${USERSHELL}" ] + then + ARGS="${ARGS} -s \"${USERSHELL}\"" + else + ARGS="${ARGS} -s \"/nonexistant\"" + fi - if [ ! -z "${USERHOME}" ] - then - ARGS="${ARGS} -m -d \"${USERHOME}\"" - fi + if [ ! -z "${USERHOME}" ] + then + ARGS="${ARGS} -m -d \"${USERHOME}\"" + fi - if [ ! -z "${USERGROUPS}" ] - then - ARGS="${ARGS} -G \"${USERGROUPS}\"" - fi + if [ ! -z "${USERGROUPS}" ] + then + ARGS="${ARGS} -G \"${USERGROUPS}\"" + fi - add_user "${ARGS}" + add_user "${ARGS}" - # Unset our vars before looking for any more users - unset USERNAME USERCOMMENT USERPASS USERSHELL USERHOME USERGROUPS - else - exit_err "ERROR: commitUser was called without any userName= entry!!!" - fi - fi + # Unset our vars before looking for any more users + unset USERNAME USERCOMMENT USERPASS USERSHELL USERHOME USERGROUPS + else + exit_err "ERROR: commitUser was called without any userName= entry!!!" + fi + fi done <${CFGF} # Check if we need to enable a user to auto-login to the desktop check_autologin }; Index: head/usr.sbin/pc-sysinstall/backend/functions.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/functions.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/functions.sh (revision 211730) @@ -1,284 +1,285 @@ #!/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.sh # Library of functions which pc-sysinstall may call upon # Function which displays the help-index file display_help() { if [ -e "${PROGDIR}/doc/help-index" ] then cat ${PROGDIR}/doc/help-index else echo "Error: ${PROGDIR}/doc/help-index not found" exit 1 fi }; # Function which displays the help for a specified command display_command_help() { if [ -z "$1" ] then echo "Error: No command specified to display help for" exit 1 fi if [ -e "${PROGDIR}/doc/help-${1}" ] then cat ${PROGDIR}/doc/help-${1} else echo "Error: ${PROGDIR}/doc/help-${1} not found" exit 1 fi }; # Function to convert bytes to megabytes convert_byte_to_megabyte() { if [ -z "${1}" ] then echo "Error: No bytes specified!" exit 1 fi expr -e ${1} / 1048576 }; # Function to convert blocks to megabytes convert_blocks_to_megabyte() { if [ -z "${1}" ] ; then echo "Error: No blocks specified!" exit 1 fi expr -e ${1} / 2048 }; # Takes $1 and strips the whitespace out of it, returns VAL strip_white_space() { if [ -z "${1}" ] then echo "Error: No value setup to strip whitespace from!" exit 1 fi VAL=`echo "$1" | tr -d ' '` export VAL }; # Displays an error message and exits with error 1 exit_err() { - # Echo the message for the users benefit - echo "$1" + # Echo the message for the users benefit + echo "$1" - # Save this error to the log file - echo "${1}" >>$LOGOUT + # Save this error to the log file + echo "${1}" >>$LOGOUT - # Check if we need to unmount any file-systems after this failure - unmount_all_filesystems_failure + # Check if we need to unmount any file-systems after this failure + unmount_all_filesystems_failure - echo "For more details see log file: $LOGOUT" + echo "For more details see log file: $LOGOUT" - exit 1 + exit 1 }; # Run-command, don't halt if command exits with non-0 rc_nohalt() { CMD="$1" if [ -z "${CMD}" ] then exit_err "Error: missing argument in rc_nohalt()" fi echo "Running: ${CMD}" >>${LOGOUT} ${CMD} >>${LOGOUT} 2>>${LOGOUT} }; # Run-command, halt if command exits with non-0 rc_halt() { CMD="$1" if [ -z "${CMD}" ] then exit_err "Error: missing argument in rc_halt()" fi echo "Running: ${CMD}" >>${LOGOUT} ${CMD} >>${LOGOUT} 2>>${LOGOUT} STATUS="$?" if [ "${STATUS}" != "0" ] then exit_err "Error ${STATUS}: ${CMD}" fi }; # Run-command w/echo to screen, halt if command exits with non-0 rc_halt_echo() { CMD="$1" if [ -z "${CMD}" ] then exit_err "Error: missing argument in rc_halt_echo()" fi echo "Running: ${CMD}" >>${LOGOUT} ${CMD} 2>&1 | tee -a ${LOGOUT} STATUS="$?" if [ "$STATUS" != "0" ] then exit_err "Error ${STATUS}: $CMD" fi }; # Run-command w/echo, don't halt if command exits with non-0 rc_nohalt_echo() { CMD="$1" if [ -z "${CMD}" ] then exit_err "Error: missing argument in rc_nohalt_echo()" fi echo "Running: ${CMD}" >>${LOGOUT} ${CMD} 2>&1 | tee -a ${LOGOUT} }; # Echo to the screen and to the log echo_log() { STR="$1" if [ -z "${STR}" ] then exit_err "Error: missing argument in echo_log()" fi echo "${STR}" | tee -a ${LOGOUT} }; # Make sure we have a numeric -is_num() { - expr $1 + 1 2>/dev/null - return $? +is_num() +{ + expr $1 + 1 2>/dev/null + return $? } # Function which uses "fetch" to download a file, and display a progress report fetch_file() { -FETCHFILE="$1" -FETCHOUTFILE="$2" -EXITFAILED="$3" + FETCHFILE="$1" + FETCHOUTFILE="$2" + EXITFAILED="$3" -SIZEFILE="${TMPDIR}/.fetchSize" -EXITFILE="${TMPDIR}/.fetchExit" + SIZEFILE="${TMPDIR}/.fetchSize" + EXITFILE="${TMPDIR}/.fetchExit" -rm ${SIZEFILE} 2>/dev/null >/dev/null -rm ${FETCHOUTFILE} 2>/dev/null >/dev/null + rm ${SIZEFILE} 2>/dev/null >/dev/null + rm ${FETCHOUTFILE} 2>/dev/null >/dev/null -fetch -s "${FETCHFILE}" >${SIZEFILE} -SIZE="`cat ${SIZEFILE}`" -SIZE="`expr ${SIZE} / 1024`" -echo "FETCH: ${FETCHFILE}" -echo "FETCH: ${FETCHOUTFILE}" >>${LOGOUT} + fetch -s "${FETCHFILE}" >${SIZEFILE} + SIZE="`cat ${SIZEFILE}`" + SIZE="`expr ${SIZE} / 1024`" + echo "FETCH: ${FETCHFILE}" + echo "FETCH: ${FETCHOUTFILE}" >>${LOGOUT} -( fetch -o ${FETCHOUTFILE} "${FETCHFILE}" >/dev/null 2>/dev/null ; echo "$?" > ${EXITFILE} ) & -PID="$!" -while -z=1 -do + ( fetch -o ${FETCHOUTFILE} "${FETCHFILE}" >/dev/null 2>/dev/null ; echo "$?" > ${EXITFILE} ) & + PID="$!" + while + z=1 + do - if [ -e "${FETCHOUTFILE}" ] - then - DSIZE=`du -k ${FETCHOUTFILE} | tr -d '\t' | cut -d '/' -f 1` - if [ $(is_num "$DSIZE") ] ; then - if [ $SIZE -lt $DSIZE ] ; then DSIZE="$SIZE"; fi + if [ -e "${FETCHOUTFILE}" ] + then + DSIZE=`du -k ${FETCHOUTFILE} | tr -d '\t' | cut -d '/' -f 1` + if [ $(is_num "$DSIZE") ] ; then + if [ $SIZE -lt $DSIZE ] ; then DSIZE="$SIZE"; fi echo "SIZE: ${SIZE} DOWNLOADED: ${DSIZE}" echo "SIZE: ${SIZE} DOWNLOADED: ${DSIZE}" >>${LOGOUT} + fi fi - fi - # Check if the download is finished - ps -p ${PID} >/dev/null 2>/dev/null - if [ "$?" != "0" ] - then - break; - fi + # Check if the download is finished + ps -p ${PID} >/dev/null 2>/dev/null + if [ "$?" != "0" ] + then + break; + fi - sleep 2 -done + sleep 2 + done -echo "FETCHDONE" + echo "FETCHDONE" -EXIT="`cat ${EXITFILE}`" -if [ "${EXIT}" != "0" -a "$EXITFAILED" = "1" ] -then - exit_err "Error: Failed to download ${FETCHFILE}" -fi + EXIT="`cat ${EXITFILE}`" + if [ "${EXIT}" != "0" -a "$EXITFAILED" = "1" ] + then + exit_err "Error: Failed to download ${FETCHFILE}" + fi -return $EXIT + return $EXIT }; # Function to return a the zpool name for this device get_zpool_name() { DEVICE="$1" # Set the base name we use for zpools BASENAME="tank" if [ ! -d "${TMPDIR}/.zpools" ] ; then mkdir -p ${TMPDIR}/.zpools fi if [ -e "${TMPDIR}/.zpools/${DEVICE}" ] ; then cat ${TMPDIR}/.zpools/${DEVICE} return 0 else # Need to generate a zpool name for this device NUM=`ls ${TMPDIR}/.zpools/ | wc -l | sed 's| ||g'` NEWNAME="${BASENAME}${NUM}" echo "$NEWNAME" >${TMPDIR}/.zpools/${DEVICE} echo "${NEWNAME}" return fi }; Index: head/usr.sbin/pc-sysinstall/backend/parseconfig.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend/parseconfig.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend/parseconfig.sh (revision 211730) @@ -1,176 +1,176 @@ #!/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" # Check the dirname of the provided CFGF and make sure its a full path DIR="`dirname ${CFGF}`" if [ "${DIR}" = "." ] then CFGF="`pwd`/${CFGF}" fi export CFGF # Start by doing a sanity check, which will catch any obvious mistakes in the config file_sanity_check "installMode disk0 installType installMedium packageType" # We passed the Sanity check, lets grab some of the universal config settings and store them check_value installMode "fresh upgrade" check_value bootManager "bsd none" check_value installType "PCBSD FreeBSD" -check_value installMedium "dvd usb ftp rsync" +check_value installMedium "dvd usb ftp rsync img" check_value packageType "uzip tar rsync split" if_check_value_exists partition "all ALL s1 s2 s3 s4 free FREE" 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 INSTALLMODE="${VAL}" ; export INSTALLMODE get_value_from_cfg installType INSTALLTYPE="${VAL}" ; export INSTALLTYPE get_value_from_cfg installMedium INSTALLMEDIUM="${VAL}" ; export INSTALLMEDIUM get_value_from_cfg packageType PACKAGETYPE="${VAL}" ; export PACKAGETYPE # Check if we are doing any networking setup start_networking # If we are not doing an upgrade, lets go ahead and setup the disk if [ "${INSTALLMODE}" = "fresh" ] then # Lets start setting up the disk slices now setup_disk_slice # Disk setup complete, now lets parse WORKINGSLICES and setup the bsdlabels setup_disk_label # Now we've setup the bsdlabels, lets go ahead and run newfs / zfs # to setup the filesystems setup_filesystems # Lets mount the partitions now mount_all_filesystems # We are ready to begin extraction, lets start now init_extraction # Check if we have any optional modules to load install_components # Check if we have any packages to install install_packages # Do any localization in configuration run_localize # Save any networking config on the installed system save_networking_install # Now add any users setup_users # Now run any commands specified run_commands # Do any last cleanup / setup before unmounting run_final_cleanup # Unmount and finish up unmount_all_filesystems echo_log "Installation finished!" exit 0 else # We're going to do an upgrade, skip all the disk setup # and start by mounting the target drive/slices mount_upgrade # Start the extraction process init_extraction # Do any localization in configuration run_localize # Now run any commands specified run_commands # Merge any old configuration files merge_old_configs # Check if we have any optional modules to load install_components # Check if we have any packages to install install_packages # All finished, unmount the file-systems unmount_upgrade echo_log "Upgrade finished!" exit 0 fi Index: head/usr.sbin/pc-sysinstall/backend-query/disk-info.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend-query/disk-info.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend-query/disk-info.sh (revision 211730) @@ -1,71 +1,69 @@ #!/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$ # Query a disk for partitions and display them ############################# . ${PROGDIR}/backend/functions.sh . ${PROGDIR}/backend/functions-disk.sh if [ -z "${1}" ] then echo "Error: No disk specified!" exit 1 fi if [ ! -e "/dev/${1}" ] then echo "Error: Disk /dev/${1} does not exist!" exit 1 fi DISK="${1}" get_disk_cyl "${DISK}" CYLS="${VAL}" get_disk_heads "${DISK}" HEADS="${VAL}" get_disk_sectors "${DISK}" SECS="${VAL}" - # Now get the disks size in MB KB="`diskinfo -v ${1} | grep 'bytes' | cut -d '#' -f 1 | tr -s '\t' ' ' | tr -d ' '`" MB=$(convert_byte_to_megabyte ${KB}) # Now get the Controller Type CTYPE="`dmesg | grep "^${1}:" | grep "B <" | cut -d '>' -f 2 | cut -d ' ' -f 3-10`" - echo "cylinders=${CYLS}" echo "heads=${HEADS}" echo "sectors=${SECS}" -echo "size=$MB" -echo "type=$CTYPE" +echo "size=${MB}" +echo "type=${CTYPE}" Index: head/usr.sbin/pc-sysinstall/backend-query/disk-list.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend-query/disk-list.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend-query/disk-list.sh (revision 211730) @@ -1,74 +1,96 @@ #!/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$ ARGS=$1 +FLAGS_MD="" +FLAGS_VERBOSE="" +shift +while [ -n "$1" ] +do + case "$1" in + -m) + FLAGS_MD=1 + ;; + -v) + FLAGS_VERBOSE=1 + ;; + esac + shift +done + # Create our device listing SYSDISK=$(sysctl -n kern.disks) -if [ "${ARGS}" = "-m" ] +if [ -n "${FLAGS_MD}" ] then - MDS=`mdconfig -l` - if [ -n "${MDS}" ] - then - SYSDISK="${SYSDISK} ${MDS}" - fi + MDS=`mdconfig -l` + if [ -n "${MDS}" ] + then + SYSDISK="${SYSDISK} ${MDS}" + fi fi # Now loop through these devices, and list the disk drives for i in ${SYSDISK} do # Get the current device DEV="${i}" # Make sure we don't find any cd devices case "${DEV}" in - acd[0-9]*|cd[0-9]*|scd[0-9]*) continue ;; + acd[0-9]*|cd[0-9]*|scd[0-9]*) continue ;; esac # Check the dmesg output for some more info about this device NEWLINE=$(dmesg | sed -n "s/^$DEV: .*<\(.*\)>.*$/ <\1>/p" | head -n 1) if [ -z "$NEWLINE" ]; then NEWLINE=" " fi - if echo "${DEV}" | grep -E '^md[0-9]+' >/dev/null 2>/dev/null + + if [ -n "${FLAGS_MD}" ] && echo "${DEV}" | grep -E '^md[0-9]+' >/dev/null 2>/dev/null then NEWLINE=" " + fi + + if [ -n "${FLAGS_VERBOSE}" ] + then + : fi # Save the disk list if [ ! -z "$DLIST" ] then DLIST="\n${DLIST}" fi DLIST="${DEV}:${NEWLINE}${DLIST}" done # Echo out the found line echo -e "$DLIST" | sort Index: head/usr.sbin/pc-sysinstall/backend-query/disk-part.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend-query/disk-part.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend-query/disk-part.sh (revision 211730) @@ -1,119 +1,117 @@ #!/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$ # Query a disk for partitions and display them ############################# . ${PROGDIR}/backend/functions.sh . ${PROGDIR}/backend/functions-disk.sh if [ -z "${1}" ] then echo "Error: No disk specified!" exit 1 fi if [ ! -e "/dev/${1}" ] then echo "Error: Disk /dev/${1} does not exist!" exit 1 fi DISK="${1}" # Now get the disks size in MB KB="`diskinfo -v ${1} | grep 'bytes' | cut -d '#' -f 1 | tr -s '\t' ' ' | tr -d ' '`" MB=$(convert_byte_to_megabyte ${KB}) TOTALSIZE="$MB" TOTALB="`diskinfo -v ${1} | grep 'in sectors' | tr -s '\t' ' ' | cut -d ' ' -f 2`" - - gpart show ${1} >/dev/null 2>/dev/null if [ "$?" != "0" ] ; then # No partitions on this disk, display entire disk size and exit echo "${1}-freemb: ${TOTALSIZE}" echo "${1}-freeblocks: ${TOTALB}" exit fi # Display if this is GPT or MBR formatted gpart show ${1} | grep "GPT" >/dev/null 2>/dev/null if [ "$?" = "0" ] ; then echo "${1}-format: GPT" TYPE="GPT" else echo "${1}-format: MBR" TYPE="MBR" fi # Set some search flags PART="0" EXTENDED="0" START="0" SIZEB="0" # Get a listing of partitions on this disk get_disk_partitions "${DISK}" PARTS="${VAL}" for curpart in $PARTS do # First get the sysid / label for this partition if [ "$TYPE" = "MBR" ] ; then - get_partition_sysid_mbr "${DISK}" "${curpart}" - echo "${curpart}-sysid: ${VAL}" - get_partition_label_mbr "${DISK}" "${curpart}" - echo "${curpart}-label: ${VAL}" + get_partition_sysid_mbr "${DISK}" "${curpart}" + echo "${curpart}-sysid: ${VAL}" + get_partition_label_mbr "${DISK}" "${curpart}" + echo "${curpart}-label: ${VAL}" else - get_partition_label_gpt "${DISK}" "${curpart}" - echo "${curpart}-sysid: ${VAL}" - echo "${curpart}-label: ${VAL}" + get_partition_label_gpt "${DISK}" "${curpart}" + echo "${curpart}-sysid: ${VAL}" + echo "${curpart}-label: ${VAL}" fi # Now get the startblock, blocksize and MB size of this partition get_partition_startblock "${DISK}" "${curpart}" START="${VAL}" echo "${curpart}-blockstart: ${START}" get_partition_blocksize "${DISK}" "${curpart}" SIZEB="${VAL}" echo "${curpart}-blocksize: ${SIZEB}" SIZEMB=$(convert_blocks_to_megabyte ${SIZEB}) echo "${curpart}-sizemb: ${SIZEMB}" done # Now calculate any free space LASTB="`expr $SIZEB + $START`" FREEB="`expr $TOTALB - $LASTB`" FREEMB="`expr ${FREEB} / 2048`" echo "${1}-freemb: $FREEMB" echo "${1}-freeblocks: $FREEB" Index: head/usr.sbin/pc-sysinstall/backend-query/enable-net.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend-query/enable-net.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend-query/enable-net.sh (revision 211730) @@ -1,65 +1,65 @@ #!/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$ # Script which enables networking with specified options ########################################################################### . ${PROGDIR}/backend/functions.sh . ${PROGDIR}/conf/pc-sysinstall.conf . ${BACKEND}/functions-networking.sh . ${BACKEND}/functions-parse.sh NIC="$1" IP="$2" NETMASK="$3" DNS="$4" GATEWAY="$5" MIRRORFETCH="$6" if [ -z "${NIC}" ] then echo "ERROR: Usage enable-net " exit 150 fi if [ "$NIC" = "AUTO-DHCP" ] then enable_auto_dhcp else echo "Enabling NIC: $NIC" ifconfig ${NIC} ${IP} ${NETMASK} echo "nameserver ${DNS}" >/etc/resolv.conf route add default ${GATE} fi case ${MIRRORFETCH} in - ON|on|yes|YES) fetch -o /tmp/mirrors-list.txt ${MIRRORLIST} >/dev/null 2>/dev/null;; - *) ;; + ON|on|yes|YES) fetch -o /tmp/mirrors-list.txt ${MIRRORLIST} >/dev/null 2>/dev/null;; + *) ;; esac Index: head/usr.sbin/pc-sysinstall/backend-query/get-packages.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend-query/get-packages.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend-query/get-packages.sh (revision 211730) @@ -1,52 +1,52 @@ #!/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$ # Script which lists the available packages for this release ########################################################################### . ${PROGDIR}/backend/functions.sh . ${PROGDIR}/backend/functions-packages.sh ID=`id -u` if [ "${ID}" -ne "0" ] then - echo "Error: must be root!" - exit 1 + echo "Error: must be root!" + exit 1 fi if [ ! -f "${PKGDIR}/INDEX" ] then - get_package_index + get_package_index fi if [ -f "${PKGDIR}/INDEX" ] then - echo "${PKGDIR}/INDEX" - exit 0 + echo "${PKGDIR}/INDEX" + exit 0 fi exit 1 Index: head/usr.sbin/pc-sysinstall/backend-query/list-packages.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend-query/list-packages.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend-query/list-packages.sh (revision 211730) @@ -1,86 +1,86 @@ #!/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$ # Script which lists the available packages for this release ########################################################################### . ${PROGDIR}/backend/functions.sh . ${PROGDIR}/backend/functions-packages.sh PACKAGE_CATEGORY="${1}" PACKAGE_NAME="${2}" NARGS=0 if [ ! -f "${PKGDIR}/INDEX" ] then - echo "Error: please fetch package index with get-packages!" - exit 1 + echo "Error: please fetch package index with get-packages!" + exit 1 fi if [ ! -f "${PKGDIR}/INDEX.parsed" ] then - parse_package_index + parse_package_index fi if [ -n "${PACKAGE_CATEGORY}" ] then - NARGS=$((NARGS+1)) + NARGS=$((NARGS+1)) fi if [ -n "${PACKAGE_NAME}" ] then - NARGS=$((NARGS+1)) + NARGS=$((NARGS+1)) fi if [ "${NARGS}" -eq "0" ] then - show_packages + show_packages elif [ "${NARGS}" -eq "1" ] then - if [ "${PACKAGE_CATEGORY}" = "@INDEX@" ] - then - if [ -f "${PKGDIR}/INDEX" ] - then - echo "${PKGDIR}/INDEX" - exit 0 - else - exit 1 - fi + if [ "${PACKAGE_CATEGORY}" = "@INDEX@" ] + then + if [ -f "${PKGDIR}/INDEX" ] + then + echo "${PKGDIR}/INDEX" + exit 0 + else + exit 1 + fi - else - show_packages_by_category "${PACKAGE_CATEGORY}" - fi + else + show_packages_by_category "${PACKAGE_CATEGORY}" + fi elif [ "${NARGS}" -eq "2" ] then - show_package_by_name "${PACKAGE_CATEGORY}" "${PACKAGE_NAME}" + show_package_by_name "${PACKAGE_CATEGORY}" "${PACKAGE_NAME}" else - show_packages + show_packages fi Index: head/usr.sbin/pc-sysinstall/backend-query/set-mirror.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend-query/set-mirror.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend-query/set-mirror.sh (revision 211730) @@ -1,40 +1,40 @@ #!/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$ . ${PROGDIR}/backend/functions.sh . ${PROGDIR}/backend/functions-ftp.sh MIRROR="${1}" if [ -z "${MIRROR}" ] then - echo "Error: No mirror specified!" - exit 1 + echo "Error: No mirror specified!" + exit 1 fi set_ftp_mirror "${MIRROR}" exit 0 Index: head/usr.sbin/pc-sysinstall/backend-query/test-netup.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend-query/test-netup.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend-query/test-netup.sh (revision 211730) @@ -1,50 +1,50 @@ #!/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$ # Script which tests "fetch" when using a network connection, and saves # if we are using direct connect, or need FTP passive mode ############################################################################# rm ${TMPDIR}/.testftp >/dev/null 2>/dev/null ping -c 2 www.pcbsd.org >/dev/null 2>/dev/null if [ "$?" = "0" ] then - echo "ftp: Up" - exit 0 + echo "ftp: Up" + exit 0 fi ping -c 2 www.freebsd.org >/dev/null 2>/dev/null if [ "$?" = "0" ] then - echo "ftp: Up" - exit 0 + echo "ftp: Up" + exit 0 fi echo "ftp: Down" exit 1 Index: head/usr.sbin/pc-sysinstall/backend-query/update-part-list.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend-query/update-part-list.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend-query/update-part-list.sh (revision 211730) @@ -1,109 +1,110 @@ #!/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$ # Need access to a some unmount functions . ${PROGDIR}/backend/functions-unmount.sh echo "Running: find-update-parts" >> ${LOGOUT} rm ${TMPDIR}/AvailUpgrades >/dev/null 2>/dev/null FSMNT="/mnt" # Get the freebsd version on this partition -get_fbsd_ver() { +get_fbsd_ver() +{ VER="`file ${FSMNT}/bin/sh | grep 'for FreeBSD' | sed 's|for FreeBSD |;|g' | cut -d ';' -f 2 | cut -d ',' -f 1`" if [ "$?" = "0" ] ; then - file ${FSMNT}/bin/sh | grep '32-bit' >/dev/null 2>/dev/null - if [ "${?}" = "0" ] ; then - echo "${1}: FreeBSD ${VER} (32bit)" - else - echo "${1}: FreeBSD ${VER} (64bit)" - fi + file ${FSMNT}/bin/sh | grep '32-bit' >/dev/null 2>/dev/null + if [ "${?}" = "0" ] ; then + echo "${1}: FreeBSD ${VER} (32bit)" + else + echo "${1}: FreeBSD ${VER} (64bit)" + fi fi } # Create our device listing SYSDISK="`sysctl kern.disks | cut -d ':' -f 2 | sed 's/^[ \t]*//'`" DEVS="" # Now loop through these devices, and list the disk drives for i in ${SYSDISK} do # Get the current device DEV="${i}" # Make sure we don't find any cd devices echo "${DEV}" | grep -e "^acd[0-9]" -e "^cd[0-9]" -e "^scd[0-9]" >/dev/null 2>/dev/null if [ "$?" != "0" ] ; then - DEVS="${DEVS} `ls /dev/${i}*`" + DEVS="${DEVS} `ls /dev/${i}*`" fi done # Search for regular UFS / Geom Partitions to upgrade for i in $DEVS do - if [ ! -e "${i}a.journal" -a ! -e "${i}a" -a ! -e "${i}p2" -a ! -e "${i}p2.journal" ] ; then - continue - fi + if [ ! -e "${i}a.journal" -a ! -e "${i}a" -a ! -e "${i}p2" -a ! -e "${i}p2.journal" ] ; then + continue + fi - if [ -e "${i}a.journal" ] ; then - _dsk="${i}a.journal" - elif [ -e "${i}a" ] ; then - _dsk="${i}a" - elif [ -e "${i}p2" ] ; then - _dsk="${i}p2" - elif [ -e "${i}p2.journal" ] ; then - _dsk="${i}p2.journal" - fi + if [ -e "${i}a.journal" ] ; then + _dsk="${i}a.journal" + elif [ -e "${i}a" ] ; then + _dsk="${i}a" + elif [ -e "${i}p2" ] ; then + _dsk="${i}p2" + elif [ -e "${i}p2.journal" ] ; then + _dsk="${i}p2.journal" + fi - mount -o ro ${_dsk} ${FSMNT} >>${LOGOUT} 2>>${LOGOUT} - if [ "${?}" = "0" -a -e "${FSMNT}/bin/sh" ] ; then - get_fbsd_ver "`echo ${_dsk} | sed 's|/dev/||g'`" - umount -f ${FSMNT} >/dev/null 2>/dev/null - fi + mount -o ro ${_dsk} ${FSMNT} >>${LOGOUT} 2>>${LOGOUT} + if [ "${?}" = "0" -a -e "${FSMNT}/bin/sh" ] ; then + get_fbsd_ver "`echo ${_dsk} | sed 's|/dev/||g'`" + umount -f ${FSMNT} >/dev/null 2>/dev/null + fi done # Now search for any ZFS root partitions zpool import -o altroot=${FSMNT} -a # Unmount any auto-mounted stuff umount_all_dir "${FSMNT}" # Get pools _zps="`zpool list | grep -v 'NAME' | cut -d ' ' -f 1`" for _zpools in ${_zps} do - mount -o ro -t zfs ${_zpools} ${FSMNT} >>${LOGOUT} 2>>${LOGOUT} - if [ "${?}" = "0" -a -e "${FSMNT}/bin/sh" ] ; then - get_fbsd_ver "${_zpools}" - umount -f ${FSMNT} >/dev/null 2>/dev/null - fi + mount -o ro -t zfs ${_zpools} ${FSMNT} >>${LOGOUT} 2>>${LOGOUT} + if [ "${?}" = "0" -a -e "${FSMNT}/bin/sh" ] ; then + get_fbsd_ver "${_zpools}" + umount -f ${FSMNT} >/dev/null 2>/dev/null + fi done Index: head/usr.sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend-query/xkeyboard-layouts.sh (revision 211730) @@ -1,56 +1,56 @@ #!/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$ FOUND="0" # Lets parse the xorg.list file, and see what layouts are supported while read line do if [ "$FOUND" = "1" -a ! -z "$line" ] then echo $line | grep '! ' >/dev/null 2>/dev/null if [ "$?" = "0" ] then - exit 0 + exit 0 else echo "$line" fi fi if [ "${FOUND}" = "0" ] then echo $line | grep '! layout' >/dev/null 2>/dev/null if [ "$?" = "0" ] then FOUND="1" fi fi done < /usr/local/share/X11/xkb/rules/xorg.lst exit 0 Index: head/usr.sbin/pc-sysinstall/backend-query/xkeyboard-models.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend-query/xkeyboard-models.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend-query/xkeyboard-models.sh (revision 211730) @@ -1,58 +1,58 @@ #!/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$ FOUND="0" # Lets parse the xorg.list file, and see what models are supported while read line do if [ "$FOUND" = "1" -a ! -z "$line" ] then echo $line | grep '! ' >/dev/null 2>/dev/null if [ "$?" = "0" ] then - exit 0 + exit 0 else model="`echo $line | sed 's|(|[|g'`" model="`echo $model | sed 's|)|]|g'`" echo "$model" fi fi if [ "${FOUND}" = "0" ] then echo $line | grep '! model' >/dev/null 2>/dev/null if [ "$?" = "0" ] then FOUND="1" fi fi done < /usr/local/share/X11/xkb/rules/xorg.lst exit 0 Index: head/usr.sbin/pc-sysinstall/backend-query/xkeyboard-variants.sh =================================================================== --- head/usr.sbin/pc-sysinstall/backend-query/xkeyboard-variants.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/backend-query/xkeyboard-variants.sh (revision 211730) @@ -1,56 +1,56 @@ #!/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$ FOUND="0" # Lets parse the xorg.list file, and see what varients are supported while read line do if [ "$FOUND" = "1" -a ! -z "$line" ] then echo $line | grep '! ' >/dev/null 2>/dev/null if [ "$?" = "0" ] then - exit 0 + exit 0 else echo "$line" fi fi if [ "${FOUND}" = "0" ] then echo $line | grep '! variant' >/dev/null 2>/dev/null if [ "$?" = "0" ] then FOUND="1" fi fi done < /usr/local/share/X11/xkb/rules/xorg.lst exit 0 Index: head/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh =================================================================== --- head/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh (revision 211729) +++ head/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh (revision 211730) @@ -1,234 +1,236 @@ #!/bin/sh ##################################################################### # Author: Kris Moore # License: BSD # Description: pc-sysinstall provides a backend for performing # system installations, as well as calls which a front-end can use # to retrive information about the system ##################################################################### # Copyright 2010 iXsystems # All rights reserved # # Redistribution and use in source and binary forms, with or without # modification, are permitted providing 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 ``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 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$ ##################################################################### # User-editable configuration variables # Set this to the program location if [ -z "${PROGDIR}" ] then - PROGDIR="/usr/share/pc-sysinstall" - export PROGDIR + PROGDIR="/usr/share/pc-sysinstall" + export PROGDIR fi # Set this to the components location COMPDIR="${PROGDIR}/components" export COMPDIR CONFDIR="${PROGDIR}/conf" export CONFDIR # Set this to the packages location PKGDIR="${CONFDIR}" export PKGDIR # End of user-editable configuration ##################################################################### # Set our QUERYDIR QUERYDIR="${PROGDIR}/backend-query" export QUERYDIR # Set our BACKEND BACKEND="${PROGDIR}/backend" export BACKEND PARTMANAGERDIR="${PROGDIR}/backend-partmanager" export PARTMANAGERDIR # Start by sourcing our conf file if [ -e "${PROGDIR}/conf/pc-sysinstall.conf" ] then . ${PROGDIR}/conf/pc-sysinstall.conf else echo "ERROR: Could not find ${PROGDIR}/conf/pc-sysinstall.conf" exit 1 fi # Now source our functions.sh if [ -e "${PROGDIR}/backend/functions.sh" ] then . ${PROGDIR}/backend/functions.sh else echo "ERROR: Could not find ${PROGDIR}/backend/functions.sh" exit 1 fi # Check if we are called without any flags and display help if [ -z "${1}" ] then - # Display the help index - display_help - exit 0 + # Display the help index + display_help + exit 0 fi case $1 in # The -c flag has been given, time to parse the script - -c) if [ -z "${2}" ] - then - display_help - else - ${BACKEND}/parseconfig.sh ${2} - exit $? - fi + -c) + if [ -z "${2}" ] + then + display_help + else + ${BACKEND}/parseconfig.sh ${2} + exit $? + fi ;; # The user requsted help - help) if [ -z "${2}" ] - then - display_help - else - display_command_help ${2} - fi + help) + if [ -z "${2}" ] + then + display_help + else + display_command_help ${2} + fi ;; # Parse an auto-install directive, and begin the installation start-autoinstall) ${BACKEND}/startautoinstall.sh ${2} ;; # The user is wanting to create a new partition create-part) ${PARTMANAGERDIR}/create-part.sh "${2}" "${3}" ;; # The user is wanting to delete an existing partition delete-part) ${PARTMANAGERDIR}/delete-part.sh "${2}" ;; # The user is wanting to check if we are on a laptop or desktop detect-laptop) ${QUERYDIR}/detect-laptop.sh ;; # The user is wanting to see what nics are available on the system detect-nics) ${QUERYDIR}/detect-nics.sh ;; # The user is wanting to check if we are in emulation detect-emulation) ${QUERYDIR}/detect-emulation.sh ;; # The user is wanting to query a disk's information disk-info) ${QUERYDIR}/disk-info.sh ${2} ;; # The user is wanting to query which disks are available - disk-list) ${QUERYDIR}/disk-list.sh "${2}" + disk-list) ${QUERYDIR}/disk-list.sh $* ;; # The user is wanting to query a disk's partitions disk-part) ${QUERYDIR}/disk-part.sh ${2} ;; # Function allows the setting of networking by a calling front-end enable-net) ${QUERYDIR}/enable-net.sh "${2}" "${3}" "${4}" "${5}" "${6}" "${7}" ;; # Function which lists components available list-components) ${QUERYDIR}/list-components.sh ;; # Function which lists pc-sysinstall configuration list-config) ${QUERYDIR}/list-config.sh ;; # Function which lists available FTP mirrors list-mirrors) ${QUERYDIR}/list-mirrors.sh "${2}" ;; # Function which lists available packages list-packages) ${QUERYDIR}/list-packages.sh "${2}" "${3}" ;; # Function which lists available backups on a rsync/ssh server list-rsync-backups) ${QUERYDIR}/list-rsync-backups.sh "${2}" "${3}" "${4}" ;; # Function which lists timezones available list-tzones) ${QUERYDIR}/list-tzones.sh ;; # Requested a list of languages this install will support query-langs) ${QUERYDIR}/query-langs.sh ;; # Function which creates a error report, and mails it to the specified address send-logs) ${QUERYDIR}/send-logs.sh ${2} ;; # Function to get package index get-packages) ${QUERYDIR}/get-packages.sh "${2}" ;; # Function to set FTP mirror set-mirror) ${QUERYDIR}/set-mirror.sh "${2}" ;; # Function which allows setting up of SSH keys setup-ssh-keys) ${QUERYDIR}/setup-ssh-keys.sh "${2}" "${3}" "${4}" ;; # Function which lists the real memory of the system in MB sys-mem) ${QUERYDIR}/sys-mem.sh ;; # Run script which determines if we are booted from install media, or on disk test-live) ${QUERYDIR}/test-live.sh ;; # The user is wanting to test if the network is up and working test-netup) ${QUERYDIR}/test-netup.sh ;; # The user is wanting to get a list of partitions available to be updated / repaired update-part-list) ${QUERYDIR}/update-part-list.sh ;; # Requested a list of keyboard layouts that xorg supports xkeyboard-layouts) ${QUERYDIR}/xkeyboard-layouts.sh ;; # Requested a list of keyboard models that xorg supports xkeyboard-models) ${QUERYDIR}/xkeyboard-models.sh ;; # Requested a list of keyboard variants that xorg supports xkeyboard-variants) ${QUERYDIR}/xkeyboard-variants.sh ;; *) echo "Unknown Command: ${1}" exit 1 ;; esac # Exit with success if we made it to the end exit $?