summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorjpaetzel <jpaetzel@FreeBSD.org>2011-09-19 05:12:53 +0000
committerjpaetzel <jpaetzel@FreeBSD.org>2011-09-19 05:12:53 +0000
commitd3ab0cf954ad6a22d6d4abd24a9711534e70af19 (patch)
tree1fec4b3768a98ffaf158f7aef4d80eae6d13b2ca /usr.sbin
parent55278d20da7e1685274612bda3ff81211ee24e98 (diff)
downloadFreeBSD-src-d3ab0cf954ad6a22d6d4abd24a9711534e70af19.zip
FreeBSD-src-d3ab0cf954ad6a22d6d4abd24a9711534e70af19.tar.gz
Fix a logic bug in pc-sysinstall creating partitions.
Improve exit when an error occurs. Fix parsing to grab values which contain extra '=' signs. Fix a bug setting the timezone properly. Fix a usage bug when setting up with gmirror. Allow a uzip file from local media to be used. Allow specifying flags for "newfs" when using UFS as the file system. Run custom commands after doing final cleanup / fstab generation and such. Also fix using relative path for config file. Approved by: re (bz)
Diffstat (limited to 'usr.sbin')
-rwxr-xr-xusr.sbin/pc-sysinstall/backend-partmanager/create-part.sh2
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh12
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-disk.sh2
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-extractimage.sh14
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-localize.sh2
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-newfs.sh8
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-parse.sh6
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-unmount.sh22
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions.sh10
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/parseconfig.sh10
-rw-r--r--usr.sbin/pc-sysinstall/examples/README8
11 files changed, 60 insertions, 36 deletions
diff --git a/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh b/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh
index ccb8d19..d0343b4 100755
--- a/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh
+++ b/usr.sbin/pc-sysinstall/backend-partmanager/create-part.sh
@@ -90,7 +90,7 @@ if [ $? -eq 0 -a "${SLICENUM}" = "1" ] ; then
fi
# If we have a starting block, use it
-if [ -z "$STARTBLOCK" ] ; then
+if [ -n "$STARTBLOCK" ] ; then
sBLOCK="-b $STARTBLOCK"
fi
diff --git a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
index e819d74..5b30695 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
@@ -45,7 +45,6 @@ check_for_enc_pass()
};
# 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}"
@@ -76,6 +75,15 @@ get_fs_line_xvars()
return
fi # End of ZFS block
+ # See if we are looking for UFS specific newfs options
+ echo $LINE | grep -q '^UFS' 2>/dev/null
+ if [ $? -eq 0 ] ; then
+ FSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`"
+ VAR="${FSVARS}"
+ export VAR
+ return
+ fi
+
fi # End of xtra-options block
# If we got here, set VAR to empty and export
@@ -278,7 +286,7 @@ setup_gpart_partitions()
# Check if using zfs mirror
echo ${XTRAOPTS} | grep -q "mirror" 2>/dev/null
- if [ $? -eq 0 ] ; then
+ if [ $? -eq 0 -a "$FS" = "ZFS" ] ; then
if [ "${_pType}" = "gpt" ] ; then
XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}p${CURPART}")
else
diff --git a/usr.sbin/pc-sysinstall/backend/functions-disk.sh b/usr.sbin/pc-sysinstall/backend/functions-disk.sh
index c63f7af..73c3eb4 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-disk.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-disk.sh
@@ -554,7 +554,7 @@ init_gmirror()
local _mDisk=$3
# Create this mirror device
- rc_halt "gmirror label -vb ${_mBal} gm${_mNum} /dev/${_mDisk}"
+ rc_halt "gmirror label -vb ${_mBal} gm${_mNum} ${_mDisk}"
sleep 3
diff --git a/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh b/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh
index 75b5a41..5d32466 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh
@@ -55,6 +55,10 @@ start_extract_uzip_tar()
case ${PACKAGETYPE} in
uzip)
+ if ! kldstat -v | grep -q "geom_uzip" ; then
+ exit_err "Kernel module geom_uzip not loaded"
+ fi
+
# Start by mounting the uzip image
MDDEVICE=`mdconfig -a -t vnode -o readonly -f ${INSFILE}`
mkdir -p ${FSMNT}.uzip
@@ -435,6 +439,16 @@ init_extraction()
rsync) start_rsync_copy ;;
image) start_image_install ;;
+ local)
+ get_value_from_cfg localPath
+ if [ -z "$VAL" ]
+ then
+ exit_err "Install medium was set to local, but no localPath was provided!"
+ fi
+ LOCALPATH=$VAL
+ INSFILE="${LOCALPATH}/${INSFILE}" ; export INSFILE
+ start_extract_uzip_tar
+ ;;
*) exit_err "ERROR: Unknown install medium" ;;
esac
diff --git a/usr.sbin/pc-sysinstall/backend/functions-localize.sh b/usr.sbin/pc-sysinstall/backend/functions-localize.sh
index 38cda79..7ee898c 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-localize.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-localize.sh
@@ -509,7 +509,7 @@ run_localize()
# Check if we need to set a timezone
- echo $line | -q grep "^timeZone=" 2>/dev/null
+ echo $line | grep -q "^timeZone=" 2>/dev/null
if [ $? -eq 0 ] ; then
get_value_from_string "$line"
set_timezone "$VAL"
diff --git a/usr.sbin/pc-sysinstall/backend/functions-newfs.sh b/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
index 96ca49b..d5edff1 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-newfs.sh
@@ -138,7 +138,7 @@ setup_filesystems()
UFS)
echo_log "NEWFS: ${PARTDEV} - ${PARTFS}"
sleep 2
- rc_halt "newfs ${PARTDEV}${EXT}"
+ rc_halt "newfs ${PARTXTRAOPTS} ${PARTDEV}${EXT}"
sleep 2
rc_halt "sync"
rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}"
@@ -154,7 +154,7 @@ setup_filesystems()
UFS+S)
echo_log "NEWFS: ${PARTDEV} - ${PARTFS}"
sleep 2
- rc_halt "newfs -U ${PARTDEV}${EXT}"
+ rc_halt "newfs ${PARTXTRAOPTS} -U ${PARTDEV}${EXT}"
sleep 2
rc_halt "sync"
rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}"
@@ -169,7 +169,7 @@ setup_filesystems()
UFS+SUJ)
echo_log "NEWFS: ${PARTDEV} - ${PARTFS}"
sleep 2
- rc_halt "newfs -U ${PARTDEV}${EXT}"
+ rc_halt "newfs ${PARTXTRAOPTS} -U ${PARTDEV}${EXT}"
sleep 2
rc_halt "sync"
rc_halt "tunefs -j enable ${PARTDEV}${EXT}"
@@ -192,7 +192,7 @@ setup_filesystems()
sleep 2
rc_halt "gjournal label -f ${PARTDEV}${EXT}"
sleep 2
- rc_halt "newfs -O 2 -J ${PARTDEV}${EXT}.journal"
+ rc_halt "newfs ${PARTXTRAOPTS} -O 2 -J ${PARTDEV}${EXT}.journal"
sleep 2
rc_halt "sync"
rc_halt "glabel label ${PARTLABEL} ${PARTDEV}${EXT}.journal"
diff --git a/usr.sbin/pc-sysinstall/backend/functions-parse.sh b/usr.sbin/pc-sysinstall/backend/functions-parse.sh
index 4f96ca3..8b9d418 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-parse.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-parse.sh
@@ -33,7 +33,7 @@ get_value_from_string()
{
if [ -n "${1}" ]
then
- export VAL="`echo ${1} | cut -d '=' -f 2`"
+ export VAL="`echo ${1} | cut -d '=' -f 2-15`"
else
echo "Error: Did we forgot to supply a string to parse?"
exit 1
@@ -45,7 +45,7 @@ get_value_from_cfg_with_spaces()
{
if [ -n "${1}" ]
then
- export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2`
+ export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2-15`
else
exit_err "Error: Did we forgot to supply a setting to grab?"
fi
@@ -57,7 +57,7 @@ get_value_from_cfg()
{
if [ -n "${1}" ]
then
- export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '`
+ export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2-15 | tr -d ' '`
else
exit_err "Error: Did we forgot to supply a setting to grab?"
fi
diff --git a/usr.sbin/pc-sysinstall/backend/functions-unmount.sh b/usr.sbin/pc-sysinstall/backend/functions-unmount.sh
index ce0db9b..23630f7 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-unmount.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-unmount.sh
@@ -176,35 +176,35 @@ unmount_all_filesystems_failure()
then
if [ "${PARTENC}" = "ON" ]
then
- rc_nohalt "swapoff ${PARTDEV}.eli"
+ swapoff ${PARTDEV}.eli >/dev/null 2>/dev/null
else
- rc_nohalt "swapoff ${PARTDEV}"
+ swapoff ${PARTDEV} >/dev/null 2>/dev/null
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 ${PARTDEV}"
- rc_nohalt "umount -f ${FSMNT}${PARTMNT}"
+ umount -f ${PARTDEV} >/dev/null 2>/dev/null
+ umount -f ${FSMNT}${PARTMNT} >/dev/null 2>/dev/null
fi
done
# Last lets the /mnt partition
#########################################################
- rc_nohalt "umount -f ${FSMNT}"
+ umount -f ${FSMNT} >/dev/null 2>/dev/null
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"
+ chroot ${FSMNT} /sbin/umount -a >/dev/null 2>/dev/null
+ umount -f ${FSMNT}/usr >/dev/null 2>/dev/null
+ umount -f ${FSMNT}/dev >/dev/null 2>/dev/null
+ umount -f ${FSMNT} >/dev/null 2>/dev/null
+ sh ${TMPDIR}/.upgrade-unmount >/dev/null 2>/dev/null
fi
# Unmount our CDMNT
- rc_nohalt "umount ${CDMNT}"
+ umount ${CDMNT} >/dev/null 2>/dev/null
};
diff --git a/usr.sbin/pc-sysinstall/backend/functions.sh b/usr.sbin/pc-sysinstall/backend/functions.sh
index 4987bf4..9a98ee2 100755
--- a/usr.sbin/pc-sysinstall/backend/functions.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions.sh
@@ -98,10 +98,10 @@ strip_white_space()
exit_err()
{
# Echo the message for the users benefit
- echo "$1"
+ echo "EXITERROR: $1"
# Save this error to the log file
- echo "${1}" >>$LOGOUT
+ echo "EXITERROR: ${1}" >>$LOGOUT
# Check if we need to unmount any file-systems after this failure
unmount_all_filesystems_failure
@@ -446,12 +446,12 @@ install_fresh()
# Now add any users
setup_users
- # Now run any commands specified
- run_commands
-
# Do any last cleanup / setup before unmounting
run_final_cleanup
+ # Now run any commands specified
+ run_commands
+
# Unmount and finish up
unmount_all_filesystems
fi
diff --git a/usr.sbin/pc-sysinstall/backend/parseconfig.sh b/usr.sbin/pc-sysinstall/backend/parseconfig.sh
index eeb6ce0..2e16751 100755
--- a/usr.sbin/pc-sysinstall/backend/parseconfig.sh
+++ b/usr.sbin/pc-sysinstall/backend/parseconfig.sh
@@ -58,12 +58,8 @@ 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
+# Resolve any relative pathing
+CFGF="`realpath ${CFGF}`"
export CFGF
# Start by doing a sanity check, which will catch any obvious mistakes in the config
@@ -72,7 +68,7 @@ file_sanity_check "installMode installType installMedium packageType"
# We passed the Sanity check, lets grab some of the universal config settings and store them
check_value installMode "fresh upgrade extract"
check_value installType "PCBSD FreeBSD"
-check_value installMedium "dvd usb ftp rsync image"
+check_value installMedium "dvd usb ftp rsync image local"
check_value packageType "uzip tar rsync split"
if_check_value_exists partition "all s1 s2 s3 s4 free image"
if_check_value_exists mirrorbal "load prefer round-robin split"
diff --git a/usr.sbin/pc-sysinstall/examples/README b/usr.sbin/pc-sysinstall/examples/README
index 2eb1e6f..cc269a2 100644
--- a/usr.sbin/pc-sysinstall/examples/README
+++ b/usr.sbin/pc-sysinstall/examples/README
@@ -184,7 +184,7 @@ the listing of any additional diskX= directives.
The following settings specify the partitioning / mount points to setup
on the target partition
-# disk0-part=UFS+S 500 /
+# disk0-part=UFS+S 500 / (-n -o time)
# disk0-part=SWAP 2000 none
# disk0-part=UFS.eli 500 /usr
# encpass=mypass
@@ -219,6 +219,12 @@ All sizes are expressed in MegaBytes
Specifying a size 0 instructs pc-sysinstall to use the rest of the
available slice size, and should only be used for the last partition / mount
+When using "UFS" and its various types, it is possible to specify custom options
+for newfs using (). For examplei:
+disk0-part=UFS+SUJ 1000 / (-o time)
+In this case "-o time" would be passed to newfs when creating the "/" filesystem.
+
+
When using "ZFS" specifically, it is possible to specify additional disks / partitions
to include in the zpool. By using the syntax: (mirror: ad1,ad2) or (raidz: ad1,ad2), it is possible
to include the disk "ad1" into the zpool for this partition, using the raidz / mirror methods.
OpenPOWER on IntegriCloud