summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pc-sysinstall
diff options
context:
space:
mode:
authorjpaetzel <jpaetzel@FreeBSD.org>2011-03-27 16:57:54 +0000
committerjpaetzel <jpaetzel@FreeBSD.org>2011-03-27 16:57:54 +0000
commitc0b9051b174edd52b1c981a25a28d77d5133a049 (patch)
tree7685cacc260db6392774e2cc0fe2507f4afd24ba /usr.sbin/pc-sysinstall
parent79f5bd9d163ed51b54be37305ac97c975667db20 (diff)
downloadFreeBSD-src-c0b9051b174edd52b1c981a25a28d77d5133a049.zip
FreeBSD-src-c0b9051b174edd52b1c981a25a28d77d5133a049.tar.gz
Fix a syntax error in a little-used function.
Replace expr with $(()) Replace grep > /dev/null with grep -q Replace "$?" = "0" with $? -eq 0 in tests Consolidate export statements with variable assignment Replace tests for ! -z with -n Approved by: kib (mentor)
Diffstat (limited to 'usr.sbin/pc-sysinstall')
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh117
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-cleanup.sh42
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-disk.sh113
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-extractimage.sh52
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-ftp.sh11
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-installcomponents.sh2
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-installpackages.sh6
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-localize.sh40
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-mountoptical.sh5
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-networking.sh37
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-packages.sh24
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-parse.sh37
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-runcommands.sh12
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-unmount.sh2
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-upgrade.sh16
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions-users.sh48
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/functions.sh7
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/parseconfig.sh10
-rwxr-xr-xusr.sbin/pc-sysinstall/backend/startautoinstall.sh10
19 files changed, 283 insertions, 308 deletions
diff --git a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
index fceed33..2e413be 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh
@@ -33,14 +33,14 @@ check_for_enc_pass()
CURLINE="${1}"
get_next_cfg_line "${CFGF}" "${CURLINE}"
- echo ${VAL} | grep "^encpass=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
+ echo ${VAL} | grep -q "^encpass=" 2>/dev/null
+ if [ $? -eq 0 ] ; then
# Found a password, return it
get_value_from_string "${VAL}"
return
fi
- VAL="" ; export VAL
+ export VAL=""
return
};
@@ -51,17 +51,17 @@ get_fs_line_xvars()
ACTIVEDEV="${1}"
LINE="${2}"
- echo $LINE | grep ' (' >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
+ echo $LINE | grep -q ' (' 2>/dev/null
+ if [ $? -eq 0 ] ; then
# See if we are looking for ZFS specific options
- echo $LINE | grep '^ZFS' >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
+ echo $LINE | grep -q '^ZFS' 2>/dev/null
+ if [ $? -eq 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
+ echo $ZFSVARS | grep -qE "^(disk|file|mirror|raidz(1|2)?|spare|log|cache):" 2>/dev/null
+ if [ $? -eq 0 ] ; then
ZTYPE=`echo $ZFSVARS | cut -f1 -d:`
ZFSVARS=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"`
fi
@@ -79,8 +79,7 @@ get_fs_line_xvars()
fi # End of xtra-options block
# If we got here, set VAR to empty and export
- VAR=""
- export VAR
+ export VAR=""
return
};
@@ -94,12 +93,12 @@ setup_zfs_mirror_parts()
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
+ echo "$_zvars" | grep -q "${2}" 2>/dev/null
+ if [ $? -eq 0 ] ; then continue ; fi
if [ -z "$_zvars" ] ; then continue ; fi
is_disk "$_zvars" >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
+ if [ $? -eq 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
@@ -138,12 +137,12 @@ gen_glabel_name()
while
Z=1
do
- glabel status | grep "${NAME}${NUM}" >/dev/null 2>/dev/null
- if [ "$?" != "0" ]
+ glabel status | grep -q "${NAME}${NUM}" 2>/dev/null
+ if [ $? -ne 0 ]
then
break
else
- NUM="`expr ${NUM} + 1`"
+ NUM=$((NUM+1))
fi
if [ $NUM -gt $MAXNUM ]
@@ -154,8 +153,7 @@ gen_glabel_name()
done
- VAL="${NAME}${NUM}"
- export VAL
+ export VAL="${NAME}${NUM}"
};
# Function to setup partitions using gpart
@@ -180,8 +178,8 @@ setup_gpart_partitions()
while read line
do
# Check for data on this slice
- echo $line | grep "^${_dTag}-part=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q "^${_dTag}-part=" 2>/dev/null
+ if [ $? -eq 0 ]
then
FOUNDPARTS="0"
# Found a slice- entry, lets get the slice info
@@ -194,8 +192,8 @@ setup_gpart_partitions()
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" ]
+ echo ${FS} | grep -q ".eli" 2>/dev/null
+ if [ $? -eq 0 ]
then
FS="`echo ${FS} | cut -d '.' -f 1`"
ENC="ON"
@@ -210,9 +208,9 @@ setup_gpart_partitions()
# Check if the user tried to setup / as an encrypted partition
check_for_mount "${MNT}" "/"
- if [ "${?}" = "0" -a "${ENC}" = "ON" ]
+ if [ $? -eq 0 -a "${ENC}" = "ON" ]
then
- USINGENCROOT="0" ; export USINGENCROOT
+ export USINGENCROOT="0"
fi
# Now check that these values are sane
@@ -223,13 +221,13 @@ setup_gpart_partitions()
# Check that we have a valid size number
expr $SIZE + 1 >/dev/null 2>/dev/null
- if [ "$?" != "0" ]; then
+ if [ $? -ne 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
+ echo "$MNT" | grep -qe "^/" -e "^none" 2>/dev/null
+ if [ $? -ne 0 ]; then
exit_err "ERROR: The mount-point specified on $line is invalid"
fi
@@ -242,19 +240,19 @@ setup_gpart_partitions()
# Check if we found a valid root partition
check_for_mount "${MNT}" "/"
- if [ "${?}" = "0" ] ; then
- FOUNDROOT="1" ; export FOUNDROOT
+ if [ $? -eq 0 ] ; then
+ export FOUNDROOT="1"
if [ "${CURPART}" = "2" -a "$_pType" = "gpt" ] ; then
- FOUNDROOT="0" ; export FOUNDROOT
+ export FOUNDROOT="0"
fi
if [ "${CURPART}" = "1" -a "$_pType" = "mbr" ] ; then
- FOUNDROOT="0" ; export FOUNDROOT
+ export FOUNDROOT="0"
fi
fi
check_for_mount "${MNT}" "/boot"
- if [ "${?}" = "0" ] ; then
- USINGBOOTPART="0" ; export USINGBOOTPART
+ if [ $? -eq 0 ] ; then
+ export USINGBOOTPART="0"
if [ "${CURPART}" != "2" -a "${_pType}" = "gpt" ] ; then
exit_err "/boot partition must be first partition"
fi
@@ -280,8 +278,8 @@ setup_gpart_partitions()
XTRAOPTS="${VAR}"
# Check if using zfs mirror
- echo ${XTRAOPTS} | grep "mirror" >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
+ echo ${XTRAOPTS} | grep -q "mirror" 2>/dev/null
+ if [ $? -eq 0 ] ; then
if [ "${_pType}" = "gpt" ] ; then
XTRAOPTS=$(setup_zfs_mirror_parts "$XTRAOPTS" "${_pDisk}p${CURPART}")
else
@@ -325,10 +323,10 @@ setup_gpart_partitions()
# Clear out any headers
sleep 2
- dd if=/dev/zero of=${_pDisk}p${CURPART} count=2048 >/dev/null 2>/dev/null
+ dd if=/dev/zero of=${_pDisk}p${CURPART} count=2048 2>/dev/null
# If we have a enc password, save it as well
- if [ ! -z "${ENCPASS}" ] ; then
+ if [ -n "${ENCPASS}" ] ; then
echo "${ENCPASS}" >${PARTDIR}-enc/${_pDisk}p${CURPART}-encpass
fi
else
@@ -336,10 +334,10 @@ setup_gpart_partitions()
echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}:${IMAGE}" >${PARTDIR}/${_wSlice}${PARTLETTER}
# Clear out any headers
sleep 2
- dd if=/dev/zero of=${_wSlice}${PARTLETTER} count=2048 >/dev/null 2>/dev/null
+ dd if=/dev/zero of=${_wSlice}${PARTLETTER} count=2048 2>/dev/null
# If we have a enc password, save it as well
- if [ ! -z "${ENCPASS}" ] ; then
+ if [ -n "${ENCPASS}" ] ; then
echo "${ENCPASS}" >${PARTDIR}-enc/${_wSlice}${PARTLETTER}-encpass
fi
fi
@@ -347,11 +345,11 @@ setup_gpart_partitions()
# Increment our parts counter
if [ "$_pType" = "gpt" ] ; then
- CURPART="`expr ${CURPART} + 1`"
+ CURPART=$((CURPART+1))
# If this is a gpt partition, we can continue and skip the MBR part letter stuff
continue
else
- CURPART="`expr ${CURPART} + 1`"
+ CURPART=$((CURPART+1))
if [ "$CURPART" = "3" ] ; then CURPART="4" ; fi
fi
@@ -370,8 +368,8 @@ setup_gpart_partitions()
fi # End of subsection locating a slice in config
- echo $line | grep "^commitDiskLabel" >/dev/null 2>/dev/null
- if [ "$?" = "0" -a "${FOUNDPARTS}" = "0" ]
+ echo $line | grep -q "^commitDiskLabel" 2>/dev/null
+ if [ $? -eq 0 -a "${FOUNDPARTS}" = "0" ]
then
# If this is the boot disk, stamp the right gptboot
@@ -455,20 +453,17 @@ setup_disk_label()
done
# Setup some files which we'll be referring to
- LABELLIST="${TMPDIR}/workingLabels"
- export LABELLIST
+ export LABELLIST="${TMPDIR}/workingLabels"
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
+ export FOUNDROOT="-1"
# Check if we are using a /boot partition
- USINGBOOTPART="1"
- export USINGBOOTPART
+ export USINGBOOTPART="1"
# Set encryption on root check
- USINGENCROOT="1" ; export USINGENCROOT
+ export USINGENCROOT="1"
# Make the tmp directory where we'll store FS info & mount-points
rm -rf ${PARTDIR} >/dev/null 2>/dev/null
@@ -516,8 +511,8 @@ check_fstab_mbr()
then
PARTLETTER=`echo "$SLICE" | sed -E 's|^.+([a-h])$|\1|'`
- cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/$' >/dev/null 2>&1
- if [ "$?" = "0" ]
+ cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/$' 2>&1
+ if [ $? -eq 0 ]
then
if [ "${PARTLETTER}" = "a" ]
then
@@ -532,8 +527,8 @@ check_fstab_mbr()
export ROOTIMAGE
fi
- cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/boot$' >/dev/null 2>&1
- if [ "$?" = "0" ]
+ cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/boot$' 2>&1
+ if [ $? -eq 0 ]
then
if [ "${PARTLETTER}" = "a" ]
then
@@ -567,8 +562,8 @@ check_fstab_gpt()
then
PARTNUMBER=`echo "${SLICE}" | sed -E 's|^.+p([0-9]*)$|\1|'`
- cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/$' >/dev/null 2>&1
- if [ "$?" = "0" ]
+ cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/$' 2>&1
+ if [ $? -eq 0 ]
then
if [ "${PARTNUMBER}" = "2" ]
then
@@ -583,8 +578,8 @@ check_fstab_gpt()
export ROOTIMAGE
fi
- cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/boot$' >/dev/null 2>&1
- if [ "$?" = "0" ]
+ cat "${FSTAB}" | awk '{ print $2 }' | grep -qE '^/boot$' 2>&1
+ if [ $? -eq 0 ]
then
if [ "${PARTNUMBER}" = "2" ]
then
@@ -645,7 +640,7 @@ check_disk_layout()
do
F=1
mount ${slice} /mnt 2>/dev/null
- if [ "$?" != "0" ]
+ if [ $? -ne 0 ]
then
continue
fi
@@ -661,7 +656,7 @@ check_disk_layout()
F="$?"
fi
- if [ "${F}" = "0" ]
+ if [ ${F} -eq 0 ]
then
umount /mnt
break
diff --git a/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh b/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
index 7524692..ca06cb2 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh
@@ -46,27 +46,27 @@ zfs_cleanup_unmount()
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
+ cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q "vfs.root.mountfrom=" 2>/dev/null
+ if [ $? -ne 0 ] ; then
echo "vfs.root.mountfrom=\"zfs:${ZPOOLNAME}\"" >> ${FSMNT}/boot/loader.conf
fi
- FOUNDZFSROOT="${ZPOOLNAME}" ; export FOUNDZFSROOT
+ export FOUNDZFSROOT="${ZPOOLNAME}"
fi
done
FOUNDZFS="1"
fi
done
- if [ ! -z "${FOUNDZFS}" ]
+ if [ -n "${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" ]
+ cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'zfs_load="YES"' 2>/dev/null
+ if [ $? -ne 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" ]
+ cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep -q 'zfs_enable="YES"' 2>/dev/null
+ if [ $? -ne 0 ]
then
echo 'zfs_enable="YES"' >>${FSMNT}/etc/rc.conf
fi
@@ -172,7 +172,7 @@ setup_fstab()
# Figure out if we are using a glabel, or the raw name for this entry
- if [ ! -z "${PARTLABEL}" ]
+ if [ -n "${PARTLABEL}" ]
then
DEVICE="label/${PARTLABEL}"
else
@@ -190,7 +190,7 @@ setup_fstab()
# Set our ROOTFSTYPE for loader.conf if necessary
check_for_mount "${PARTMNT}" "/"
- if [ "$?" = "0" ] ; then
+ if [ $? -eq 0 ] ; then
if [ "${PARTFS}" = "ZFS" ] ; then
ROOTFSTYPE="zfs"
XPOOLNAME=$(get_zpool_name "${PART}")
@@ -263,12 +263,12 @@ setup_gmirror()
sleep 3
- NUM="`expr ${NUM} + 1`"
+ NUM=$((NUM+1))
done
- cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep 'geom_mirror_load="YES"' >/dev/null 2>/dev/null
- if [ "$?" != "0" ]
+ cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'geom_mirror_load="YES"' 2>/dev/null
+ if [ $? -ne 0 ]
then
echo 'geom_mirror_load="YES"' >>${FSMNT}/boot/loader.conf
fi
@@ -304,8 +304,8 @@ setup_geli_loading()
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" ]
+ cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'geom_eli_load="YES"' 2>/dev/null
+ if [ $? -ne 0 ]
then
echo 'geom_eli_load="YES"' >>${FSMNT}/boot/loader.conf
fi
@@ -360,8 +360,8 @@ 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" ]
+ cat ${FSMNT}/boot/loader.conf 2>/dev/null | grep -q 'geom_journal_load="YES"' 2>/dev/null
+ if [ $? -ne 0 ]
then
echo 'geom_journal_load="YES"' >>${FSMNT}/boot/loader.conf
fi
@@ -385,14 +385,14 @@ set_root_pw()
echo_log "Setting root password"
# Check if setting plaintext password
- if [ ! -z "${PW}" ] ; then
+ if [ -n "${PW}" ] ; then
echo "${PW}" > ${FSMNT}/.rootpw
run_chroot_cmd "cat /.rootpw | pw usermod root -h 0"
rc_halt "rm ${FSMNT}/.rootpw"
fi
# Check if setting encrypted password
- if [ ! -z "${ENCPW}" ] ; then
+ if [ -n "${ENCPW}" ] ; then
echo "${ENCPW}" > ${FSMNT}/.rootpw
run_chroot_cmd "cat /.rootpw | pw usermod root -H 0"
rc_halt "rm ${FSMNT}/.rootpw"
@@ -405,7 +405,7 @@ run_final_cleanup()
{
# Check if we need to run any gmirror setup
ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ if [ $? -eq 0 ]
then
# Lets setup gmirror now
setup_gmirror
@@ -413,7 +413,7 @@ run_final_cleanup()
# Check if we need to save any geli keys
ls ${GELIKEYDIR}/* >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ if [ $? -eq 0 ]
then
# Lets setup geli loading
setup_geli_loading
diff --git a/usr.sbin/pc-sysinstall/backend/functions-disk.sh b/usr.sbin/pc-sysinstall/backend/functions-disk.sh
index 0600428..75258a3 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-disk.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-disk.sh
@@ -32,7 +32,7 @@ is_disk()
{
for _dsk in `sysctl -n kern.disks`
do
- if [ "$_dsk" = "${1}" ] ; then return 0 ; fi
+ [ "$_dsk" = "${1}" ] && return 0
done
return 1
@@ -47,8 +47,8 @@ get_partition_sysid_mbr()
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
+ echo "$i" | grep -q "The data for partition" 2>/dev/null
+ if [ $? -eq 0 ] ; then
INPART="0"
PART="`echo ${i} | cut -d ' ' -f 5`"
if [ "$PART" = "$PARTNUM" ] ; then
@@ -58,8 +58,8 @@ get_partition_sysid_mbr()
# In the partition section
if [ "$INPART" = "1" ] ; then
- echo "$i" | grep "^sysid" >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
+ echo "$i" | grep -q "^sysid" 2>/dev/null
+ if [ $? -eq 0 ] ; then
SYSID="`echo ${i} | tr -s '\t' ' ' | cut -d ' ' -f 2`"
break
fi
@@ -69,8 +69,7 @@ get_partition_sysid_mbr()
done < ${TMPDIR}/disk-${DISK}
rm ${TMPDIR}/disk-${DISK}
- VAL="${SYSID}"
- export VAL
+ export VAL="${SYSID}"
};
# Get the partitions MBR label
@@ -82,8 +81,8 @@ get_partition_label_mbr()
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
+ echo "$i" | grep -q "The data for partition" 2>/dev/null
+ if [ $? -eq 0 ] ; then
INPART="0"
PART="`echo ${i} | cut -d ' ' -f 5`"
if [ "$PART" = "$PARTNUM" ] ; then
@@ -93,8 +92,8 @@ get_partition_label_mbr()
# In the partition section
if [ "$INPART" = "1" ] ; then
- echo "$i" | grep "^sysid" >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
+ echo "$i" | grep -q "^sysid" 2>/dev/null
+ if [ $? -eq 0 ] ; then
LABEL="`echo ${i} | tr -s '\t' ' ' | cut -d ',' -f 2-10`"
break
fi
@@ -104,8 +103,7 @@ get_partition_label_mbr()
done < ${TMPDIR}/disk-${DISK}
rm ${TMPDIR}/disk-${DISK}
- VAL="${LABEL}"
- export VAL
+ export VAL="${LABEL}"
};
# Get a GPT partitions label
@@ -125,8 +123,7 @@ get_partition_label_gpt()
done <${TMPDIR}/disk-${DISK}
rm ${TMPDIR}/disk-${DISK}
- VAL="${LABEL}"
- export VAL
+ export VAL="${LABEL}"
};
# Get a partitions startblock
@@ -146,8 +143,7 @@ get_partition_startblock()
done <${TMPDIR}/disk-${DISK}
rm ${TMPDIR}/disk-${DISK}
- VAL="${SB}"
- export VAL
+ export VAL="${SB}"
};
# Get a partitions blocksize
@@ -167,16 +163,15 @@ get_partition_blocksize()
done <${TMPDIR}/disk-${DISK}
rm ${TMPDIR}/disk-${DISK}
- VAL="${BS}"
- export VAL
+ export VAL="${BS}"
};
# 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
+ if [ $? -ne 0 ] ; then
+ export VAL=""
return
fi
@@ -198,35 +193,35 @@ get_disk_partitions()
fi
done
- VAL="${RSLICES}" ; export VAL
+ export VAL="${RSLICES}"
};
# 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
+ export VAL="${cyl}"
};
# 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
+ export VAL="${sec}"
};
# 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
+ export VAL="${head}"
};
# 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`
- VAL="${mediasize}" ; export VAL
+ export VAL="${mediasize}"
};
# Function which exports all zpools, making them safe to overwrite potentially
@@ -288,8 +283,8 @@ stop_all_gmirror()
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" ]
+ gmirror list | grep -q "Name: ${DISK}" 2>/dev/null
+ if [ $? -eq 0 ]
then
echo_log "Stopping mirror $gprov $DISK"
rc_nohalt "gmirror remove $gprov $DISK"
@@ -306,8 +301,8 @@ stop_all_geli()
for i in `ls ${_geld}*`
do
- echo $i | grep '.eli' >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $i | grep -q '.eli' 2>/dev/null
+ if [ $? -eq 0 ]
then
echo_log "Detaching GELI on ${i}"
rc_halt "geli detach ${i}"
@@ -335,8 +330,8 @@ 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" ]
+ echo $line | grep -q "^disk${disknum}=" 2>/dev/null
+ if [ $? -eq 0 ]
then
# Found a disk= entry, lets get the disk we are working on
@@ -362,8 +357,8 @@ setup_disk_slice()
fi
# Lets look if this device will be mirrored on another disk
- echo $line | grep "^mirror=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q "^mirror=" 2>/dev/null
+ if [ $? -eq 0 ]
then
# Found a disk= entry, lets get the disk we are working on
@@ -379,8 +374,8 @@ setup_disk_slice()
fi
# Lets see if we have been given a mirror balance choice
- echo $line | grep "^mirrorbal=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q "^mirrorbal=" 2>/dev/null
+ if [ $? -eq 0 ]
then
# Found a disk= entry, lets get the disk we are working on
@@ -389,8 +384,8 @@ setup_disk_slice()
MIRRORBAL="$VAL"
fi
- echo $line | grep "^partition=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q "^partition=" 2>/dev/null
+ if [ $? -eq 0 ]
then
# Found a partition= entry, lets read / set it
get_value_from_string "${line}"
@@ -413,7 +408,7 @@ setup_disk_slice()
then
LASTSLICE="1"
else
- LASTSLICE="`expr $LASTSLICE + 1`"
+ LASTSLICE=$((LASTSLICE+1))
fi
if [ $LASTSLICE -gt 4 ]
@@ -425,8 +420,8 @@ setup_disk_slice()
fi
# Check if we have an image file defined
- echo $line | grep "^image=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
+ echo $line | grep -q "^image=" 2>/dev/null
+ if [ $? eq 0 ] ; then
# Found an image= entry, lets read / set it
get_value_from_string "${line}"
strip_white_space "$VAL"
@@ -437,8 +432,8 @@ setup_disk_slice()
fi
# Check if we have a partscheme specified
- echo $line | grep "^partscheme=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
+ echo $line | grep -q "^partscheme=" 2>/dev/null
+ if [ $? -eq 0 ] ; then
# Found a partscheme= entry, lets read / set it
get_value_from_string "${line}"
strip_white_space "$VAL"
@@ -448,8 +443,8 @@ setup_disk_slice()
fi
fi
- echo $line | grep "^bootManager=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q "^bootManager=" 2>/dev/null
+ if [ $? -eq 0 ]
then
# Found a bootManager= entry, lets read /set it
get_value_from_string "${line}"
@@ -457,8 +452,8 @@ setup_disk_slice()
BMANAGER="$VAL"
fi
- echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q "^commitDiskPart" 2>/dev/null
+ if [ $? -eq 0 ]
then
# Found our flag to commit this disk setup / lets do sanity check and do it
if [ ! -z "${DISK}" -a ! -z "${PTYPE}" ]
@@ -520,7 +515,7 @@ setup_disk_slice()
fi
# Save any mirror config
- if [ ! -z "$MIRRORDISK" ]
+ if [ -n "$MIRRORDISK" ]
then
# Default to round-robin if the user didn't specify
if [ -z "$MIRRORBAL" ]
@@ -532,7 +527,7 @@ setup_disk_slice()
# Increment our disk counter to look for next disk and unset
unset BMANAGER PTYPE DISK MIRRORDISK MIRRORBAL PSCHEME IMAGE
- disknum="`expr $disknum + 1`"
+ disknum=$((disknum+1))
else
exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!"
fi
@@ -548,7 +543,7 @@ 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" ]
+ if [ $? -eq 0 ]
then
cd /dev
for i in `ls ${_gdsk}*.journal`
@@ -569,7 +564,7 @@ clear_backup_gpt_table()
# Make sure this is a valid number
is_num "${dSize}" >/dev/null 2>/dev/null
- if [ "$?" != "0" ] ; then return ; fi
+ [ $? -ne 0 ] && return
# Die backup label, DIE
echo_log "Clearing gpt backup table location on disk"
@@ -697,7 +692,7 @@ run_gpart_full()
run_gpart_slice()
{
DISK=$1
- if [ ! -z "$2" ]
+ if [ -n "$2" ]
then
BMANAGER="$2"
fi
@@ -757,7 +752,7 @@ run_gpart_free()
{
DISK=$1
SLICENUM=$2
- if [ ! -z "$3" ]
+ if [ -n "$3" ]
then
BMANAGER="$3"
fi
@@ -770,7 +765,7 @@ run_gpart_free()
# 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
+ if [ $? -ne 0 -a "$SLICENUM" = "1" ] ; then
echo_log "Initializing disk, no existing MBR setup"
rc_halt "gpart create -s mbr ${DISK}"
fi
@@ -781,12 +776,12 @@ run_gpart_free()
startblock="63"
else
# Lets figure out where the prior slice ends
- checkslice="`expr ${slicenum} - 1`"
+ checkslice=$((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}`"
+ startblock=$((sblk+blksiz))
fi
# No slice after the new slice, lets figure out the free space remaining and use it
@@ -803,12 +798,12 @@ run_gpart_free()
sec="${VAL}"
# Multiply them all together to get our total blocks
- totalblocks="`expr ${cyl} \* ${head}`"
- totalblocks="`expr ${totalblocks} \* ${sec}`"
+ totalblocks=$((cyl*head))
+ totalblocks=$((totalblocks*sec))
# Now set the ending block to the total disk block size
- sizeblock="`expr ${totalblocks} - ${startblock}`"
+ sizeblock=$((totalblocks-startblock))
# Install new partition setup
echo_log "Running gpart on ${DISK}"
diff --git a/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh b/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh
index f9be5ea..75b5a41 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh
@@ -59,7 +59,7 @@ start_extract_uzip_tar()
MDDEVICE=`mdconfig -a -t vnode -o readonly -f ${INSFILE}`
mkdir -p ${FSMNT}.uzip
mount -r /dev/${MDDEVICE}.uzip ${FSMNT}.uzip
- if [ "$?" != "0" ]
+ if [ $? -ne 0 ]
then
exit_err "ERROR: Failed mounting the ${INSFILE}"
fi
@@ -67,7 +67,7 @@ start_extract_uzip_tar()
# 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" ]
+ if [ $? -ne 0 ]
then
cd /
echo "TAR failure occurred:" >>${LOGOUT}
@@ -84,7 +84,7 @@ start_extract_uzip_tar()
;;
tar)
tar -xpv -C ${FSMNT} -f ${INSFILE} ${TAROPTS} >&1 2>&1
- if [ "$?" != "0" ]
+ if [ $? -ne 0 ]
then
exit_err "ERROR: Failed extracting the tar image"
fi
@@ -127,7 +127,7 @@ start_extract_split()
then
echo_log "Extracting" `basename ${dir}`
echo "y" | sh install.sh >/dev/null
- if [ "$?" != "0" ]
+ if [ $? -ne 0 ]
then
exit_err "ERROR: Failed extracting ${dir}"
fi
@@ -143,7 +143,7 @@ start_extract_split()
then
echo_log "Extracting" `basename ${KERNELS}`
echo "y" | sh install.sh generic >/dev/null
- if [ "$?" != "0" ]
+ if [ $? -ne 0 ]
then
exit_err "ERROR: Failed extracting ${KERNELS}"
fi
@@ -160,7 +160,7 @@ start_extract_split()
then
echo_log "Extracting" `basename ${SOURCE}`
echo "y" | sh install.sh all >/dev/null
- if [ "$?" != "0" ]
+ if [ $? -ne 0 ]
then
exit_err "ERROR: Failed extracting ${SOURCE}"
fi
@@ -202,7 +202,7 @@ fetch_install_file()
fetch_file "${FTPPATH}/${INSFILE}.md5" "${OUTFILE}.md5" "0"
# Done fetching, now reset the INSFILE to our downloaded archived
- INSFILE="${OUTFILE}" ; export INSFILE
+ export INSFILE="${OUTFILE}"
};
@@ -244,7 +244,7 @@ fetch_split_files()
NETRC="${OUTFILE}/.netrc"
- cat<<EOF>"${NETRC}"
+ cat <<EOF >"${NETRC}"
machine ${FTPHOST}
login anonymous
password anonymous
@@ -255,14 +255,14 @@ EOF
for d in ${DIRS}
do
- cat<<EOF>>"${NETRC}"
+ cat <<EOF >>"${NETRC}"
cd ${FTPDIR}/${d}
lcd ${OUTFILE}/${d}
mreget *
EOF
done
- cat<<EOF>>"${NETRC}"
+ cat <<EOF >>"${NETRC}"
bye
@@ -272,7 +272,7 @@ EOF
echo "$ INSTALL" | ftp -N "${NETRC}" "${FTPHOST}"
# Done fetching, now reset the INSFILE to our downloaded archived
- INSFILE="${OUTFILE}" ; export INSFILE
+ export INSFILE="${OUTFILE}"
}
# Function which does the rsync download from the server specified in cfg
@@ -283,27 +283,27 @@ start_rsync_copy()
if [ -z "${VAL}" ]; then
exit_err "ERROR: rsyncPath is unset! Please check your config and try again."
fi
- RSYNCPATH="${VAL}" ; export RSYNCPATH
+ export RSYNCPATH="${VAL}"
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
+ export RSYNCHOST="${VAL}"
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
+ export RSYNCUSER="${VAL}"
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
+ export RSYNCPORT="${VAL}"
- COUNT="1"
+ COUNT=1
while
z=1
do
@@ -317,14 +317,14 @@ start_rsync_copy()
--rsync-path="rsync --fake-super" \
-e "ssh -p ${RSYNCPORT}" \
${RSYNCUSER}@${RSYNCHOST}:${RSYNCPATH}/./ ${FSMNT}
- if [ "$?" != "0" ]
+ if [ $? -ne 0 ]
then
echo "Rsync failed! Tries: ${COUNT}"
else
break
fi
- COUNT="`expr ${COUNT} + 1`"
+ COUNT=$((COUNT+1))
done
};
@@ -339,8 +339,8 @@ start_image_install()
# 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" ]
+ echo $line | grep -q "^disk0=" 2>/dev/null
+ if [ $? -eq 0 ]
then
# Found a disk= entry, lets get the disk we are working on
get_value_from_string "${line}"
@@ -348,11 +348,11 @@ start_image_install()
DISK="$VAL"
fi
- echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q "^commitDiskPart" 2>/dev/null
+ if [ $? -eq 0 ]
then
# Found our flag to commit this disk setup / lets do sanity check and do it
- if [ ! -z "${DISK}" ]
+ if [ -n "${DISK}" ]
then
# Write the image
@@ -376,9 +376,9 @@ init_extraction()
# Figure out what file we are using to install from via the config
get_value_from_cfg installFile
- if [ ! -z "${VAL}" ]
+ if [ -n "${VAL}" ]
then
- INSFILE="${VAL}" ; export INSFILE
+ export INSFILE="${VAL}"
else
# If no installFile specified, try our defaults
if [ "$INSTALLTYPE" = "FreeBSD" ]
@@ -407,7 +407,7 @@ init_extraction()
dvd|usb)
# Lets start by mounting the disk
opt_mount
- if [ ! -z "${INSDIR}" ]
+ if [ -n "${INSDIR}" ]
then
INSDIR="${CDMNT}/${INSDIR}" ; export INSDIR
start_extract_split
diff --git a/usr.sbin/pc-sysinstall/backend/functions-ftp.sh b/usr.sbin/pc-sysinstall/backend/functions-ftp.sh
index db230f3..6116fce 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-ftp.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-ftp.sh
@@ -292,8 +292,7 @@ get_ftp_mirror()
MIRROR=`cat "${CONFDIR}/mirrors.conf"`
fi
- VAL="${MIRROR}"
- export VAL
+ export VAL="${MIRROR}"
};
@@ -303,9 +302,7 @@ get_ftpHost()
ftpPath="$VAL"
ftpHost=`echo "${ftpPath}" | sed -E 's|^(ftp://)([^/]*)(.*)|\2|'`
- VAL="${ftpHost}"
-
- export VAL
+ export VAL="${ftpHost}"
};
get_ftpDir()
@@ -314,9 +311,7 @@ get_ftpDir()
ftpPath="$VAL"
ftpDir=`echo "${ftpPath}" | sed -E 's|^(ftp://)([^/]*)(.*)|\3|'`
- VAL="${ftpDir}"
-
- export VAL
+ export VAL="${ftpDir}"
};
get_ftp_mirrors()
diff --git a/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh b/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh
index f133e30..c46c9c5 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh
@@ -140,7 +140,7 @@ install_components()
{
# First, lets check and see if we even have any optional modules
get_value_from_cfg installComponents
- if [ ! -z "${VAL}" ]
+ if [ -n "${VAL}" ]
then
# Lets start by cleaning up the string and getting it ready to parse
strip_white_space ${VAL}
diff --git a/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh b/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh
index 3e0a4ba..7572efb 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-installpackages.sh
@@ -36,8 +36,8 @@ determine_package_dependencies()
local PKGNAME="${1}"
local DEPFILE="${2}"
- grep "${PKGNAME}" "${DEPFILE}" >/dev/null
- if [ "$?" -ne "0" ]
+ grep -q "${PKGNAME}" "${DEPFILE}"
+ if [ $? -ne 0 ]
then
echo "${PKGNAME}" >> "${DEPFILE}"
get_package_dependencies "${PKGNAME}" "1"
@@ -78,7 +78,7 @@ install_packages()
{
# First, lets check and see if we even have any packages to install
get_value_from_cfg installPackages
- if [ ! -z "${VAL}" ]
+ if [ -n "${VAL}" ]
then
HERE=`pwd`
rc_nohalt "mkdir -p ${FSMNT}/${PKGTMPDIR}"
diff --git a/usr.sbin/pc-sysinstall/backend/functions-localize.sh b/usr.sbin/pc-sysinstall/backend/functions-localize.sh
index d7508d4..38cda79 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-localize.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-localize.sh
@@ -64,7 +64,7 @@ localize_x_desktops() {
##########################################################################
# See if GDM is enabled and customize its lang
- cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep "gdm_enable=\"YES\"" >/dev/null 2>/dev/null
+ cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep -q "gdm_enable=\"YES\"" 2>/dev/null
if [ "$?" = "0" ] ; then
echo "gdm_lang=\"${LOCALE}.UTF-8\"" >> ${FSMNT}/etc/rc.conf
fi
@@ -192,7 +192,7 @@ localize_key_layout()
;;
esac
- if [ ! -z "${KEYLAYOUT_CONSOLE}" ]
+ if [ -n "${KEYLAYOUT_CONSOLE}" ]
then
echo "keymap=\"${KEYLAYOUT_CONSOLE}\"" >>${FSMNT}/etc/rc.conf
fi
@@ -214,10 +214,10 @@ localize_prune_langs()
# Create the script to do uninstalls
echo '#!/bin/sh
- for i in `pkg_info | grep "kde-l10n" | cut -d " " -f 1`
+ for i in `pkg_info -xEI kde-l10n`
do
echo "$i" | grep "${KEEPLANG}-kde"
- if [ "$?" != "0" ] ; then
+ if [ $? -ne 0 ] ; then
pkg_delete ${i}
fi
done
@@ -439,15 +439,15 @@ 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" ]
+ cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep -q 'ntpd_enable="YES"' 2>/dev/null
+ if [ $? -ne 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" ]
+ cat ${FSMNT}/etc/rc.conf 2>/dev/null | grep -q 'ntpd_enable="YES"' 2>/dev/null
+ if [ $? -ne 0 ]
then
sed -i.bak 's|ntpd_enable="YES"||g' ${FSMNT}/etc/rc.conf
fi
@@ -464,8 +464,8 @@ run_localize()
while read line
do
# Check if we need to do any localization
- echo $line | grep "^localizeLang=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q "^localizeLang=" 2>/dev/null
+ if [ $? -eq 0 ]
then
# Set our country / lang / locale variables
@@ -487,37 +487,37 @@ run_localize()
fi
# Check if we need to do any keylayouts
- echo $line | grep "^localizeKeyLayout=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
+ echo $line | grep -q "^localizeKeyLayout=" 2>/dev/null
+ if [ $? -eq 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
+ echo $line | grep -q "^localizeKeyModel=" 2>/dev/null
+ if [ $? -eq 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
+ echo $line | grep -q "^localizeKeyVariant=" 2>/dev/null
+ if [ $? -eq 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
+ echo $line | -q grep "^timeZone=" 2>/dev/null
+ if [ $? -eq 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
+ echo $line | grep -q "^enableNTP=" 2>/dev/null
+ if [ $? -eq 0 ] ; then
get_value_from_string "$line"
set_ntp "$VAL"
fi
diff --git a/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh b/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh
index 9cf3a63..4a15b81 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh
@@ -60,8 +60,8 @@ opt_mount()
# Start by checking if we already have a cd mounted at CDMNT
- mount | grep "${CDMNT} " >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ mount | grep -q "${CDMNT} " 2>/dev/null
+ if [ $? -eq 0 ]
then
if [ -e "${CDMNT}/${INSFILE}" ]
then
@@ -150,4 +150,3 @@ opt_umount()
{
/sbin/umount ${CDMNT} >/dev/null 2>/dev/null
};
-
diff --git a/usr.sbin/pc-sysinstall/backend/functions-networking.sh b/usr.sbin/pc-sysinstall/backend/functions-networking.sh
index 419bd3f..d12a9cc 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-networking.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-networking.sh
@@ -45,8 +45,8 @@ Type=Application" > ${FSMNT}/usr/share/skel/.kde4/Autostart/tray-${NIC}.desktop
check_is_wifi()
{
NIC="$1"
- ifconfig ${NIC} | grep "802.11" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ ifconfig ${NIC} | grep -q "802.11" 2>/dev/null
+ if [ $? -eq 0 ]
then
return 0
else
@@ -66,15 +66,15 @@ get_first_wired_nic()
do
NIC="`echo $line | cut -d ':' -f 1`"
check_is_wifi ${NIC}
- if [ "$?" != "0" ]
+ if [ $? -ne 0 ]
then
- VAL="${NIC}" ; export VAL
+ export VAL="${NIC}"
return
fi
done < ${TMPDIR}/.niclist
fi
- VAL="" ; export VAL
+ export VAL=""
return
};
@@ -95,14 +95,14 @@ enable_dhcp_all()
DESC="`echo $line | cut -d ':' -f 2`"
echo_log "Setting $NIC to DHCP on the system."
check_is_wifi ${NIC}
- if [ "$?" = "0" ]
+ if [ $? -eq 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`"
+ WLANCOUNT=$((WLANCOUNT+1))
else
echo "ifconfig_${NIC}=\"DHCP\"" >>${FSMNT}/etc/rc.conf
CNIC="${NIC}"
@@ -144,7 +144,7 @@ save_manual_nic()
# Check if we have a netmask to set
get_value_from_cfg netSaveMask
NETMASK="${VAL}"
- if [ ! -z "${NETMASK}" ]
+ if [ -n "${NETMASK}" ]
then
IFARGS="${IFARGS} netmask ${NETMASK}"
fi
@@ -156,7 +156,7 @@ save_manual_nic()
# Check if we have a default router to set
get_value_from_cfg netSaveDefaultRouter
NETROUTE="${VAL}"
- if [ ! -z "${NETROUTE}" ]
+ if [ -n "${NETROUTE}" ]
then
echo "defaultrouter=\"${NETROUTE}\"" >>${FSMNT}/etc/rc.conf
fi
@@ -164,7 +164,7 @@ save_manual_nic()
# Check if we have a nameserver to enable
get_value_from_cfg netSaveNameServer
NAMESERVER="${VAL}"
- if [ ! -z "${NAMESERVER}" ]
+ if [ -n "${NAMESERVER}" ]
then
echo "nameserver ${NAMESERVER}" >${FSMNT}/etc/resolv.conf
fi
@@ -174,8 +174,8 @@ save_manual_nic()
# 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
+ ifconfig ${1} | grep -q "status: active" 2>/dev/null
+ if [ $? -eq 0 ] ; then
return 0
else
return 1
@@ -195,12 +195,12 @@ enable_auto_dhcp()
DESC="`echo $line | cut -d ':' -f 2`"
is_nic_active "${NIC}"
- if [ "$?" = "0" ] ; then
+ if [ $? -eq 0 ] ; then
echo_log "Trying DHCP on $NIC $DESC"
dhclient ${NIC} >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
+ if [ $? -eq 0 ] ; then
# Got a valid DHCP IP, we can return now
- WRKNIC="$NIC" ; export WRKNIC
+ export WRKNIC="$NIC"
return 0
fi
fi
@@ -242,7 +242,7 @@ enable_manual_nic()
# Check if we have a netmask to set
get_value_from_cfg netMask
NETMASK="${VAL}"
- if [ ! -z "${NETMASK}" ]
+ if [ -n "${NETMASK}" ]
then
rc_halt "ifconfig ${NIC} netmask ${NETMASK}"
fi
@@ -250,7 +250,7 @@ enable_manual_nic()
# Check if we have a default router to set
get_value_from_cfg netDefaultRouter
NETROUTE="${VAL}"
- if [ ! -z "${NETROUTE}" ]
+ if [ -n "${NETROUTE}" ]
then
rc_halt "route add default ${NETROUTE}"
fi
@@ -258,7 +258,7 @@ enable_manual_nic()
# Check if we have a nameserver to enable
get_value_from_cfg netNameServer
NAMESERVER="${VAL}"
- if [ ! -z "${NAMESERVER}" ]
+ if [ -n "${NAMESERVER}" ]
then
echo "nameserver ${NAMESERVER}" >/etc/resolv.conf
fi
@@ -309,4 +309,3 @@ save_networking_install()
fi
};
-
diff --git a/usr.sbin/pc-sysinstall/backend/functions-packages.sh b/usr.sbin/pc-sysinstall/backend/functions-packages.sh
index f517250..c426778 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-packages.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-packages.sh
@@ -144,23 +144,23 @@ parse_package_index()
for part in ${line}
do
- if [ "${i}" -eq "0" ]
+ if [ ${i} -eq 0 ]
then
PKGNAME="${part}"
- elif [ "${i}" -eq "1" ]
+ elif [ ${i} -eq 1 ]
then
PACKAGE=`basename "${part}"`
- elif [ "${i}" -eq "3" ]
+ elif [ ${i} -eq 3 ]
then
DESC="${part}"
- elif [ "${i}" -eq "6" ]
+ elif [ ${i} -eq 6 ]
then
CATEGORY=`echo "${part}" | cut -f1 -d' '`
- elif [ "${i}" -eq "8" ]
+ elif [ ${i} -eq 8 ]
then
DEPS="${part}"
fi
@@ -235,7 +235,7 @@ get_package_dependencies()
INDEX_FILE="${PKGDIR}/INDEX.deps"
REGEX="^${PACKAGE}|"
- if [ "${LONG}" -ne "0" ]
+ if [ ${LONG} -ne 0 ]
then
REGEX="^.*|${PACKAGE}|"
fi
@@ -243,8 +243,7 @@ get_package_dependencies()
LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null`
DEPS=`echo "${LINE}"|cut -f3 -d'|'`
- VAL="${DEPS}"
- export VAL
+ export VAL="${DEPS}"
if [ -z "${VAL}" ]
then
@@ -265,8 +264,7 @@ get_package_name()
LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null`
NAME=`echo "${LINE}"|cut -f2 -d'|'`
- VAL="${NAME}"
- export VAL
+ export VAL="${NAME}"
if [ -z "${VAL}" ]
then
@@ -287,8 +285,7 @@ get_package_short_name()
LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null`
NAME=`echo "${LINE}"|cut -f1 -d'|'`
- VAL="${NAME}"
- export VAL
+ export VAL="${NAME}"
if [ -z "${VAL}" ]
then
@@ -307,8 +304,7 @@ get_package_category()
LINE=`grep "|${PACKAGE}|" "${INDEX_FILE}" 2>/dev/null`
NAME=`echo "${LINE}"|cut -f1 -d'|'`
- VAL="${NAME}"
- export VAL
+ export VAL="${NAME}"
if [ -z "${VAL}" ]
then
diff --git a/usr.sbin/pc-sysinstall/backend/functions-parse.sh b/usr.sbin/pc-sysinstall/backend/functions-parse.sh
index 11bba10..4f96ca3 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-parse.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-parse.sh
@@ -31,10 +31,9 @@
# which gets the value of a setting in the provided line
get_value_from_string()
{
- if [ ! -z "${1}" ]
+ if [ -n "${1}" ]
then
- VAL="`echo ${1} | cut -d '=' -f 2`"
- export VAL
+ export VAL="`echo ${1} | cut -d '=' -f 2`"
else
echo "Error: Did we forgot to supply a string to parse?"
exit 1
@@ -44,10 +43,9 @@ get_value_from_string()
# Get the value from the cfg file including spaces
get_value_from_cfg_with_spaces()
{
- if [ ! -z "${1}" ]
+ if [ -n "${1}" ]
then
- VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2`
- export VAL
+ export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2`
else
exit_err "Error: Did we forgot to supply a setting to grab?"
fi
@@ -57,10 +55,9 @@ get_value_from_cfg_with_spaces()
# Get the value from the cfg file
get_value_from_cfg()
{
- if [ ! -z "${1}" ]
+ if [ -n "${1}" ]
then
- VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '`
- export VAL
+ export VAL=`grep "^${1}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '`
else
exit_err "Error: Did we forgot to supply a setting to grab?"
fi
@@ -70,7 +67,7 @@ get_value_from_cfg()
# 1 = setting we are checking, 2 = list of valid values
if_check_value_exists()
{
- if [ ! -z "${1}" -a ! -z "${2}" ]
+ if [ -n "${1}" -a -n "${2}" ]
then
# Get the first occurance of the setting from the config, strip out whitespace
@@ -104,7 +101,7 @@ if_check_value_exists()
# 1 = setting we are checking, 2 = list of valid values
check_value()
{
- if [ ! -z "${1}" -a ! -z "${2}" ]
+ if [ -n "${1}" -a -n "${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 ' '`
@@ -129,12 +126,12 @@ check_value()
# 1 = values to confirm exist
file_sanity_check()
{
- if [ ! -z "$CFGF" -a ! -z "$1" ]
+ if [ -n "$CFGF" -a -n "$1" ]
then
for i in $1
do
- grep "^${i}=" $CFGF >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ grep -q "^${i}=" $CFGF 2>/dev/null
+ if [ $? -eq 0 ]
then
LN=`grep "^${i}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '`
if [ -z "${LN}" ]
@@ -173,11 +170,11 @@ merge_config()
while read newline
do
- echo ${newline} | grep "^#" >/dev/null 2>/dev/null
- if [ "$?" != "0" ] ; then
+ echo ${newline} | grep -q "^#" 2>/dev/null
+ if [ $? -ne 0 ] ; then
VAL="`echo ${newline} | cut -d '=' -f 1`"
- cat ${OLDCFG} | grep ${VAL} >/dev/null 2>/dev/null
- if [ "$?" != "0" ] ; then
+ cat ${OLDCFG} | grep -q ${VAL} 2>/dev/null
+ if [ $? -ne 0 ] ; then
if [ "${FOUNDMERGE}" = "NO" ] ; then
echo "" >> ${FINALCFG}
echo "# Auto-merged values from newer ${NEWCFG}" >> ${FINALCFG}
@@ -219,7 +216,7 @@ get_next_cfg_line()
while read line
do
if [ "$FOUND" = "0" ] ; then
- VAL="$line" ; export VAL
+ export VAL="$line"
return
fi
if [ "$line" = "${CURLINE}" ] ; then
@@ -228,5 +225,5 @@ get_next_cfg_line()
done <${CURFILE}
# Got here, couldn't find this line or at end of file, set VAL to ""
- VAL="" ; export VAL
+ export VAL=""
};
diff --git a/usr.sbin/pc-sysinstall/backend/functions-runcommands.sh b/usr.sbin/pc-sysinstall/backend/functions-runcommands.sh
index fccc00a..b364823 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-runcommands.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-runcommands.sh
@@ -82,24 +82,24 @@ run_commands()
while read line
do
# Check if we need to run any chroot command
- echo $line | grep ^runCommand= >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q ^runCommand= 2>/dev/null
+ if [ $? -eq 0 ]
then
get_value_from_string "$line"
run_chroot_cmd "$VAL"
fi
# Check if we need to run any chroot script
- echo $line | grep ^runScript= >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q ^runScript= 2>/dev/null
+ if [ $? -eq 0 ]
then
get_value_from_string "$line"
run_chroot_script "$VAL"
fi
# Check if we need to run any chroot command
- echo $line | grep ^runExtCommand= >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q ^runExtCommand= 2>/dev/null
+ if [ $? -eq 0 ]
then
get_value_from_string "$line"
run_ext_cmd "$VAL"
diff --git a/usr.sbin/pc-sysinstall/backend/functions-unmount.sh b/usr.sbin/pc-sysinstall/backend/functions-unmount.sh
index aaf8b68..5e80985 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-unmount.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-unmount.sh
@@ -143,7 +143,7 @@ unmount_all_filesystems()
# Check if we need to run any gmirror syncing
ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ if [ $? -eq 0 ]
then
# Lets start syncing now
start_gmirror_sync
diff --git a/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh b/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh
index e7250f7..f191e6f 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh
@@ -42,7 +42,7 @@ mount_target_slice()
if [ -e "/dev/${MPART}" ] ; then
rc_nohalt "mount /dev/${MPART} ${FSMNT}"
- if [ "$?" != "0" ] ; then
+ if [ $? -ne 0 ] ; then
# Check if we have ZFS tank name
rc_halt "mount -t zfs ${MPART} ${FSMNT}"
fi
@@ -58,7 +58,7 @@ mount_target_slice()
zfs mount -a
# Mount all the fstab goodies on disk
- chroot ${FSMNT} /sbin/mount -a -t nolinprocfs >>${LOGOUT} 2>>${LOGOUT
+ chroot ${FSMNT} /sbin/mount -a -t nolinprocfs >>${LOGOUT} 2>>${LOGOUT}
chroot ${FSMNT} umount /proc >/dev/null 2>/dev/null
chroot ${FSMNT} umount /compat/linux/proc >/dev/null 2>/dev/null
@@ -80,7 +80,7 @@ mount_target_slice()
then
echo_log "Removing old packages, this may take a while... Please wait..."
echo '#!/bin/sh
-for i in `pkg_info -E \*`
+for i in `pkg_info -aE`
do
echo "Uninstalling package: ${i}"
pkg_delete -f ${i} >/dev/null 2>/dev/null
@@ -116,8 +116,8 @@ mount_upgrade()
# 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" ]
+ echo $line | grep -q "^disk0=" 2>/dev/null
+ if [ $? -eq 0 ]
then
# Found a disk= entry, lets get the disk we are working on
@@ -126,11 +126,11 @@ mount_upgrade()
DISK="$VAL"
fi
- echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q "^commitDiskPart" 2>/dev/null
+ if [ $? -eq 0 ]
then
# Found our flag to commit this disk setup / lets do sanity check and do it
- if [ ! -z "${DISK}" ]
+ if [ -n "${DISK}" ]
then
# Start mounting this slice
diff --git a/usr.sbin/pc-sysinstall/backend/functions-users.sh b/usr.sbin/pc-sysinstall/backend/functions-users.sh
index 0288ba9..bf1a72f 100755
--- a/usr.sbin/pc-sysinstall/backend/functions-users.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions-users.sh
@@ -35,7 +35,7 @@
check_autologin()
{
get_value_from_cfg autoLoginUser
- if [ ! -z "${VAL}" -a "${INSTALLTYPE}" = "PCBSD" ]
+ if [ -n "${VAL}" -a "${INSTALLTYPE}" = "PCBSD" ]
then
AUTOU="${VAL}"
# Add the auto-login user line
@@ -72,77 +72,77 @@ setup_users()
while read line
do
- echo $line | grep "^userName=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q "^userName=" 2>/dev/null
+ if [ $? -eq 0 ]
then
get_value_from_string "${line}"
USERNAME="$VAL"
fi
- echo $line | grep "^userComment=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q "^userComment=" 2>/dev/null
+ if [ $? -eq 0 ]
then
get_value_from_string "${line}"
USERCOMMENT="$VAL"
fi
- echo $line | grep "^userPass=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q "^userPass=" 2>/dev/null
+ if [ $? -eq 0 ]
then
get_value_from_string "${line}"
USERPASS="$VAL"
fi
- echo $line | grep "^userEncPass=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q "^userEncPass=" 2>/dev/null
+ if [ $? -eq 0 ]
then
get_value_from_string "${line}"
USERENCPASS="$VAL"
fi
- echo $line | grep "^userShell=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q "^userShell=" 2>/dev/null
+ if [ $? -eq 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" ]
+ echo $line | grep -q "^userHome=" 2>/dev/null
+ if [ $? -eq 0 ]
then
get_value_from_string "${line}"
USERHOME="$VAL"
fi
- echo $line | grep "^userGroups=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q "^userGroups=" 2>/dev/null
+ if [ $? -eq 0 ]
then
get_value_from_string "${line}"
USERGROUPS="$VAL"
fi
- echo $line | grep "^commitUser" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
+ echo $line | grep -q "^commitUser" 2>/dev/null
+ if [ $? -eq 0 ]
then
# Found our flag to commit this user, lets check and do it
- if [ ! -z "${USERNAME}" ]
+ if [ -n "${USERNAME}" ]
then
# Now add this user to the system, by building our args list
ARGS="-n ${USERNAME}"
- if [ ! -z "${USERCOMMENT}" ]
+ if [ -n "${USERCOMMENT}" ]
then
ARGS="${ARGS} -c \"${USERCOMMENT}\""
fi
- if [ ! -z "${USERPASS}" ]
+ if [ -n "${USERPASS}" ]
then
ARGS="${ARGS} -h 0"
echo "${USERPASS}" >${FSMNT}/.tmpPass
- elif [ ! -z "${USERENCPASS}" ]
+ elif [ -n "${USERENCPASS}" ]
then
ARGS="${ARGS} -H 0"
echo "${USERENCPASS}" >${FSMNT}/.tmpPass
@@ -151,19 +151,19 @@ setup_users()
rm ${FSMNT}/.tmpPass 2>/dev/null 2>/dev/null
fi
- if [ ! -z "${USERSHELL}" ]
+ if [ -n "${USERSHELL}" ]
then
ARGS="${ARGS} -s \"${USERSHELL}\""
else
ARGS="${ARGS} -s \"/nonexistant\""
fi
- if [ ! -z "${USERHOME}" ]
+ if [ -n "${USERHOME}" ]
then
ARGS="${ARGS} -m -d \"${USERHOME}\""
fi
- if [ ! -z "${USERGROUPS}" ]
+ if [ -n "${USERGROUPS}" ]
then
ARGS="${ARGS} -G \"${USERGROUPS}\""
fi
diff --git a/usr.sbin/pc-sysinstall/backend/functions.sh b/usr.sbin/pc-sysinstall/backend/functions.sh
index c413968..56ffa86 100755
--- a/usr.sbin/pc-sysinstall/backend/functions.sh
+++ b/usr.sbin/pc-sysinstall/backend/functions.sh
@@ -91,8 +91,7 @@ strip_white_space()
exit 1
fi
- VAL=`echo "$1" | tr -d ' '`
- export VAL
+ export VAL=`echo "$1" | tr -d ' '`
};
# Displays an error message and exits with error 1
@@ -239,7 +238,7 @@ fetch_file()
# Check if the download is finished
ps -p ${PID} >/dev/null 2>/dev/null
- if [ "$?" != "0" ]
+ if [ $? -ne 0 ]
then
break;
fi
@@ -293,7 +292,7 @@ iscompressed()
RES=1
if echo "${FILE}" | \
- grep -iE '\.(Z|lzo|lzw|lzma|gz|bz2|xz|zip)$' >/dev/null 2>&1
+ grep -qiE '\.(Z|lzo|lzw|lzma|gz|bz2|xz|zip)$' 2>&1
then
RES=0
fi
diff --git a/usr.sbin/pc-sysinstall/backend/parseconfig.sh b/usr.sbin/pc-sysinstall/backend/parseconfig.sh
index ad9c2d7..eeb6ce0 100755
--- a/usr.sbin/pc-sysinstall/backend/parseconfig.sh
+++ b/usr.sbin/pc-sysinstall/backend/parseconfig.sh
@@ -82,16 +82,16 @@ echo "File Sanity Check -> OK"
# Lets load the various universal settings now
get_value_from_cfg installMode
-INSTALLMODE="${VAL}" ; export INSTALLMODE
+export INSTALLMODE="${VAL}"
get_value_from_cfg installType
-INSTALLTYPE="${VAL}" ; export INSTALLTYPE
+export INSTALLTYPE="${VAL}"
get_value_from_cfg installMedium
-INSTALLMEDIUM="${VAL}" ; export INSTALLMEDIUM
+export INSTALLMEDIUM="${VAL}"
get_value_from_cfg packageType
-PACKAGETYPE="${VAL}" ; export PACKAGETYPE
+export PACKAGETYPE="${VAL}"
# Check if we are doing any networking setup
start_networking
@@ -110,7 +110,7 @@ case "${INSTALLMODE}" in
extract)
# Extracting only, make sure we have a valid target directory
get_value_from_cfg installLocation
- FSMNT="${VAL}" ; export FSMNT
+ export FSMNT="${VAL}"
if [ -z "$FSMNT" ] ; then exit_err "Missing installLocation=" ; fi
if [ ! -d "$FSMNT" ] ; then exit_err "No such directory: $FSMNT" ; fi
diff --git a/usr.sbin/pc-sysinstall/backend/startautoinstall.sh b/usr.sbin/pc-sysinstall/backend/startautoinstall.sh
index 93d9274..66cbe36 100755
--- a/usr.sbin/pc-sysinstall/backend/startautoinstall.sh
+++ b/usr.sbin/pc-sysinstall/backend/startautoinstall.sh
@@ -49,8 +49,8 @@ SHUTDOWN_CMD=`grep "shutdown_cmd:" ${CONF} | grep -v "^#" | sed "s|shutdown_cmd:
CONFIRM_INS=`grep "confirm_install:" ${CONF} | grep -v "^#" | sed "s|confirm_install: ||g" | sed "s|confirm_install:||g"`
# Check that this isn't a http / ftp file we need to fetch later
-echo "${PCCFG}" | grep -e "^http" -e "^ftp" > /dev/null 2>/dev/null
-if [ "$?" != "0" ]
+echo "${PCCFG}" | grep -q -e "^http" -e "^ftp" 2>/dev/null
+if [ $? -ne 0 ]
then
# Copy over the install cfg file, if not done already
if [ ! -e "${INSTALL_CFG}" ]
@@ -92,7 +92,7 @@ else
# Now try to fetch the remove file
echo "Fetching cfg with: \"fetch -o ${INSTALL_CFG} ${PCCFG}\""
fetch -o "${INSTALL_CFG}" "${PCCFG}"
- if [ "$?" != "0" ]
+ if [ $? -ne 0 ]
then
echo "ERROR: Failed to fetch ${PCCFG}, install aborted"
exit 150
@@ -115,9 +115,9 @@ then
fi
${PROGDIR}/pc-sysinstall -c ${INSTALL_CFG}
- if [ "$?" = "0" ]
+ if [ $? -eq 0 ]
then
- if [ ! -z "$SHUTDOWN_CMD" ]
+ if [ -n "$SHUTDOWN_CMD" ]
then
${SHUTDOWN_CMD}
else
OpenPOWER on IntegriCloud