From 608e1b84a9142f7c5e7fb3c2d7e2bc4f64e633f0 Mon Sep 17 00:00:00 2001 From: imp Date: Wed, 8 Sep 2010 20:10:24 +0000 Subject: pc-sysinstall(8) patch that allows images to be written to disks This patch creates the "image" directive for the pc-sysinstall config file. This allows disks to be configured with an image instead of partitioning. PR: 150137 Submitted by: John Hixson --- usr.sbin/pc-sysinstall/backend-query/disk-list.sh | 13 +- usr.sbin/pc-sysinstall/backend/Makefile | 2 +- .../pc-sysinstall/backend/functions-bsdlabel.sh | 172 ++++++++++- usr.sbin/pc-sysinstall/backend/functions-disk.sh | 333 ++++++++++++--------- .../backend/functions-extractimage.sh | 8 +- .../backend/functions-installcomponents.sh | 4 +- .../pc-sysinstall/backend/functions-packages.sh | 6 +- usr.sbin/pc-sysinstall/backend/functions-parse.sh | 1 + usr.sbin/pc-sysinstall/backend/functions.sh | 115 +++++++ usr.sbin/pc-sysinstall/backend/parseconfig.sh | 91 +----- usr.sbin/pc-sysinstall/doc/help-index | 2 + usr.sbin/pc-sysinstall/examples/README | 11 +- .../pc-sysinstall/pc-sysinstall/pc-sysinstall.sh | 4 + 13 files changed, 523 insertions(+), 239 deletions(-) (limited to 'usr.sbin/pc-sysinstall') diff --git a/usr.sbin/pc-sysinstall/backend-query/disk-list.sh b/usr.sbin/pc-sysinstall/backend-query/disk-list.sh index eb6b437..4054f04 100755 --- a/usr.sbin/pc-sysinstall/backend-query/disk-list.sh +++ b/usr.sbin/pc-sysinstall/backend-query/disk-list.sh @@ -27,6 +27,7 @@ ARGS=$1 FLAGS_MD="" +FLAGS_CD="" FLAGS_VERBOSE="" shift @@ -39,6 +40,9 @@ do -v) FLAGS_VERBOSE=1 ;; + -c) + FLAGS_CD=1 + ;; esac shift done @@ -62,9 +66,12 @@ do DEV="${i}" # Make sure we don't find any cd devices - case "${DEV}" in - acd[0-9]*|cd[0-9]*|scd[0-9]*) continue ;; - esac + if [ -z "${FLAGS_CD}" ] + then + case "${DEV}" in + acd[0-9]*|cd[0-9]*|scd[0-9]*) continue ;; + esac + fi # Check the dmesg output for some more info about this device NEWLINE=$(dmesg | sed -n "s/^$DEV: .*<\(.*\)>.*$/ <\1>/p" | head -n 1) diff --git a/usr.sbin/pc-sysinstall/backend/Makefile b/usr.sbin/pc-sysinstall/backend/Makefile index fa51d50..6165191 100644 --- a/usr.sbin/pc-sysinstall/backend/Makefile +++ b/usr.sbin/pc-sysinstall/backend/Makefile @@ -7,7 +7,7 @@ FILES= functions-bsdlabel.sh functions-cleanup.sh functions-disk.sh \ functions-newfs.sh functions-packages.sh functions-parse.sh \ functions-runcommands.sh functions-unmount.sh \ functions-upgrade.sh functions-users.sh \ - functions.sh parseconfig.sh startautoinstall.sh + functions.sh parseconfig.sh startautoinstall.sh installimage.sh FILESMODE= ${BINMODE} FILESDIR=${SHAREDIR}/pc-sysinstall/backend NO_OBJ= diff --git a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh index 42aaec2..1604148 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh @@ -566,9 +566,8 @@ populate_disk_label() 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 + if [ -z "${WORKINGSLICES}" -a -z "${WORKINGIMAGES}" ]; then exit_err "ERROR: No slices were setup! Please report this to the maintainers" fi @@ -613,6 +612,12 @@ setup_disk_label() populate_disk_label "${i}" done + for i in $WORKINGIMAGES + do + image=`echo "${i}"|cut -f2 -d:` + check_image_layout "${image}" + done + # Check if we made a root partition if [ "$FOUNDROOT" = "-1" ] then @@ -631,3 +636,166 @@ setup_disk_label() fi }; +check_fstab_mbr() +{ + local SLICE + local FSTAB + + if [ -z "$2" ] + then + return 1 + fi + + SLICE="$1" + FSTAB="$2/etc/fstab" + + if [ -f "${FSTAB}" ] + then + PARTLETTER=`echo "$SLICE" | sed -E 's|^.+([a-h])$|\1|'` + + grep -E '^.+ +/ +' "${FSTAB}" >/dev/null 2>&1 + if [ "$?" = "0" ] + then + if [ "${PARTLETTER}" = "a" ] + then + FOUNDROOT="0" + else + FOUNDROOT="1" + fi + export FOUNDROOT + fi + + grep -E '^.+ +/boot +' "${FSTAB}" >/dev/null 2>&1 + if [ "$?" = "0" ] + then + if [ "${PARTLETTER}" = "a" ] + then + USINGBOOTPART="0" + else + exit_err "/boot partition must be first partition" + fi + export USINGBOOTPART + fi + + return 0 + fi + + return 1 +}; + +check_fstab_gpt() +{ + local SLICE + local FSTAB + + if [ -z "$2" ] + then + return 1 + fi + + SLICE="$1" + FSTAB="$2/etc/fstab" + + if [ -f "${FSTAB}" ] + then + PARTNUMBER=`echo "${SLICE}" | sed -E 's|^.+p([0-9]*)$|\1|'` + + grep -E '^.+ +/ +' "${FSTAB}" >/dev/null 2>&1 + if [ "$?" = "0" ] + then + if [ "${PARTNUMBER}" = "2" ] + then + FOUNDROOT="0" + else + FOUNDROOT="1" + fi + export FOUNDROOT + fi + + grep -E '^.+ +/boot +' "${FSTAB}" >/dev/null 2>&1 + if [ "$?" = "0" ] + then + if [ "${PARTNUMBER}" = "2" ] + then + USINGBOOTPART="0" + else + exit_err "/boot partition must be first partition" + fi + export USINGBOOTPART + fi + + return 0 + fi + + + return 1 +}; + +check_image_layout() +{ + local SLICES + local IMAGE + local TYPE + local RES + local MD + local F + + IMAGE="$1" + TYPE="MBR" + + if [ -z "${IMAGE}" ] + then + return 1 + fi + + MD=`mdconfig -af "${IMAGE}"` + if [ "$?" != "0" ] + then + return 1 + fi + + SLICES=`ls /dev/${MD}s[1-4]*[a-h]* 2>/dev/null` + if [ "$?" != "0" ] + then + SLICES=`ls /dev/${MD}p[0-9]* 2>/dev/null` + if [ -n "${SLICES}" ] + then + TYPE="GPT" + RES=0 + fi + else + RES=0 + fi + + for slice in ${SLICES} + do + F=1 + mount ${slice} /mnt 2>/dev/null + if [ "$?" != "0" ] + then + continue + fi + + if [ "${TYPE}" = "MBR" ] + then + check_fstab_mbr "${slice}" "/mnt" + F="$?" + + elif [ "${TYPE}" = "GPT" ] + then + check_fstab_gpt "${slice}" "/mnt" + F="$?" + fi + + if [ "${F}" = "0" ] + then + umount /mnt + break + fi + + umount /mnt + done + + mdconfig -d -u "${MD}" + return ${RES} +}; diff --git a/usr.sbin/pc-sysinstall/backend/functions-disk.sh b/usr.sbin/pc-sysinstall/backend/functions-disk.sh index 6416fe1..f676cd6 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-disk.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-disk.sh @@ -231,9 +231,6 @@ get_disk_heads() 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 }; @@ -336,164 +333,205 @@ setup_disk_slice() # 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" + 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 + # 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 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 stop any geli stuff on this disk + stop_all_geli ${DISK} - # Make sure we don't have any zpools loaded - stop_all_zfs + # Make sure we don't have any zpools loaded + stop_all_zfs - fi + fi - # Lets look if this device will be mirrored on another disk - echo $line | grep "^mirror=" >/dev/null 2>/dev/null - if [ "$?" = "0" ] - then + # 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" + # 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 + # 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 + # 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 + # 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 + 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=`echo $VAL|tr A-Z a-z` + + # We are using free space, figure out the slice number + if [ "${PTYPE}" = "free" ] + then + # Lets figure out what number this slice will be + LASTSLICE="`gpart show ${DISK} \ + | grep -v ${DISK} \ + | grep -v ' free' \ + | tr -s '\t' ' ' \ + | cut -d ' ' -f 4 \ + | sed '/^$/d' \ + | tail -n 1`" + + if [ -z "${LASTSLICE}" ] + then + LASTSLICE="1" + else + LASTSLICE="`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 - fi - fi + # Check if we have an image file defined + echo $line | grep "^image=" >/dev/null 2>/dev/null + if [ "$?" = "0" ] ; then + # Found an image= entry, lets read / set it + get_value_from_string "${line}" + strip_white_space "$VAL" + IMAGE="$VAL" + if [ ! -f "$IMAGE" ] ; then + exit_err "$IMAGE file does not exist" + fi + fi - # Check if we have a partscheme specified - echo $line | grep "^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 + # 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 "^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" ;; - 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 + 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) + 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) + tmpSLICE="${DISK}s${LASTSLICE}" + run_gpart_free "${DISK}" "${LASTSLICE}" "${BMANAGER}" + ;; + + image) + if [ -n "${IMAGE}" ] + then + write_image "${IMAGE}" "${DISK}" + else + exit_err "ERROR: partition type image specified with no image!" + fi + + IMAGE="${DISK}:${IMAGE}" + if [ -z "${WORKINGIMAGES}" ] + then + WORKINGIMAGES="${IMAGE}" + else + WORKINGIMAGES="${WORKINGIMAGES} ${IMAGE}" + fi + + export WORKINGIMAGES + ;; + + *) exit_err "ERROR: Unknown PTYPE: $PTYPE" ;; + esac + + # Now save which disk this is, so we can parse it later during slice partition setup + if [ -n "${tmpSLICE}" ] + then + echo "disk${disknum}" >${SLICECFGDIR}/$tmpSLICE + fi + + # 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 IMAGE + disknum="`expr $disknum + 1`" + else + exit_err "ERROR: commitDiskPart was called without procceding disk= and partition= entries!!!" + fi + fi done <${CFGF} @@ -590,8 +628,7 @@ init_mbr_full_disk() totalblocks="`expr ${totalblocks} \* ${sec}`" if [ -z "${totalblocks}" ] then - get_disk_mediasize "${_intDISK}" - totalblocks="${VAL}" + totalblocks=`gpart show "${_intDISK}"|tail -2|head -1|awk '{ print $2 }'` fi # Now set the ending block to the total disk block size diff --git a/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh b/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh index 72a30fb..c7c7ed7 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh @@ -377,7 +377,7 @@ init_extraction() fi ;; - ftp|sftp) + ftp) if [ "$PACKAGETYPE" = "split" ] then fetch_split_files @@ -390,9 +390,9 @@ init_extraction() fi ;; - rsync) start_rsync_copy ;; - img) - ;; + sftp) ;; + + rsync) start_rsync_copy ;; *) exit_err "ERROR: Unknown install medium" ;; esac diff --git a/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh b/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh index e8beeda..f133e30 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh @@ -60,7 +60,7 @@ copy_component() RESULT="$?" ;; - ftp|sftp) + ftp) get_value_from_cfg ftpPath if [ -z "$VAL" ] then @@ -71,6 +71,8 @@ copy_component() fetch_file "${FTPPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE}" "${FSMNT}/${COMPTMPDIR}/${CFILE}" "0" RESULT="$?" ;; + + sftp) ;; esac if [ "${RESULT}" != "0" ] diff --git a/usr.sbin/pc-sysinstall/backend/functions-packages.sh b/usr.sbin/pc-sysinstall/backend/functions-packages.sh index 998b7ad..f517250 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-packages.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-packages.sh @@ -113,7 +113,8 @@ get_package_index() case "${INSTALLMEDIUM}" in usb|dvd) get_package_index_by_fs ;; - ftp|sftp) get_package_index_by_ftp "${FTPPATH}" ;; + ftp) get_package_index_by_ftp "${FTPPATH}" ;; + sftp) ;; *) RES=1 ;; esac @@ -369,6 +370,7 @@ fetch_package() case "${INSTALLMEDIUM}" in usb|dvd) fetch_package_by_fs "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;; - ftp|sftp) fetch_package_by_ftp "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;; + ftp) fetch_package_by_ftp "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;; + sftp) ;; esac }; diff --git a/usr.sbin/pc-sysinstall/backend/functions-parse.sh b/usr.sbin/pc-sysinstall/backend/functions-parse.sh index 3604ba4..11bba10 100755 --- a/usr.sbin/pc-sysinstall/backend/functions-parse.sh +++ b/usr.sbin/pc-sysinstall/backend/functions-parse.sh @@ -85,6 +85,7 @@ if_check_value_exists() VALID="1" for i in ${2} do + VAL=`echo "$VAL"|tr A-Z a-z` if [ "$VAL" = "${i}" ] then VALID="0" diff --git a/usr.sbin/pc-sysinstall/backend/functions.sh b/usr.sbin/pc-sysinstall/backend/functions.sh index f51902a..847d97e 100755 --- a/usr.sbin/pc-sysinstall/backend/functions.sh +++ b/usr.sbin/pc-sysinstall/backend/functions.sh @@ -283,3 +283,118 @@ get_zpool_name() return fi }; + +write_image() +{ + IMAGE_FILE="$1" + DEVICE_FILE="$2" + + if [ -z "${IMAGE_FILE}" ] + then + echo "ERROR: Image file not specified!" + exit 1 + fi + + if [ -z "${DEVICE_FILE}" ] + then + echo "ERROR: Device file not specified!" + exit 1 + fi + + if [ ! -f "${IMAGE_FILE}" ] + then + echo "ERROR: '${IMAGE_FILE}' does not exist!" + exit 1 + fi + + DEVICE_FILE="${DEVICE_FILE#/dev/}" + DEVICE_FILE="/dev/${DEVICE_FILE}" + + if [ ! -c "${DEVICE_FILE}" ] + then + echo "ERROR: '${DEVICE_FILE}' is not a character device!" + exit 1 + fi + + if [ "${RES}" = "0" ] + then + rc_halt "dd if=${IMAGE_FILE} of=${DEVICE_FILE} ibs=16k obs=16k" + fi + + return 0 +}; + +install_fresh() +{ + # 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!" +} + +install_upgrade() +{ + # 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 + + # ow 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!" +} diff --git a/usr.sbin/pc-sysinstall/backend/parseconfig.sh b/usr.sbin/pc-sysinstall/backend/parseconfig.sh index ff5694c..af4f974 100755 --- a/usr.sbin/pc-sysinstall/backend/parseconfig.sh +++ b/usr.sbin/pc-sysinstall/backend/parseconfig.sh @@ -73,9 +73,9 @@ file_sanity_check "installMode disk0 installType installMedium packageType" check_value installMode "fresh upgrade" check_value bootManager "bsd none" check_value installType "PCBSD FreeBSD" -check_value installMedium "dvd usb ftp rsync img" +check_value installMedium "dvd usb ftp rsync" check_value packageType "uzip tar rsync split" -if_check_value_exists partition "all ALL s1 s2 s3 s4 free FREE" +if_check_value_exists partition "all s1 s2 s3 s4 free image" if_check_value_exists mirrorbal "load prefer round-robin split" # We passed all sanity checks! Yay, lets start the install @@ -98,79 +98,18 @@ PACKAGETYPE="${VAL}" ; export PACKAGETYPE start_networking # If we are not doing an upgrade, lets go ahead and setup the disk -if [ "${INSTALLMODE}" = "fresh" ] -then +case "${INSTALLMODE}" in + fresh) + install_fresh + ;; - # 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 + upgrade) + install_upgrade + ;; + + *) + exit 1 + ;; +esac +exit 0 diff --git a/usr.sbin/pc-sysinstall/doc/help-index b/usr.sbin/pc-sysinstall/doc/help-index index 6a0f1bc..bad401f 100644 --- a/usr.sbin/pc-sysinstall/doc/help-index +++ b/usr.sbin/pc-sysinstall/doc/help-index @@ -9,6 +9,8 @@ Help Commands Display the help data for the specified command System Query Commands + install-image + Installs an image file to a device file disk-list Provides a listing of the disk drives detected on this system diff --git a/usr.sbin/pc-sysinstall/examples/README b/usr.sbin/pc-sysinstall/examples/README index eeb96d0..1031375 100644 --- a/usr.sbin/pc-sysinstall/examples/README +++ b/usr.sbin/pc-sysinstall/examples/README @@ -114,7 +114,7 @@ root zpool of the target system to update. I.E: # disk0=ada0s1a -# partition=(all, free, s1, s1, s3, s4) +# partition=(all, free, s1, s1, s3, s4, image) After setting disk[0-9], the partition= variable is used to specify which target partition we will be working with for this device. @@ -124,7 +124,9 @@ Setting this to "all" will setup the disk with a single FreeBSD slice as "s1" Setting this to "free" will allow pc-sysinstall to search for the first available primary slice with free space, and create the slice. -Setting this to "s1, s2, s3 or s4" will use the specified MBR slice +Setting this to "s1, s2, s3 or s4" will use the specified MBR slice. + +Setting this to "image" will use an image to configure the disk. (This tag is unused for upgrades) @@ -151,6 +153,11 @@ specified this defaults to "round-robin" Setting this option will instruct pc-sysinstall to install the BSD boot Manager, or leave it empty +# image=(/path/to/image/file) + +Setting this option will instruct pc-sysinstall to write the image file +specified by the path to the disk. + # commitDiskPart This command must be placed at the end of the diskX= section, before starting diff --git a/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh b/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh index 088dea7..ff62a6f 100755 --- a/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh +++ b/usr.sbin/pc-sysinstall/pc-sysinstall/pc-sysinstall.sh @@ -116,6 +116,10 @@ case $1 in fi ;; + # Install an image file to a device + install-image) ${BACKEND}/installimage.sh "${2}" "${3}" + ;; + # Parse an auto-install directive, and begin the installation start-autoinstall) ${BACKEND}/startautoinstall.sh ${2} ;; -- cgit v1.1