mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-01 12:19:28 +00:00
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
This commit is contained in:
parent
170a7705ae
commit
ecc12db0a4
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=212337
@ -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)
|
||||
|
@ -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=
|
||||
|
@ -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}
|
||||
};
|
||||
|
@ -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
|
||||
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"
|
||||
# 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"
|
||||
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" -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
|
||||
# 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 [ $LASTSLICE -gt 4 ]
|
||||
then
|
||||
exit_err "ERROR: BSD only supports primary partitions, and there are none availble on $DISK"
|
||||
fi
|
||||
if [ -z "${LASTSLICE}" ]
|
||||
then
|
||||
LASTSLICE="1"
|
||||
else
|
||||
LASTSLICE="`expr $LASTSLICE + 1`"
|
||||
fi
|
||||
|
||||
fi
|
||||
fi
|
||||
if [ $LASTSLICE -gt 4 ]
|
||||
then
|
||||
exit_err "ERROR: BSD only supports primary partitions, and there are none availble on $DISK"
|
||||
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
|
||||
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
|
||||
# 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
|
||||
|
||||
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
|
||||
# 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
|
||||
|
||||
run_gpart_full "${DISK}" "${BMANAGER}" "${PSCHEME}"
|
||||
;;
|
||||
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
|
||||
|
||||
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}"
|
||||
;;
|
||||
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
|
||||
|
||||
free|FREE)
|
||||
tmpSLICE="${DISK}s${LASTSLICE}"
|
||||
run_gpart_free "${DISK}" "${LASTSLICE}" "${BMANAGER}"
|
||||
;;
|
||||
run_gpart_full "${DISK}" "${BMANAGER}" "${PSCHEME}"
|
||||
;;
|
||||
|
||||
*) exit_err "ERROR: Unknown PTYPE: $PTYPE" ;;
|
||||
esac
|
||||
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}"
|
||||
;;
|
||||
|
||||
# Now save which disk<num> this is, so we can parse it later during slice partition setup
|
||||
echo "disk${disknum}" >${SLICECFGDIR}/$tmpSLICE
|
||||
free)
|
||||
tmpSLICE="${DISK}s${LASTSLICE}"
|
||||
run_gpart_free "${DISK}" "${LASTSLICE}" "${BMANAGER}"
|
||||
;;
|
||||
|
||||
# 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
|
||||
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<num> 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
|
||||
disknum="`expr $disknum + 1`"
|
||||
else
|
||||
exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!"
|
||||
fi
|
||||
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<num>= 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
|
||||
|
@ -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
|
||||
|
||||
|
@ -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" ]
|
||||
|
@ -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
|
||||
};
|
||||
|
@ -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"
|
||||
|
@ -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!"
|
||||
}
|
||||
|
@ -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
|
||||
upgrade)
|
||||
install_upgrade
|
||||
;;
|
||||
|
||||
# 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
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
|
@ -9,6 +9,8 @@ Help Commands
|
||||
Display the help data for the specified command
|
||||
|
||||
System Query Commands
|
||||
install-image <image> <device>
|
||||
Installs an image file to a device file
|
||||
|
||||
disk-list
|
||||
Provides a listing of the disk drives detected on this system
|
||||
|
@ -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
|
||||
|
@ -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}
|
||||
;;
|
||||
|
Loading…
Reference in New Issue
Block a user