aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/pc-sysinstall/backend
diff options
context:
space:
mode:
authorJosh Paetzel <jpaetzel@FreeBSD.org>2011-09-19 05:12:53 +0000
committerJosh Paetzel <jpaetzel@FreeBSD.org>2011-09-19 05:12:53 +0000
commitc49e3f837c79e153327a25c98f368f212418c7f9 (patch)
tree1fec4b3768a98ffaf158f7aef4d80eae6d13b2ca /usr.sbin/pc-sysinstall/backend
parentf3ae23b34b2ed42463d05ee083c465c32bd044af (diff)
downloadsrc-c49e3f837c79e153327a25c98f368f212418c7f9.tar.gz
src-c49e3f837c79e153327a25c98f368f212418c7f9.zip
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)
Notes
Notes: svn path=/head/; revision=225657
Diffstat (limited to 'usr.sbin/pc-sysinstall/backend')
-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
9 files changed, 52 insertions, 34 deletions
diff --git a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
index e819d740dd28..5b3069558e39 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 c63f7afd7ecf..73c3eb4c179f 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 75b5a410bc72..5d32466e6a54 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 38cda791c2c6..7ee898cb3f1b 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 96ca49b900ed..d5edff10e3a0 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 4f96ca338d95..8b9d4180f61b 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 ce0db9b1f4e1..23630f7674a4 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 4987bf45c7f3..9a98ee2bf144 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 eeb6ce0049a7..2e16751bd626 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"