summaryrefslogtreecommitdiffstats
path: root/usr/sbin/pc-sysinstall/backend
diff options
context:
space:
mode:
Diffstat (limited to 'usr/sbin/pc-sysinstall/backend')
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/Makefile6
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-bsdlabel.sh306
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-cleanup.sh62
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-disk.sh421
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-extractimage.sh216
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-ftp.sh49
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-installcomponents.sh95
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-localize.sh445
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-mountdisk.sh195
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-mountoptical.sh204
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-networking.sh27
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-newfs.sh231
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-packages.sh394
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-parse.sh29
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-runcommands.sh10
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-unmount.sh253
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-upgrade.sh110
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions-users.sh184
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/functions.sh325
-rwxr-xr-xusr/sbin/pc-sysinstall/backend/parseconfig.sh95
20 files changed, 2312 insertions, 1345 deletions
diff --git a/usr/sbin/pc-sysinstall/backend/Makefile b/usr/sbin/pc-sysinstall/backend/Makefile
index b4c517b..2b4693d 100755
--- a/usr/sbin/pc-sysinstall/backend/Makefile
+++ b/usr/sbin/pc-sysinstall/backend/Makefile
@@ -1,13 +1,13 @@
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/Makefile,v 1.4 2010/07/13 23:47:12 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/Makefile,v 1.6 2010/09/08 20:10:24 imp Exp $
FILES= functions-bsdlabel.sh functions-cleanup.sh functions-disk.sh \
functions-extractimage.sh functions-ftp.sh functions-installcomponents.sh \
- functions-localize.sh functions-mountdisk.sh \
+ functions-installpackages.sh functions-localize.sh functions-mountdisk.sh \
functions-mountoptical.sh functions-networking.sh \
functions-newfs.sh functions-packages.sh functions-parse.sh \
functions-runcommands.sh functions-unmount.sh \
functions-upgrade.sh functions-users.sh \
- functions.sh parseconfig.sh startautoinstall.sh
+ functions.sh parseconfig.sh startautoinstall.sh installimage.sh
FILESMODE= ${BINMODE}
FILESDIR=${SHAREDIR}/pc-sysinstall/backend
NO_OBJ=
diff --git a/usr/sbin/pc-sysinstall/backend/functions-bsdlabel.sh b/usr/sbin/pc-sysinstall/backend/functions-bsdlabel.sh
index c8cb4f1..316b46c 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-bsdlabel.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-bsdlabel.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-bsdlabel.sh,v 1.9 2010/10/21 22:46:10 imp Exp $
# Functions related to disk operations using bsdlabel
@@ -58,20 +58,13 @@ get_fs_line_xvars()
echo $LINE | grep '^ZFS' >/dev/null 2>/dev/null
if [ "$?" = "0" ] ; then
ZTYPE="NONE"
- ZFSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1`"
+ ZFSVARS="`echo $LINE | cut -d '(' -f 2- | cut -d ')' -f 1 | xargs`"
- # Check if we are doing raidz setup
- echo $ZFSVARS | grep "^raidz:" >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
- ZTYPE="raidz"
- ZFSVARS="`echo $ZFSVARS | sed 's|raidz: ||g' | sed 's|raidz:||g'`"
- fi
-
- echo $ZFSVARS | grep "^mirror:" >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
- ZTYPE="mirror"
- ZFSVARS="`echo $ZFSVARS | sed 's|mirror: ||g' | sed 's|mirror:||g'`"
- fi
+ echo $ZFSVARS | grep -E "^(disk|file|mirror|raidz(1|2)?|spare|log|cache):" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ] ; then
+ ZTYPE=`echo $ZFSVARS | cut -f1 -d:`
+ ZFSVARS=`echo $ZFSVARS | sed "s|$ZTYPE: ||g" | sed "s|$ZTYPE:||g"`
+ fi
# Return the ZFS options
if [ "${ZTYPE}" = "NONE" ] ; then
@@ -83,7 +76,6 @@ get_fs_line_xvars()
return
fi # End of ZFS block
-
fi # End of xtra-options block
# If we got here, set VAR to empty and export
@@ -93,30 +85,31 @@ get_fs_line_xvars()
};
# Init each zfs mirror disk with a boot sector so we can failover
-setup_zfs_mirror_parts() {
-
- _nZFS=""
- # Using mirroring, setup boot partitions on each disk
- _mirrline="`echo ${1} | sed 's|mirror ||g'`"
- 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
- if [ -z "$_zvars" ] ; then continue ; fi
-
- is_disk "$_zvars" >/dev/null 2>/dev/null
- if [ "$?" = "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
- rc_halt "gpart add -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null
- _nZFS="$_nZFS ${_zvars}p2"
- else
- _nZFS="$_nZFS ${_zvars}"
- fi
- done
- echo "mirror $2 `echo $_nZFS | tr -s ' '`"
+setup_zfs_mirror_parts()
+{
+ _nZFS=""
+
+ # Using mirroring, setup boot partitions on each disk
+ _mirrline="`echo ${1} | sed 's|mirror ||g'`"
+ 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
+ if [ -z "$_zvars" ] ; then continue ; fi
+
+ is_disk "$_zvars" >/dev/null 2>/dev/null
+ if [ "$?" = "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
+ rc_halt "gpart add -t freebsd-zfs ${_zvars}" >/dev/null 2>/dev/null
+ _nZFS="$_nZFS ${_zvars}p2"
+ else
+ _nZFS="$_nZFS ${_zvars}"
+ fi
+ done
+ echo "mirror $2 `echo $_nZFS | tr -s ' '`"
} ;
# Function which creates a unique label name for the specified mount
@@ -168,12 +161,10 @@ gen_glabel_name()
# Function to setup / stamp a legacy MBR bsdlabel
setup_mbr_partitions()
{
-
DISKTAG="$1"
WRKSLICE="$2"
FOUNDPARTS="1"
-
# Lets setup the BSDLABEL
BSDLABEL="${TMPDIR}/bsdLabel-${WRKSLICE}"
export BSDLABEL
@@ -201,6 +192,11 @@ setup_mbr_partitions()
SIZE=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 2`
MNT=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 3`
+ if echo $STRING | grep -E '^/.+' >/dev/null 2>&1
+ then
+ IMAGE=`echo ${STRING} | cut -f1 -d' '`
+ fi
+
# Check if we have a .eli extension on this FS
echo ${FS} | grep ".eli" >/dev/null 2>/dev/null
if [ "$?" = "0" ]
@@ -223,9 +219,17 @@ setup_mbr_partitions()
USINGENCROOT="0" ; export USINGENCROOT
fi
+ if [ -n "${IMAGE}" ]
+ then
+ FS="IMAGE"
+ SIZE=`ls -l "${IMAGE}" | awk '{ print $5 }'`
+ MNT=`echo $STRING | tr -s '\t' ' ' | cut -d ' ' -f 2`
+ SIZE=`convert_byte_to_megabyte $SIZE`
+ fi
+
# Now check that these values are sane
case $FS in
- UFS|UFS+S|UFS+J|ZFS|SWAP) ;;
+ UFS|UFS+S|UFS+J|UFS+SUJ|ZFS|SWAP|IMAGE) ;;
*) exit_err "ERROR: Invalid file system specified on $line" ;;
esac
@@ -262,20 +266,20 @@ setup_mbr_partitions()
# Check if we found a valid root partition
check_for_mount "${MNT}" "/"
if [ "$?" = "0" ] ; then
- FOUNDROOT="0" ; export FOUNDROOT
+ FOUNDROOT="0" ; export FOUNDROOT
fi
# Check if we have a "/boot" instead
check_for_mount "${MNT}" "/boot"
if [ "${?}" = "0" ] ; then
USINGBOOTPART="0" ; export USINGBOOTPART
- if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" ]
+ if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" -a "${FS}" != "UFS+SUJ" ]
then
exit_err "/boot partition must be formatted with UFS"
fi
fi
- else
+ else
# Done with the a: partitions
# Check if we found a valid root partition not on a:
@@ -314,7 +318,7 @@ setup_mbr_partitions()
fi
# Save this data to our partition config dir
- echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}" >${PARTDIR}/${WRKSLICE}${PARTLETTER}
+ echo "${FS}:${MNT}:${ENC}:${PLABEL}:MBR:${XTRAOPTS}:${IMAGE}" >${PARTDIR}/${WRKSLICE}${PARTLETTER}
# If we have a enc password, save it as well
if [ ! -z "${ENCPASS}" ] ; then
@@ -323,18 +327,20 @@ setup_mbr_partitions()
# This partition letter is used, get the next one
case ${PARTLETTER} in
- a) PARTLETTER="b" ;;
- b) # When we hit b, add the special c: setup for bsdlabel
- echo "c: * * unused" >>${BSDLABEL}
- PARTLETTER="d" ;;
- d) PARTLETTER="e" ;;
- e) PARTLETTER="f" ;;
- f) PARTLETTER="g" ;;
- g) PARTLETTER="h" ;;
- h) PARTLETTER="ERR" ;;
- *) exit_err "ERROR: bsdlabel only supports up to letter h for partitions." ;;
+ a) PARTLETTER="b" ;;
+ b) # When we hit b, add the special c: setup for bsdlabel
+ echo "c: * * unused" >>${BSDLABEL}
+ PARTLETTER="d" ;;
+ d) PARTLETTER="e" ;;
+ e) PARTLETTER="f" ;;
+ f) PARTLETTER="g" ;;
+ g) PARTLETTER="h" ;;
+ h) PARTLETTER="ERR" ;;
+ *) exit_err "ERROR: bsdlabel only supports up to letter h for partitions." ;;
esac
+ unset IMAGE
+
fi # End of subsection locating a slice in config
echo $line | grep "^commitDiskLabel" >/dev/null 2>/dev/null
@@ -409,7 +415,7 @@ setup_gpt_partitions()
# Now check that these values are sane
case $FS in
- UFS|UFS+S|UFS+J|ZFS|SWAP) ;;
+ UFS|UFS+S|UFS+J|UFS+SUJ|ZFS|SWAP) ;;
*) exit_err "ERROR: Invalid file system specified on $line" ;;
esac
@@ -446,7 +452,7 @@ setup_gpt_partitions()
if [ "${?}" = "0" ] ; then
if [ "${CURPART}" = "2" ] ; then
USINGBOOTPART="0" ; export USINGBOOTPART
- if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" ]
+ if [ "${FS}" != "UFS" -a "${FS}" != "UFS+S" -a "${FS}" != "UFS+J" -a "${FS}" != "UFS+SUJ" ]
then
exit_err "/boot partition must be formatted with UFS"
fi
@@ -471,9 +477,9 @@ setup_gpt_partitions()
# Figure out the gpart type to use
case ${FS} in
- ZFS) PARTYPE="freebsd-zfs" ;;
- SWAP) PARTYPE="freebsd-swap" ;;
- *) PARTYPE="freebsd-ufs" ;;
+ ZFS) PARTYPE="freebsd-zfs" ;;
+ SWAP) PARTYPE="freebsd-swap" ;;
+ *) PARTYPE="freebsd-ufs" ;;
esac
# Create the partition
@@ -514,8 +520,8 @@ setup_gpt_partitions()
# If this is the boot disk, stamp the right gptboot
if [ ! -z "${BOOTTYPE}" ] ; then
case ${BOOTTYPE} in
- freebsd-ufs) rc_halt "gpart bootcode -p /boot/gptboot -i 1 ${DISK}" ;;
- freebsd-zfs) rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${DISK}" ;;
+ freebsd-ufs) rc_halt "gpart bootcode -p /boot/gptboot -i 1 ${DISK}" ;;
+ freebsd-zfs) rc_halt "gpart bootcode -p /boot/gptzfsboot -i 1 ${DISK}" ;;
esac
fi
@@ -574,7 +580,6 @@ 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
exit_err "ERROR: No slices were setup! Please report this to the maintainers"
@@ -639,3 +644,176 @@ 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|'`
+
+ cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/$' >/dev/null 2>&1
+ if [ "$?" = "0" ]
+ then
+ if [ "${PARTLETTER}" = "a" ]
+ then
+ FOUNDROOT="0"
+ else
+ FOUNDROOT="1"
+ fi
+
+ ROOTIMAGE="1"
+
+ export FOUNDROOT
+ export ROOTIMAGE
+ fi
+
+ cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/boot$' >/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|'`
+
+ cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/$' >/dev/null 2>&1
+ if [ "$?" = "0" ]
+ then
+ if [ "${PARTNUMBER}" = "2" ]
+ then
+ FOUNDROOT="0"
+ else
+ FOUNDROOT="1"
+ fi
+
+ ROOTIMAGE="1"
+
+ export FOUNDROOT
+ export ROOTIMAGE
+ fi
+
+ cat "${FSTAB}" | awk '{ print $2 }' | grep -E '^/boot$' >/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_disk_layout()
+{
+ local SLICES
+ local TYPE
+ local DISK
+ local RES
+ local F
+
+ DISK="$1"
+ TYPE="MBR"
+
+ if [ -z "${DISK}" ]
+ then
+ return 1
+ fi
+
+ SLICES_MBR=`ls /dev/${DISK}s[1-4]*[a-h]* 2>/dev/null`
+ SLICES_GPT=`ls /dev/${DISK}p[0-9]* 2>/dev/null`
+ SLICES_SLICE=`ls /dev/${DISK}[a-h]* 2>/dev/null`
+
+ if [ -n "${SLICES_MBR}" ]
+ then
+ SLICES="${SLICES_MBR}"
+ TYPE="MBR"
+ RES=0
+ fi
+ if [ -n "${SLICES_GPT}" ]
+ then
+ SLICES="${SLICES_GPT}"
+ TYPE="GPT"
+ RES=0
+ fi
+ if [ -n "${SLICES_SLICE}" ]
+ then
+ SLICES="${SLICES_SLICE}"
+ TYPE="MBR"
+ 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
+
+ return ${RES}
+};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-cleanup.sh b/usr/sbin/pc-sysinstall/backend/functions-cleanup.sh
index ff2729f..be316c4 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-cleanup.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-cleanup.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh,v 1.3 2010/07/31 19:25:51 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-cleanup.sh,v 1.5 2010/10/21 17:14:44 imp Exp $
# Functions which perform the final cleanup after an install
@@ -99,9 +99,9 @@ zfs_cleanup_unmount()
do
if [ "${ZMNT}" != "/" ]
then
- #rc_halt "/sbin/zfs set mountpoint=${ZMNT} ${ZPOOLNAME}${ZMNT}"
- #rc_halt "/sbin/zfs unmount ${ZPOOLNAME}${ZMNT}"
- #sleep 2
+ rc_halt "zfs set mountpoint=${ZMNT} ${ZPOOLNAME}${ZMNT}"
+ rc_halt "zfs unmount ${ZPOOLNAME}${ZMNT}"
+ sleep 2
fi
done
fi
@@ -166,8 +166,8 @@ setup_fstab()
# Set mount options for file-systems
case $PARTFS in
UFS+J) MNTOPTS="rw,noatime,async" ;;
- SWAP) MNTOPTS="sw" ;;
- *) MNTOPTS="rw,noatime" ;;
+ SWAP) MNTOPTS="sw" ;;
+ *) MNTOPTS="rw,noatime" ;;
esac
@@ -296,7 +296,7 @@ setup_geli_loading()
# If we have a passphrase, set it up now
if [ -e "${PARTDIR}-enc/${PART}-encpass" ] ; then
- cat ${PARTDIR}-enc/${PART}-encpass | geli setkey -S -n 0 -p -k ${KEYFILE} -K ${KEYFILE} ${PART}
+ geli setkey -J ${PARTDIR}-enc/${PART}-encpass -n 0 -p -k ${KEYFILE} -K ${KEYFILE} ${PART}
geli configure -b ${PART}
fi
@@ -349,9 +349,9 @@ setup_hostname()
mv ${FSMNT}/etc/rc.conf.new ${FSMNT}/etc/rc.conf
# Set the hostname now
-# echo_log "Setting hostname: ${HOSTNAME}"
-# echo "hostname=\"${HOSTNAME}\"" >> ${FSMNT}/etc/rc.conf
-# sed -i -e "s|my.domain|${HOSTNAME} ${HOSTNAME}|g" ${FSMNT}/etc/hosts
+ echo_log "Setting hostname: ${HOSTNAME}"
+ echo "hostname=\"${HOSTNAME}\"" >> ${FSMNT}/etc/rc.conf
+ sed -i -e "s|my.domain|${HOSTNAME} ${HOSTNAME}|g" ${FSMNT}/etc/hosts
};
@@ -391,30 +391,28 @@ set_root_pw()
run_final_cleanup()
{
+ # Check if we need to run any gmirror setup
+ ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Lets setup gmirror now
+ setup_gmirror
+ fi
- # Check if we need to run any gmirror setup
- ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- # Lets setup gmirror now
- setup_gmirror
- fi
-
- # Check if we need to save any geli keys
- ls ${GELIKEYDIR}/* >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- # Lets setup geli loading
- setup_geli_loading
- fi
-
- # Set a hostname on the install system
- setup_hostname
+ # Check if we need to save any geli keys
+ ls ${GELIKEYDIR}/* >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Lets setup geli loading
+ setup_geli_loading
+ fi
- # Set the root_pw if it is specified
- set_root_pw
+ # Set a hostname on the install system
+ setup_hostname
- # Generate the fstab for the installed system
- setup_fstab
+ # Set the root_pw if it is specified
+ set_root_pw
+ # Generate the fstab for the installed system
+ setup_fstab
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-disk.sh b/usr/sbin/pc-sysinstall/backend/functions-disk.sh
index 3ab86dd..2bb3ecc 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-disk.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-disk.sh
@@ -23,18 +23,19 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-disk.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-disk.sh,v 1.8 2010/11/10 05:32:36 imp Exp $
# Functions related to disk operations using gpart
# See if device is a full disk or partition/slice
-is_disk() {
- for _dsk in `sysctl -n kern.disks`
- do
- if [ "$_dsk" = "${1}" ] ; then return 0 ; fi
- done
+is_disk()
+{
+ for _dsk in `sysctl -n kern.disks`
+ do
+ if [ "$_dsk" = "${1}" ] ; then return 0 ; fi
+ done
- return 1
+ return 1
}
# Get a MBR partitions sysid
@@ -190,9 +191,9 @@ get_disk_partitions()
for i in ${SLICES}
do
case $type in
- MBR) name="${1}s${i}" ;;
- GPT) name="${1}p${i}";;
- *) name="${1}s${i}";;
+ MBR) name="${1}s${i}" ;;
+ GPT) name="${1}p${i}";;
+ *) name="${1}s${i}";;
esac
if [ -z "${RSLICES}" ]
then
@@ -226,8 +227,16 @@ get_disk_heads()
VAL="${head}" ; export VAL
};
+# 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
+};
+
# Function which exports all zpools, making them safe to overwrite potentially
-export_all_zpools() {
+export_all_zpools()
+{
# Export any zpools
for i in `zpool list -H -o name`
do
@@ -324,144 +333,216 @@ setup_disk_slice()
# We are ready to start setting up the disks, lets read the config and do the actions
while read line
do
- echo $line | grep "^disk${disknum}=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
-
- # Found a disk= entry, lets get the disk we are working on
- get_value_from_string "${line}"
- strip_white_space "$VAL"
- DISK="$VAL"
+ echo $line | grep "^disk${disknum}=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+
+ # Found a disk= entry, lets get the disk we are working on
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ DISK="$VAL"
- # Before we go further, lets confirm this disk really exists
- if [ ! -e "/dev/${DISK}" ]
- then
- exit_err "ERROR: The disk ${DISK} does not exist!"
- fi
+ # Before we go further, lets confirm this disk really exists
+ if [ ! -e "/dev/${DISK}" ]
+ then
+ exit_err "ERROR: The disk ${DISK} does not exist!"
+ fi
- # Make sure we stop any gmirrors on this disk
- stop_all_gmirror ${DISK}
+ # Make sure we stop any gmirrors on this disk
+ stop_all_gmirror ${DISK}
- # Make sure we stop any geli stuff on this disk
- stop_all_geli ${DISK}
+ # Make sure we stop any geli stuff on this disk
+ stop_all_geli ${DISK}
- # Make sure we don't have any zpools loaded
- stop_all_zfs
+ # Make sure we don't have any zpools loaded
+ stop_all_zfs
- fi
+ fi
- # Lets look if this device will be mirrored on another disk
- echo $line | grep "^mirror=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
+ # Lets look if this device will be mirrored on another disk
+ echo $line | grep "^mirror=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
- # Found a disk= entry, lets get the disk we are working on
- get_value_from_string "${line}"
- strip_white_space "$VAL"
- MIRRORDISK="$VAL"
+ # Found a disk= entry, lets get the disk we are working on
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ MIRRORDISK="$VAL"
- # Before we go further, lets confirm this disk really exists
- if [ ! -e "/dev/${MIRRORDISK}" ]
- then
- exit_err "ERROR: The mirror disk ${MIRRORDISK} does not exist!"
- fi
- fi
+ # Before we go further, lets confirm this disk really exists
+ if [ ! -e "/dev/${MIRRORDISK}" ]
+ then
+ exit_err "ERROR: The mirror disk ${MIRRORDISK} does not exist!"
+ fi
+ fi
- # Lets see if we have been given a mirror balance choice
- echo $line | grep "^mirrorbal=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
+ # Lets see if we have been given a mirror balance choice
+ echo $line | grep "^mirrorbal=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
- # Found a disk= entry, lets get the disk we are working on
- get_value_from_string "${line}"
- strip_white_space "$VAL"
- MIRRORBAL="$VAL"
- fi
+ # Found a disk= entry, lets get the disk we are working on
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ MIRRORBAL="$VAL"
+ fi
- echo $line | grep "^partition=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- # Found a partition= entry, lets read / set it
- get_value_from_string "${line}"
- strip_white_space "$VAL"
- PTYPE="$VAL"
-
- # We are using free space, figure out the slice number
- if [ "${PTYPE}" = "free" -o "${PTYPE}" = "FREE" ]
- then
- # Lets figure out what number this slice will be
- LASTSLICE="`gpart show ${DISK} | grep -v ${DISK} | grep -v ' free' |tr -s '\t' ' ' | cut -d ' ' -f 4 | sed '/^$/d' | tail -n 1`"
- if [ -z "${LASTSLICE}" ]
- then
- LASTSLICE="1"
- else
- LASTSLICE="`expr $LASTSLICE + 1`"
- fi
-
- if [ $LASTSLICE -gt 4 ]
- then
- exit_err "ERROR: BSD only supports primary partitions, and there are none availble on $DISK"
- fi
+ echo $line | grep "^partition=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Found a partition= entry, lets read / set it
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ PTYPE=`echo $VAL|tr A-Z a-z`
+
+ # We are using free space, figure out the slice number
+ if [ "${PTYPE}" = "free" ]
+ then
+ # Lets figure out what number this slice will be
+ LASTSLICE="`gpart show ${DISK} \
+ | grep -v ${DISK} \
+ | grep -v ' free' \
+ | tr -s '\t' ' ' \
+ | cut -d ' ' -f 4 \
+ | sed '/^$/d' \
+ | tail -n 1`"
+
+ if [ -z "${LASTSLICE}" ]
+ then
+ LASTSLICE="1"
+ else
+ LASTSLICE="`expr $LASTSLICE + 1`"
+ fi
+
+ if [ $LASTSLICE -gt 4 ]
+ then
+ exit_err "ERROR: BSD only supports primary partitions, and there are none availble on $DISK"
+ fi
+
+ fi
+ fi
- fi
- fi
+ # Check if we have an image file defined
+ echo $line | grep "^image=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ] ; then
+ # Found an image= entry, lets read / set it
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ IMAGE="$VAL"
+ if [ ! -f "$IMAGE" ] ; then
+ exit_err "$IMAGE file does not exist"
+ fi
+ fi
- 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 a partscheme specified
+ echo $line | grep "^partscheme=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ] ; then
+ # Found a partscheme= entry, lets read / set it
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ PSCHEME="$VAL"
+ if [ "$PSCHEME" != "GPT" -a "$PSCHEME" != "MBR" ] ; then
+ exit_err "Unknown partition scheme: $PSCHEME"
+ fi
+ fi
- echo $line | grep "^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) tmpSLICE="${DISK}p1"
- run_gpart_full "${DISK}" "${BMANAGER}" ;;
- s1|s2|s3|s4) tmpSLICE="${DISK}${PTYPE}"
- # Get the number of the slice we are working on
- s="`echo ${PTYPE} | awk '{print substr($0,length,1)}'`"
- run_gpart_slice "${DISK}" "${BMANAGER}" "${s}" ;;
- free|FREE) tmpSLICE="${DISK}s${LASTSLICE}"
- run_gpart_free "${DISK}" "${LASTSLICE}" "${BMANAGER}" ;;
- *) exit_err "ERROR: Unknown PTYPE: $PTYPE" ;;
- esac
-
- # Now save which disk<num> this is, so we can parse it later during slice partition setup
- echo "disk${disknum}" >${SLICECFGDIR}/$tmpSLICE
-
- # Save any mirror config
- if [ ! -z "$MIRRORDISK" ]
- then
- # Default to round-robin if the user didn't specify
- if [ -z "$MIRRORBAL" ]
- then
- MIRRORBAL="round-robin"
- fi
- echo "$MIRRORDISK:$MIRRORBAL" >${MIRRORCFGDIR}/$DISK
- fi
-
-
- # Increment our disk counter to look for next disk and unset
- unset BMANAGER PTYPE DISK MIRRORDISK MIRRORBAL
- disknum="`expr $disknum + 1`"
- else
- exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!"
- fi
- fi
+ echo $line | grep "^bootManager=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Found a bootManager= entry, lets read /set it
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ BMANAGER="$VAL"
+ fi
+
+ echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Found our flag to commit this disk setup / lets do sanity check and do it
+ if [ ! -z "${DISK}" -a ! -z "${PTYPE}" ]
+ then
+ case ${PTYPE} in
+ all)
+ if [ "$PSCHEME" = "MBR" -o -z "$PSCHEME" ] ; then
+ PSCHEME="MBR"
+ tmpSLICE="${DISK}s1"
+ else
+ tmpSLICE="${DISK}p1"
+ fi
+
+ run_gpart_full "${DISK}" "${BMANAGER}" "${PSCHEME}"
+ ;;
+
+ s1|s2|s3|s4)
+ tmpSLICE="${DISK}${PTYPE}"
+ # Get the number of the slice we are working on
+ s="`echo ${PTYPE} | awk '{print substr($0,length,1)}'`"
+ run_gpart_slice "${DISK}" "${BMANAGER}" "${s}"
+ ;;
+
+ free)
+ tmpSLICE="${DISK}s${LASTSLICE}"
+ run_gpart_free "${DISK}" "${LASTSLICE}" "${BMANAGER}"
+ ;;
+
+ image)
+ if [ -z "${IMAGE}" ]
+ then
+ exit_err "ERROR: partition type image specified with no image!"
+ fi
+ ;;
+
+ *) exit_err "ERROR: Unknown PTYPE: $PTYPE" ;;
+ esac
+
+
+ if [ -n "${IMAGE}" ]
+ then
+ local DEST
+
+ if [ -n "${tmpSLICE}" ]
+ then
+ DEST="${tmpSLICE}"
+ else
+ DEST="${DISK}"
+ fi
+
+ write_image "${IMAGE}" "${DEST}"
+ check_disk_layout "${DEST}"
+ fi
+
+ # Now save which disk<num> this is, so we can parse it later during slice partition setup
+ if [ -z "${IMAGE}" ]
+ then
+ echo "disk${disknum}" >${SLICECFGDIR}/$tmpSLICE
+ fi
+
+ # Save any mirror config
+ if [ ! -z "$MIRRORDISK" ]
+ then
+ # Default to round-robin if the user didn't specify
+ if [ -z "$MIRRORBAL" ]
+ then
+ MIRRORBAL="round-robin"
+ fi
+ echo "$MIRRORDISK:$MIRRORBAL" >${MIRRORCFGDIR}/$DISK
+ fi
+
+ # Increment our disk counter to look for next disk and unset
+ unset BMANAGER PTYPE DISK MIRRORDISK MIRRORBAL PSCHEME IMAGE
+ disknum="`expr $disknum + 1`"
+ else
+ exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!"
+ fi
+ fi
done <${CFGF}
};
# Stop all gjournals on disk / slice
-stop_gjournal() {
+stop_gjournal()
+{
_gdsk="$1"
# Check if we need to shutdown any journals on this drive
ls /dev/${_gdsk}*.journal >/dev/null 2>/dev/null
@@ -477,7 +558,7 @@ stop_gjournal() {
fi
} ;
-# Function which runs gpart and creates a single large slice
+# Function which runs gpart and creates a single large GPT partition scheme
init_gpt_full_disk()
{
_intDISK=$1
@@ -506,14 +587,88 @@ init_gpt_full_disk()
}
+# Function which runs gpart and creates a single large MBR partition scheme
+init_mbr_full_disk()
+{
+ _intDISK=$1
+ _intBOOT=$2
+
+ startblock="63"
+
+ # Set our sysctl so we can overwrite any geom using drives
+ sysctl kern.geom.debugflags=16 >>${LOGOUT} 2>>${LOGOUT}
+
+ # Stop any journaling
+ stop_gjournal "${_intDISK}"
+
+ # Remove any existing partitions
+ delete_all_gpart "${_intDISK}"
+
+ #Erase any existing bootloader
+ echo_log "Cleaning up ${_intDISK}"
+ rc_halt "dd if=/dev/zero of=/dev/${_intDISK} count=2048"
+
+ sleep 2
+
+ echo_log "Running gpart on ${_intDISK}"
+ rc_halt "gpart create -s mbr ${_intDISK}"
+
+ # Lets figure out disk size in blocks
+ # Get the cyl of this disk
+ get_disk_cyl "${_intDISK}"
+ cyl="${VAL}"
+
+ # Get the heads of this disk
+ get_disk_heads "${_intDISK}"
+ head="${VAL}"
+
+ # Get the tracks/sectors of this disk
+ get_disk_sectors "${_intDISK}"
+ sec="${VAL}"
+
+ # Multiply them all together to get our total blocks
+ totalblocks="`expr ${cyl} \* ${head}`"
+ totalblocks="`expr ${totalblocks} \* ${sec}`"
+ if [ -z "${totalblocks}" ]
+ then
+ totalblocks=`gpart show "${_intDISK}"|tail -2|head -1|awk '{ print $2 }'`
+ fi
+
+ # Now set the ending block to the total disk block size
+ sizeblock="`expr ${totalblocks} - ${startblock}`"
+
+ # Install new partition setup
+ echo_log "Running gpart add on ${_intDISK}"
+ rc_halt "gpart add -b ${startblock} -s ${sizeblock} -t freebsd -i 1 ${_intDISK}"
+ sleep 2
+
+ echo_log "Cleaning up ${_intDISK}s1"
+ rc_halt "dd if=/dev/zero of=/dev/${_intDISK}s1 count=1024"
+
+ if [ "$_intBOOT" = "bsd" ] ; then
+ echo_log "Stamping boot0 on ${_intDISK}"
+ rc_halt "gpart bootcode -b /boot/boot0 ${_intDISK}"
+ else
+ echo_log "Stamping boot1 on ${_intDISK}"
+ rc_halt "gpart bootcode -b /boot/boot1 ${_intDISK}"
+ fi
+
+}
+
# Function which runs gpart and creates a single large slice
run_gpart_full()
{
DISK=$1
+ BOOT=$2
+ SCHEME=$3
- init_gpt_full_disk "$DISK"
-
- slice="${DISK}-1-gpt"
+ if [ "$SCHEME" = "MBR" ] ; then
+ init_mbr_full_disk "$DISK" "$BOOT"
+ slice="${DISK}-1-mbr"
+ else
+ init_gpt_full_disk "$DISK"
+ slice="${DISK}-1-gpt"
+ fi
# Lets save our slice, so we know what to look for in the config file later on
if [ -z "$WORKINGSLICES" ]
diff --git a/usr/sbin/pc-sysinstall/backend/functions-extractimage.sh b/usr/sbin/pc-sysinstall/backend/functions-extractimage.sh
index 1853e26..aeb585f 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-extractimage.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-extractimage.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-extractimage.sh,v 1.8 2010/10/21 23:08:42 imp Exp $
# Functions which perform the extraction / installation of system to disk
@@ -54,39 +54,41 @@ start_extract_uzip_tar()
echo_log "pc-sysinstall: Starting Extraction"
case ${PACKAGETYPE} in
- uzip) # Start by mounting the uzip image
- MDDEVICE=`mdconfig -a -t vnode -o readonly -f ${INSFILE}`
- mkdir -p ${FSMNT}.uzip
- mount -r /dev/${MDDEVICE}.uzip ${FSMNT}.uzip
- if [ "$?" != "0" ]
- then
- exit_err "ERROR: Failed mounting the ${INSFILE}"
- fi
- cd ${FSMNT}.uzip
-
- # 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" ]
- then
- cd /
- echo "TAR failure occured:" >>${LOGOUT}
- cat ${FSMNT}/.tar-extract.log | grep "tar:" >>${LOGOUT}
- umount ${FSMNT}.uzip
- mdconfig -d -u ${MDDEVICE}
- exit_err "ERROR: Failed extracting the tar image"
- fi
-
- # All finished, now lets umount and cleanup
- cd /
- umount ${FSMNT}.uzip
- mdconfig -d -u ${MDDEVICE}
- ;;
- tar) tar -xpv -C ${FSMNT} -f ${INSFILE} ${TAROPTS} >&1 2>&1
- if [ "$?" != "0" ]
- then
- exit_err "ERROR: Failed extracting the tar image"
- fi
- ;;
+ uzip)
+ # Start by mounting the uzip image
+ MDDEVICE=`mdconfig -a -t vnode -o readonly -f ${INSFILE}`
+ mkdir -p ${FSMNT}.uzip
+ mount -r /dev/${MDDEVICE}.uzip ${FSMNT}.uzip
+ if [ "$?" != "0" ]
+ then
+ exit_err "ERROR: Failed mounting the ${INSFILE}"
+ fi
+ cd ${FSMNT}.uzip
+
+ # 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" ]
+ then
+ cd /
+ echo "TAR failure occurred:" >>${LOGOUT}
+ cat ${FSMNT}/.tar-extract.log | grep "tar:" >>${LOGOUT}
+ umount ${FSMNT}.uzip
+ mdconfig -d -u ${MDDEVICE}
+ exit_err "ERROR: Failed extracting the tar image"
+ fi
+
+ # All finished, now lets umount and cleanup
+ cd /
+ umount ${FSMNT}.uzip
+ mdconfig -d -u ${MDDEVICE}
+ ;;
+ tar)
+ tar -xpv -C ${FSMNT} -f ${INSFILE} ${TAROPTS} >&1 2>&1
+ if [ "$?" != "0" ]
+ then
+ exit_err "ERROR: Failed extracting the tar image"
+ fi
+ ;;
esac
# Check if this was a FTP download and clean it up now
@@ -120,10 +122,10 @@ start_extract_split()
DIRS=`ls -d ${INSDIR}/*|grep -Ev '(uzip|kernels|src)'`
for dir in ${DIRS}
do
- cd "${dir}"
- if [ -f "install.sh" ]
- then
- echo "Extracting" `basename ${dir}`
+ cd "${dir}"
+ if [ -f "install.sh" ]
+ then
+ echo_log "Extracting" `basename ${dir}`
echo "y" | sh install.sh >/dev/null
if [ "$?" != "0" ]
then
@@ -139,13 +141,14 @@ start_extract_split()
cd "${KERNELS}"
if [ -f "install.sh" ]
then
- echo "Extracting" `basename ${KERNELS}`
+ echo_log "Extracting" `basename ${KERNELS}`
echo "y" | sh install.sh generic >/dev/null
if [ "$?" != "0" ]
then
exit_err "ERROR: Failed extracting ${KERNELS}"
fi
- echo 'kernel="GENERIC"' > "${FSMNT}/boot/loader.conf"
+ rm -rf "${FSMNT}/boot/kernel"
+ mv "${FSMNT}/boot/GENERIC" "${FSMNT}/boot/kernel"
else
exit_err "ERROR: ${KERNELS}/install.sh does not exist"
fi
@@ -155,7 +158,7 @@ start_extract_split()
cd "${SOURCE}"
if [ -f "install.sh" ]
then
- echo "Extracting" `basename ${SOURCE}`
+ echo_log "Extracting" `basename ${SOURCE}`
echo "y" | sh install.sh all >/dev/null
if [ "$?" != "0" ]
then
@@ -203,7 +206,76 @@ fetch_install_file()
};
-# Function which does the rsync download from the server specifed in cfg
+# Function which will download freebsd install files
+fetch_split_files()
+{
+ get_ftpHost
+ if [ -z "$VAL" ]
+ then
+ exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!"
+ fi
+ FTPHOST="${VAL}"
+
+ get_ftpDir
+ if [ -z "$VAL" ]
+ then
+ exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!"
+ fi
+ FTPDIR="${VAL}"
+
+ # Check if we have a /usr partition to save the download
+ if [ -d "${FSMNT}/usr" ]
+ then
+ OUTFILE="${FSMNT}/usr/.fetch-${INSFILE}"
+ else
+ OUTFILE="${FSMNT}/.fetch-${INSFILE}"
+ fi
+
+ DIRS="base catpages dict doc games info manpages proflibs kernels src"
+ if [ "${FBSD_ARCH}" = "amd64" ]
+ then
+ DIRS="${DIRS} lib32"
+ fi
+
+ for d in ${DIRS}
+ do
+ mkdir -p "${OUTFILE}/${d}"
+ done
+
+
+ NETRC="${OUTFILE}/.netrc"
+ cat<<EOF>"${NETRC}"
+machine ${FTPHOST}
+login anonymous
+password anonymous
+macdef INSTALL
+bin
+prompt
+EOF
+
+ for d in ${DIRS}
+ do
+ cat<<EOF>>"${NETRC}"
+cd ${FTPDIR}/${d}
+lcd ${OUTFILE}/${d}
+mreget *
+EOF
+ done
+
+ cat<<EOF>>"${NETRC}"
+bye
+
+
+EOF
+
+ # Fetch the files via ftp
+ echo "$ INSTALL" | ftp -N "${NETRC}" "${FTPHOST}"
+
+ # Done fetching, now reset the INSFILE to our downloaded archived
+ INSFILE="${OUTFILE}" ; export INSFILE
+}
+
+# Function which does the rsync download from the server specified in cfg
start_rsync_copy()
{
# Load our rsync config values
@@ -257,6 +329,46 @@ start_rsync_copy()
};
+start_image_install()
+{
+ if [ -z "${IMAGE_FILE}" ]
+ then
+ exit_err "ERROR: installMedium set to image but no image file specified!"
+ fi
+
+ # 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" ]
+ then
+ # Found a disk= entry, lets get the disk we are working on
+ get_value_from_string "${line}"
+ strip_white_space "$VAL"
+ DISK="$VAL"
+ fi
+
+ echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Found our flag to commit this disk setup / lets do sanity check and do it
+ if [ ! -z "${DISK}" ]
+ then
+
+ # Write the image
+ write_image "${IMAGE_FILE}" "${DISK}"
+
+ # Increment our disk counter to look for next disk and unset
+ unset DISK
+ break
+
+ else
+ exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!"
+ fi
+ fi
+
+ done <${CFGF}
+};
# Entrance function, which starts the installation process
init_extraction()
@@ -272,19 +384,19 @@ init_extraction()
if [ "$INSTALLTYPE" = "FreeBSD" ]
then
case $PACKAGETYPE in
- uzip) INSFILE="${FBSD_UZIP_FILE}" ;;
- tar) INSFILE="${FBSD_TAR_FILE}" ;;
- split)
- INSDIR="${FBSD_BRANCH_DIR}"
-
- # This is to trick opt_mount into not failing
- INSFILE="${INSDIR}"
- ;;
+ uzip) INSFILE="${FBSD_UZIP_FILE}" ;;
+ tar) INSFILE="${FBSD_TAR_FILE}" ;;
+ split)
+ INSDIR="${FBSD_BRANCH_DIR}"
+
+ # This is to trick opt_mount into not failing
+ INSFILE="${INSDIR}"
+ ;;
esac
else
case $PACKAGETYPE in
- uzip) INSFILE="${UZIP_FILE}" ;;
- tar) INSFILE="${TAR_FILE}" ;;
+ uzip) INSFILE="${UZIP_FILE}" ;;
+ tar) INSFILE="${TAR_FILE}" ;;
esac
fi
export INSFILE
diff --git a/usr/sbin/pc-sysinstall/backend/functions-ftp.sh b/usr/sbin/pc-sysinstall/backend/functions-ftp.sh
index 93d9eae..fa05e3f 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-ftp.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-ftp.sh
@@ -23,13 +23,15 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-ftp.sh,v 1.2 2010/07/13 23:47:12 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-ftp.sh,v 1.4 2010/08/24 06:11:46 imp Exp $
# Functions which runs commands on the system
. ${BACKEND}/functions.sh
. ${BACKEND}/functions-parse.sh
+DEFAULT_FTP_SERVER="ftp.freebsd.org"
+
MAIN_FTP_SERVERS="\
Main Site: ftp.freebsd.org"
@@ -274,7 +276,48 @@ show_mirrors()
done
IFS="${SAVE_IFS}"
fi
-}
+};
+
+set_ftp_mirror()
+{
+ MIRROR="${1}"
+ echo "${MIRROR}" > "${CONFDIR}/mirrors.conf"
+};
+
+get_ftp_mirror()
+{
+ MIRROR="${DEFAULT_FTP_SERVER}"
+ if [ -f "${CONFDIR}/mirrors.conf" ]
+ then
+ MIRROR=`cat "${CONFDIR}/mirrors.conf"`
+ fi
+
+ VAL="${MIRROR}"
+ export VAL
+};
+
+
+get_ftpHost()
+{
+ get_value_from_cfg ftpPath
+ ftpPath="$VAL"
+
+ ftpHost=`echo "${ftpPath}" | sed -E 's|^(ftp://)([^/]*)(.*)|\2|'`
+ VAL="${ftpHost}"
+
+ export VAL
+};
+
+get_ftpDir()
+{
+ get_value_from_cfg ftpPath
+ ftpPath="$VAL"
+
+ ftpDir=`echo "${ftpPath}" | sed -E 's|^(ftp://)([^/]*)(.*)|\3|'`
+ VAL="${ftpDir}"
+
+ export VAL
+};
get_ftp_mirrors()
{
@@ -371,4 +414,4 @@ get_ftp_mirrors()
fi
export VAL
-}
+};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-installcomponents.sh b/usr/sbin/pc-sysinstall/backend/functions-installcomponents.sh
index 4744765..5aa6f84 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-installcomponents.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-installcomponents.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-installcomponents.sh,v 1.4 2010/09/08 20:10:24 imp Exp $
# Functions which check and load any optional modules specified in the config
@@ -52,23 +52,27 @@ copy_component()
CFILEMD5="`echo $line | cut -d ':' -f 2`"
CFILE2MD5="`echo $line | cut -d ':' -f 3`"
-
case ${INSTALLMEDIUM} in
- dvd|usb) # On both dvd / usb, we can just copy the file
- cp ${CDMNT}/${COMPFILEDIR}/${SUBDIR}/${CFILE} \
- ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
- RESULT="$?"
- ;;
- ftp) get_value_from_cfg ftpPath
- if [ -z "$VAL" ]
- then
- exit_err "ERROR: Install medium was set to ftp, but no ftpPath was provided!"
- fi
- FTPPATH="${VAL}"
-
- fetch_file "${FTPPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE}" "${FSMNT}/${COMPTMPDIR}/${CFILE}" "0"
+ dvd|usb)
+ # On both dvd / usb, we can just copy the file
+ cp ${CDMNT}/${COMPFILEDIR}/${SUBDIR}/${CFILE} \
+ ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
RESULT="$?"
- ;;
+ ;;
+
+ ftp)
+ get_value_from_cfg ftpPath
+ if [ -z "$VAL" ]
+ then
+ exit_err "ERROR: Install medium was set to ftp, but no ftpPath was provided!"
+ fi
+ FTPPATH="${VAL}"
+
+ fetch_file "${FTPPATH}/${COMPFILEDIR}/${SUBDIR}/${CFILE}" "${FSMNT}/${COMPTMPDIR}/${CFILE}" "0"
+ RESULT="$?"
+ ;;
+
+ sftp) ;;
esac
if [ "${RESULT}" != "0" ]
@@ -120,47 +124,44 @@ export CFILE
sh ${COMPTMPDIR}/install.sh
" >${FSMNT}/.componentwrapper.sh
- chmod 755 ${FSMNT}/.componentwrapper.sh
+ chmod 755 ${FSMNT}/.componentwrapper.sh
- # Copy over the install script for this component
- cp ${COMPDIR}/${COMPONENT}/install.sh ${FSMNT}/${COMPTMPDIR}/
-
- echo_log "INSTALL COMPONENT: ${i}"
- chroot ${FSMNT} /.componentwrapper.sh >>${LOGOUT} 2>>${LOGOUT}
- rm ${FSMNT}/.componentwrapper.sh
+ # Copy over the install script for this component
+ cp ${COMPDIR}/${COMPONENT}/install.sh ${FSMNT}/${COMPTMPDIR}/
+ echo_log "INSTALL COMPONENT: ${i}"
+ chroot ${FSMNT} /.componentwrapper.sh >>${LOGOUT} 2>>${LOGOUT}
+ rm ${FSMNT}/.componentwrapper.sh
};
# Check for any modules specified, and begin loading them
install_components()
{
- # First, lets check and see if we even have any optional modules
- get_value_from_cfg installComponents
- if [ ! -z "${VAL}" ]
- then
- # Lets start by cleaning up the string and getting it ready to parse
- strip_white_space ${VAL}
- COMPONENTS=`echo ${VAL} | sed -e "s|,| |g"`
- for i in $COMPONENTS
- do
- if [ ! -e "${COMPDIR}/${i}/install.sh" -o ! -e "${COMPDIR}/${i}/distfiles" ]
- then
- echo_log "WARNING: Component ${i} doesn't seem to exist"
- else
-
- # Make the tmpdir on the disk
- mkdir -p ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
-
- # Start by grabbing the component files
- copy_component ${i}
+ # First, lets check and see if we even have any optional modules
+ get_value_from_cfg installComponents
+ if [ ! -z "${VAL}" ]
+ then
+ # Lets start by cleaning up the string and getting it ready to parse
+ strip_white_space ${VAL}
+ COMPONENTS=`echo ${VAL} | sed -e "s|,| |g"`
+ for i in $COMPONENTS
+ do
+ if [ ! -e "${COMPDIR}/${i}/install.sh" -o ! -e "${COMPDIR}/${i}/distfiles" ]
+ then
+ echo_log "WARNING: Component ${i} doesn't seem to exist"
+ else
- # Remove the tmpdir now
- rm -rf ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
+ # Make the tmpdir on the disk
+ mkdir -p ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
- fi
- done
+ # Start by grabbing the component files
+ copy_component ${i}
- fi
+ # Remove the tmpdir now
+ rm -rf ${FSMNT}/${COMPTMPDIR} >>${LOGOUT} 2>>${LOGOUT}
+ fi
+ done
+ fi
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-localize.sh b/usr/sbin/pc-sysinstall/backend/functions-localize.sh
index 107a6ae..a56f957 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-localize.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-localize.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-localize.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-localize.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Functions which runs commands on the system
@@ -63,66 +63,66 @@ localize_pcbsd()
localize_x_keyboard()
{
- KEYMOD="$1"
- KEYLAY="$2"
- KEYVAR="$3"
- COUNTRY="$4"
- OPTION="grp:alt_shift_toggle"
- SETXKBMAP=""
-
- if [ "${COUNTRY}" = "NONE" -o "${COUNTRY}" = "us" -o "${COUNTRY}" = "C" ] ; then
- #In this case we don't need any additional language
- COUNTRY=""
- OPTION=""
- else
- COUNTRY=",${COUNTRY}"
- fi
-
- if [ "${KEYMOD}" != "NONE" ]
- then
- SETXKBMAP="-model ${KEYMOD}"
- KXMODEL="${KEYMOD}"
- else
- KXMODEL="pc104"
- fi
-
- if [ "${KEYLAY}" != "NONE" ]
- then
- localize_key_layout "$KEYLAY"
- SETXKBMAP="${SETXKBMAP} -layout ${KEYLAY}"
- KXLAYOUT="${KEYLAY}"
- else
- KXLAYOUT="us"
- fi
-
- if [ "${KEYVAR}" != "NONE" ]
- then
- SETXKBMAP="${SETXKBMAP} -variant ${KEYVAR}"
- KXVAR="(${KEYVAR})"
- else
- KXVAR=""
- fi
-
- # Setup .xprofile with our setxkbmap call now
- if [ ! -z "${SETXKBMAP}" ]
- then
- if [ ! -e "${FSMNT}/usr/share/skel/.xprofile" ]
- then
- echo "#!/bin/sh" >${FSMNT}/usr/share/skel/.xprofile
- fi
-
- # Save the keyboard layout for user / root X logins
- echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/share/skel/.xprofile
- chmod 755 ${FSMNT}/usr/share/skel/.xprofile
- cp ${FSMNT}/usr/share/skel/.xprofile ${FSMNT}/root/.xprofile
-
- # Save it for KDM
- echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/local/kde4/share/config/kdm/Xsetup
- fi
+ KEYMOD="$1"
+ KEYLAY="$2"
+ KEYVAR="$3"
+ COUNTRY="$4"
+ OPTION="grp:alt_shift_toggle"
+ SETXKBMAP=""
+
+ if [ "${COUNTRY}" = "NONE" -o "${COUNTRY}" = "us" -o "${COUNTRY}" = "C" ] ; then
+ #In this case we don't need any additional language
+ COUNTRY=""
+ OPTION=""
+ else
+ COUNTRY=",${COUNTRY}"
+ fi
+
+ if [ "${KEYMOD}" != "NONE" ]
+ then
+ SETXKBMAP="-model ${KEYMOD}"
+ KXMODEL="${KEYMOD}"
+ else
+ KXMODEL="pc104"
+ fi
+
+ if [ "${KEYLAY}" != "NONE" ]
+ then
+ localize_key_layout "$KEYLAY"
+ SETXKBMAP="${SETXKBMAP} -layout ${KEYLAY}"
+ KXLAYOUT="${KEYLAY}"
+ else
+ KXLAYOUT="us"
+ fi
+
+ if [ "${KEYVAR}" != "NONE" ]
+ then
+ SETXKBMAP="${SETXKBMAP} -variant ${KEYVAR}"
+ KXVAR="(${KEYVAR})"
+ else
+ KXVAR=""
+ fi
+
+ # Setup .xprofile with our setxkbmap call now
+ if [ ! -z "${SETXKBMAP}" ]
+ then
+ if [ ! -e "${FSMNT}/usr/share/skel/.xprofile" ]
+ then
+ echo "#!/bin/sh" >${FSMNT}/usr/share/skel/.xprofile
+ fi
+
+ # Save the keyboard layout for user / root X logins
+ echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/share/skel/.xprofile
+ chmod 755 ${FSMNT}/usr/share/skel/.xprofile
+ cp ${FSMNT}/usr/share/skel/.xprofile ${FSMNT}/root/.xprofile
+
+ # Save it for KDM
+ echo "setxkbmap ${SETXKBMAP}" >>${FSMNT}/usr/local/kde4/share/config/kdm/Xsetup
+ fi
# Create the kxkbrc configuration using these options
- echo "[Layout]
+ echo "[Layout]
DisplayNames=${KXLAYOUT}${COUNTRY}
IndicatorOnly=false
LayoutList=${KXLAYOUT}${KXVAR}${COUNTRY}
@@ -211,157 +211,194 @@ localize_get_codes()
TARGETLANG="${1}"
# Setup the presets for the specific lang
case $TARGETLANG in
- af) COUNTRY="C"
- SETLANG="af"
- LOCALE="af_ZA"
- ;;
- ar) COUNTRY="C"
- SETLANG="ar"
- LOCALE="en_US"
- ;;
- az) COUNTRY="C"
- SETLANG="az"
- LOCALE="en_US"
- ;;
- ca) COUNTRY="es"
- SETLANG="es:ca"
- LOCALE="ca_ES"
- ;;
- be) COUNTRY="be"
- SETLANG="be"
- LOCALE="be_BY"
- ;;
- bn) COUNTRY="bn"
- SETLANG="bn"
- LOCALE="en_US"
- ;;
- bg) COUNTRY="bg"
- SETLANG="bg"
- LOCALE="bg_BG"
- ;;
- cs) COUNTRY="cz"
- SETLANG="cs"
- LOCALE="cs_CZ"
- ;;
- da) COUNTRY="dk"
- SETLANG="da"
- LOCALE="da_DK"
- ;;
- de) COUNTRY="de"
- SETLANG="de"
- LOCALE="de_DE"
- ;;
- en_GB) COUNTRY="gb"
- SETLANG="en_GB:cy"
- LOCALE="en_GB"
- ;;
- el) COUNTRY="gr"
- SETLANG="el:gr"
- LOCALE="el_GR"
- ;;
- es) COUNTRY="es"
- SETLANG="es"
- LOCALE="es_ES"
- ;;
- es_LA) COUNTRY="us"
- SETLANG="es:en_US"
- LOCALE="es_ES"
- ;;
- et) COUNTRY="ee"
- SETLANG="et"
- LOCALE="et_EE"
- ;;
- fr) COUNTRY="fr"
- SETLANG="fr"
- LOCALE="fr_FR"
- ;;
- he) COUNTRY="il"
- SETLANG="he:ar"
- LOCALE="he_IL"
- ;;
- hr) COUNTRY="hr"
- SETLANG="hr"
- LOCALE="hr_HR"
- ;;
- hu) COUNTRY="hu"
- SETLANG="hu"
- LOCALE="hu_HU"
- ;;
- it) COUNTRY="it"
- SETLANG="it"
- LOCALE="it_IT"
- ;;
- ja) COUNTRY="jp"
- SETLANG="ja"
- LOCALE="ja_JP"
- ;;
- ko) COUNTRY="kr"
- SETLANG="ko"
- LOCALE="ko_KR"
- ;;
- nl) COUNTRY="nl"
- SETLANG="nl"
- LOCALE="nl_NL"
- ;;
- nn) COUNTRY="no"
- SETLANG="nn"
- LOCALE="en_US"
- ;;
- pa) COUNTRY="pa"
- SETLANG="pa"
- LOCALE="en_US"
- ;;
- pl) COUNTRY="pl"
- SETLANG="pl"
- LOCALE="pl_PL"
- ;;
- pt) COUNTRY="pt"
- SETLANG="pt"
- LOCALE="pt_PT"
- ;;
- pt_BR) COUNTRY="br"
- SETLANG="pt_BR"
- LOCALE="pt_BR"
- ;;
- ru) COUNTRY="ru"
- SETLANG="ru"
- LOCALE="ru_RU"
- ;;
- sl) COUNTRY="si"
- SETLANG="sl"
- LOCALE="sl_SI"
- ;;
- sk) COUNTRY="sk"
- SETLANG="sk"
- LOCALE="sk_SK"
- ;;
- sv) COUNTRY="se"
- SETLANG="sv"
- LOCALE="sv_SE"
- ;;
- uk) COUNTRY="ua"
- SETLANG="uk"
- LOCALE="uk_UA"
- ;;
- vi) COUNTRY="vn"
- SETLANG="vi"
- LOCALE="en_US"
- ;;
- zh_CN) COUNTRY="cn"
- SETLANG="zh_CN"
- LOCALE="zh_CN"
- ;;
- zh_TW) COUNTRY="tw"
- SETLANG="zh_TW"
- LOCALE="zh_TW"
- ;;
- *) COUNTRY="C"
+ af)
+ COUNTRY="C"
+ SETLANG="af"
+ LOCALE="af_ZA"
+ ;;
+ ar)
+ COUNTRY="C"
+ SETLANG="ar"
+ LOCALE="en_US"
+ ;;
+ az)
+ COUNTRY="C"
+ SETLANG="az"
+ LOCALE="en_US"
+ ;;
+ ca)
+ COUNTRY="es"
+ SETLANG="es:ca"
+ LOCALE="ca_ES"
+ ;;
+ be)
+ COUNTRY="be"
+ SETLANG="be"
+ LOCALE="be_BY"
+ ;;
+ bn)
+ COUNTRY="bn"
+ SETLANG="bn"
+ LOCALE="en_US"
+ ;;
+ bg)
+ COUNTRY="bg"
+ SETLANG="bg"
+ LOCALE="bg_BG"
+ ;;
+ cs)
+ COUNTRY="cz"
+ SETLANG="cs"
+ LOCALE="cs_CZ"
+ ;;
+ da)
+ COUNTRY="dk"
+ SETLANG="da"
+ LOCALE="da_DK"
+ ;;
+ de)
+ COUNTRY="de"
+ SETLANG="de"
+ LOCALE="de_DE"
+ ;;
+ en_GB)
+ COUNTRY="gb"
+ SETLANG="en_GB:cy"
+ LOCALE="en_GB"
+ ;;
+ el)
+ COUNTRY="gr"
+ SETLANG="el:gr"
+ LOCALE="el_GR"
+ ;;
+ es)
+ COUNTRY="es"
+ SETLANG="es"
+ LOCALE="es_ES"
+ ;;
+ es_LA)
+ COUNTRY="us"
+ SETLANG="es:en_US"
+ LOCALE="es_ES"
+ ;;
+ et)
+ COUNTRY="ee"
+ SETLANG="et"
+ LOCALE="et_EE"
+ ;;
+ fr)
+ COUNTRY="fr"
+ SETLANG="fr"
+ LOCALE="fr_FR"
+ ;;
+ he)
+ COUNTRY="il"
+ SETLANG="he:ar"
+ LOCALE="he_IL"
+ ;;
+ hr)
+ COUNTRY="hr"
+ SETLANG="hr"
+ LOCALE="hr_HR"
+ ;;
+ hu)
+ COUNTRY="hu"
+ SETLANG="hu"
+ LOCALE="hu_HU"
+ ;;
+ it)
+ COUNTRY="it"
+ SETLANG="it"
+ LOCALE="it_IT"
+ ;;
+ ja)
+ COUNTRY="jp"
+ SETLANG="ja"
+ LOCALE="ja_JP"
+ ;;
+ ko)
+ COUNTRY="kr"
+ SETLANG="ko"
+ LOCALE="ko_KR"
+ ;;
+ nl)
+ COUNTRY="nl"
+ SETLANG="nl"
+ LOCALE="nl_NL"
+ ;;
+ nn)
+ COUNTRY="no"
+ SETLANG="nn"
+ LOCALE="en_US"
+ ;;
+ pa)
+ COUNTRY="pa"
+ SETLANG="pa"
+ LOCALE="en_US"
+ ;;
+ pl)
+ COUNTRY="pl"
+ SETLANG="pl"
+ LOCALE="pl_PL"
+ ;;
+ pt)
+ COUNTRY="pt"
+ SETLANG="pt"
+ LOCALE="pt_PT"
+ ;;
+ pt_BR)
+ COUNTRY="br"
+ SETLANG="pt_BR"
+ LOCALE="pt_BR"
+ ;;
+ ru)
+ COUNTRY="ru"
+ SETLANG="ru"
+ LOCALE="ru_RU"
+ ;;
+ sl)
+ COUNTRY="si"
+ SETLANG="sl"
+ LOCALE="sl_SI"
+ ;;
+ sk)
+ COUNTRY="sk"
+ SETLANG="sk"
+ LOCALE="sk_SK"
+ ;;
+ sv)
+ COUNTRY="se"
+ SETLANG="sv"
+ LOCALE="sv_SE"
+ ;;
+ uk)
+ COUNTRY="ua"
+ SETLANG="uk"
+ LOCALE="uk_UA"
+ ;;
+ vi)
+ COUNTRY="vn"
+ SETLANG="vi"
+ LOCALE="en_US"
+ ;;
+ zh_CN)
+ COUNTRY="cn"
+ SETLANG="zh_CN"
+ LOCALE="zh_CN"
+ ;;
+ zh_TW)
+ COUNTRY="tw"
+ SETLANG="zh_TW"
+ LOCALE="zh_TW"
+ ;;
+ *)
+ COUNTRY="C"
SETLANG="${TARGETLANG}"
LOCALE="en_US"
;;
esac
- export COUNTRY SETLANG LOCALE
+ export COUNTRY SETLANG LOCALE
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-mountdisk.sh b/usr/sbin/pc-sysinstall/backend/functions-mountdisk.sh
index e4f94af..9424a62 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-mountdisk.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-mountdisk.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-mountdisk.sh,v 1.5 2010/10/09 08:52:09 imp Exp $
# Functions related mounting the newly formatted disk partitions
@@ -52,32 +52,32 @@ mount_partition()
#We are on ZFS, lets setup this mount-point
if [ "${PARTFS}" = "ZFS" ]
then
- ZPOOLNAME=$(get_zpool_name "${PART}")
-
- # Check if we have multiple zfs mounts specified
- for ZMNT in `echo ${MNTPOINT} | sed 's|,| |g'`
- do
- # First make sure we create the mount point
- if [ ! -d "${FSMNT}${ZMNT}" ] ; then
- mkdir -p ${FSMNT}${ZMNT} >>${LOGOUT} 2>>${LOGOUT}
- fi
-
- if [ "${ZMNT}" = "/" ] ; then
- ZNAME=""
- else
- ZNAME="${ZMNT}"
- echo_log "zfs create -p ${ZPOOLNAME}${ZNAME}"
- rc_halt "zfs create -p ${ZPOOLNAME}${ZNAME}"
- fi
- sleep 2
- rc_halt "zfs set mountpoint=${FSMNT}${ZNAME} ${ZPOOLNAME}${ZNAME}"
-
- # Disable atime for this zfs partition, speed increase
- rc_nohalt "zfs set atime=off ${ZPOOLNAME}${ZNAME}"
- done
+ ZPOOLNAME=$(get_zpool_name "${PART}")
+
+ # Check if we have multiple zfs mounts specified
+ for ZMNT in `echo ${MNTPOINT} | sed 's|,| |g'`
+ do
+ # First make sure we create the mount point
+ if [ ! -d "${FSMNT}${ZMNT}" ] ; then
+ mkdir -p ${FSMNT}${ZMNT} >>${LOGOUT} 2>>${LOGOUT}
+ fi
+
+ if [ "${ZMNT}" = "/" ] ; then
+ ZNAME=""
+ else
+ ZNAME="${ZMNT}"
+ echo_log "zfs create -p ${ZPOOLNAME}${ZNAME}"
+ rc_halt "zfs create -p ${ZPOOLNAME}${ZNAME}"
+ fi
+ sleep 2
+ rc_halt "zfs set mountpoint=${FSMNT}${ZNAME} ${ZPOOLNAME}${ZNAME}"
+
+ # Disable atime for this zfs partition, speed increase
+ rc_nohalt "zfs set atime=off ${ZPOOLNAME}${ZNAME}"
+ done
else
- # If we are not on ZFS, lets do the mount now
+ # If we are not on ZFS, lets do the mount now
# First make sure we create the mount point
if [ ! -d "${FSMNT}${MNTPOINT}" ]
then
@@ -94,17 +94,17 @@ mount_partition()
# Mounts all the new file systems to prepare for installation
mount_all_filesystems()
{
- # Make sure our mount point exists
- mkdir -p ${FSMNT} >/dev/null 2>/dev/null
-
- # First lets find and mount the / partition
- #########################################################
- for PART in `ls ${PARTDIR}`
- do
- if [ ! -e "/dev/${PART}" ]
- then
- exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
- fi
+ # Make sure our mount point exists
+ mkdir -p ${FSMNT} >/dev/null 2>/dev/null
+
+ # First lets find and mount the / partition
+ #########################################################
+ for PART in `ls ${PARTDIR}`
+ do
+ if [ ! -e "/dev/${PART}" ]
+ then
+ exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
+ fi
PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
@@ -122,69 +122,70 @@ mount_all_filesystems()
if [ "$?" = "0" -o "$PARTMNT" = "/" ]
then
case ${PARTFS} in
- UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime"
- ;;
- UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime"
- ;;
- UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime"
- ;;
- ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT}
- ;;
- *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
+ UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+SUJ) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" ;;
+ ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT} ;;
+ IMAGE) mount_partition ${PART} ${PARTFS} ${PARTMNT} ;;
+ *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
esac
-
fi
+ done
+
+ # Now that we've mounted "/" lets do any other remaining mount-points
+ ##################################################################
+ for PART in `ls ${PARTDIR}`
+ do
+ if [ ! -e "/dev/${PART}" ]
+ then
+ exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
+ fi
- done
-
- # Now that we've mounted "/" lets do any other remaining mount-points
- ##################################################################
- for PART in `ls ${PARTDIR}`
- do
- if [ ! -e "/dev/${PART}" ]
- then
- exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
- fi
-
- PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
- PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
- PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
-
- if [ "${PARTENC}" = "ON" ]
- then
- EXT=".eli"
- else
- EXT=""
- fi
-
- # Check if we've found "/" again, don't need to mount it twice
- echo "$PARTMNT" | grep "/," >/dev/null
- if [ "$?" != "0" -a "$PARTMNT" != "/" ]
- then
+ PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
+ PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
+ PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
+
+ if [ "${PARTENC}" = "ON" ]
+ then
+ EXT=".eli"
+ else
+ EXT=""
+ fi
+
+ # Check if we've found "/" again, don't need to mount it twice
+ echo "$PARTMNT" | grep "/," >/dev/null
+ if [ "$?" != "0" -a "$PARTMNT" != "/" ]
+ then
case ${PARTFS} in
- UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime"
- ;;
- UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime"
- ;;
- UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime"
- ;;
- ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT}
- ;;
- SWAP) # Lets enable this swap now
- if [ "$PARTENC" = "ON" ]
- then
- echo_log "Enabling encrypted swap on /dev/${PART}"
- rc_halt "geli onetime -d -e 3des ${PART}"
- sleep 5
- rc_halt "swapon /dev/${PART}.eli"
- else
- echo_log "swapon ${PART}"
- sleep 5
- rc_halt "swapon /dev/${PART}"
- fi
- ;;
- *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
- esac
- fi
- done
+ UFS) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+S) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+SUJ) mount_partition ${PART}${EXT} ${PARTFS} ${PARTMNT} "noatime" ;;
+ UFS+J) mount_partition ${PART}${EXT}.journal ${PARTFS} ${PARTMNT} "async,noatime" ;;
+ ZFS) mount_partition ${PART} ${PARTFS} ${PARTMNT} ;;
+ SWAP)
+ # Lets enable this swap now
+ if [ "$PARTENC" = "ON" ]
+ then
+ echo_log "Enabling encrypted swap on /dev/${PART}"
+ rc_halt "geli onetime -d -e 3des ${PART}"
+ sleep 5
+ rc_halt "swapon /dev/${PART}.eli"
+ else
+ echo_log "swapon ${PART}"
+ sleep 5
+ rc_halt "swapon /dev/${PART}"
+ fi
+ ;;
+ IMAGE)
+ if [ ! -d "${PARTMNT}" ]
+ then
+ mkdir -p "${PARTMNT}"
+ fi
+ mount_partition ${PART} ${PARTFS} ${PARTMNT}
+ ;;
+ *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
+ esac
+ fi
+ done
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-mountoptical.sh b/usr/sbin/pc-sysinstall/backend/functions-mountoptical.sh
index e9147ca..1e0eff3 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-mountoptical.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-mountoptical.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-mountoptical.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Functions which perform mounting / unmounting and switching of
# optical / usb media
@@ -34,114 +34,114 @@
# Displays an optical failure message
opt_fail()
{
- # If we got here, we must not have a DVD/USB we can find :(
- get_value_from_cfg installInteractive
- if [ "${VAL}" = "yes" ]
- then
- # We are running interactive, and didn't find a DVD, prompt user again
- echo_log "DISK ERROR: Unable to find installation disk!"
- echo_log "Please insert the installation disk and press enter."
- read tmp
- else
- exit_err "ERROR: Unable to locate installation DVD/USB"
- fi
+ # If we got here, we must not have a DVD/USB we can find :(
+ get_value_from_cfg installInteractive
+ if [ "${VAL}" = "yes" ]
+ then
+ # We are running interactive, and didn't find a DVD, prompt user again
+ echo_log "DISK ERROR: Unable to find installation disk!"
+ echo_log "Please insert the installation disk and press enter."
+ read tmp
+ else
+ exit_err "ERROR: Unable to locate installation DVD/USB"
+ fi
};
# Performs the extraction of data to disk
opt_mount()
{
- FOUND="0"
-
- # Ensure we have a directory where its supposed to be
- if [ ! -d "${CDMNT}" ]
- then
- mkdir -p ${CDMNT}
- fi
-
-
- # Start by checking if we already have a cd mounted at CDMNT
- mount | grep "${CDMNT} " >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- if [ -e "${CDMNT}/${INSFILE}" ]
- then
- echo "MOUNTED" >${TMPDIR}/cdmnt
- echo_log "FOUND DVD: MOUNTED"
- FOUND="1"
- return
- fi
-
- # failed to find optical disk
- opt_fail
- return
- fi
-
-# Setup our loop to search for installation media
- while
- z=1
- do
-
- # Loop though and look for an installation disk
- for i in `ls -1 /dev/acd* /dev/cd* /dev/scd* /dev/rscd* 2>/dev/null`
- do
- # Find the CD Device
- /sbin/mount_cd9660 $i ${CDMNT}
-
- # Check the package type to see if we have our install data
- if [ -e "${CDMNT}/${INSFILE}" ]
- then
- echo "${i}" >${TMPDIR}/cdmnt
- echo_log "FOUND DVD: ${i}"
- FOUND="1"
- break
- fi
- /sbin/umount ${CDMNT} >/dev/null 2>/dev/null
- done
-
- # If no DVD found, try USB
- if [ "$FOUND" != "1" ]
- then
- # Loop though and look for an installation disk
- for i in `ls -1 /dev/da* 2>/dev/null`
- do
- # Check if we can mount this device UFS
- /sbin/mount -r $i ${CDMNT}
-
- # Check the package type to see if we have our install data
- if [ -e "${CDMNT}/${INSFILE}" ]
- then
- echo "${i}" >${TMPDIR}/cdmnt
- echo_log "FOUND USB: ${i}"
- FOUND="1"
- break
- fi
- /sbin/umount ${CDMNT} >/dev/null 2>/dev/null
-
- # Also check if it is a FAT mount
- /sbin/mount -r -t msdosfs $i ${CDMNT}
-
- # Check the package type to see if we have our install data
- if [ -e "${CDMNT}/${INSFILE}" ]
- then
- echo "${i}" >${TMPDIR}/cdmnt
- echo_log "FOUND USB: ${i}"
- FOUND="1"
- break
- fi
- /sbin/umount ${CDMNT} >/dev/null 2>/dev/null
- done
- fi # End of USB Check
-
-
- if [ "$FOUND" = "1" ]
- then
- break
- fi
+ FOUND="0"
+
+ # Ensure we have a directory where its supposed to be
+ if [ ! -d "${CDMNT}" ]
+ then
+ mkdir -p ${CDMNT}
+ fi
+
+
+ # Start by checking if we already have a cd mounted at CDMNT
+ mount | grep "${CDMNT} " >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ if [ -e "${CDMNT}/${INSFILE}" ]
+ then
+ echo "MOUNTED" >${TMPDIR}/cdmnt
+ echo_log "FOUND DVD: MOUNTED"
+ FOUND="1"
+ return
+ fi
+
+ # failed to find optical disk
+ opt_fail
+ return
+ fi
+
+ # Setup our loop to search for installation media
+ while
+ z=1
+ do
+
+ # Loop though and look for an installation disk
+ for i in `ls -1 /dev/acd* /dev/cd* /dev/scd* /dev/rscd* 2>/dev/null`
+ do
+ # Find the CD Device
+ /sbin/mount_cd9660 $i ${CDMNT}
+
+ # Check the package type to see if we have our install data
+ if [ -e "${CDMNT}/${INSFILE}" ]
+ then
+ echo "${i}" >${TMPDIR}/cdmnt
+ echo_log "FOUND DVD: ${i}"
+ FOUND="1"
+ break
+ fi
+ #/sbin/umount ${CDMNT} >/dev/null 2>/dev/null
+ done
+
+ # If no DVD found, try USB
+ if [ "$FOUND" != "1" ]
+ then
+ # Loop though and look for an installation disk
+ for i in `ls -1 /dev/da* 2>/dev/null`
+ do
+ # Check if we can mount this device UFS
+ /sbin/mount -r $i ${CDMNT}
+
+ # Check the package type to see if we have our install data
+ if [ -e "${CDMNT}/${INSFILE}" ]
+ then
+ echo "${i}" >${TMPDIR}/cdmnt
+ echo_log "FOUND USB: ${i}"
+ FOUND="1"
+ break
+ fi
+ #/sbin/umount ${CDMNT} >/dev/null 2>/dev/null
+
+ # Also check if it is a FAT mount
+ /sbin/mount -r -t msdosfs $i ${CDMNT}
+
+ # Check the package type to see if we have our install data
+ if [ -e "${CDMNT}/${INSFILE}" ]
+ then
+ echo "${i}" >${TMPDIR}/cdmnt
+ echo_log "FOUND USB: ${i}"
+ FOUND="1"
+ break
+ fi
+ #/sbin/umount ${CDMNT} >/dev/null 2>/dev/null
+ done
+ fi # End of USB Check
+
+
+ if [ "$FOUND" = "1" ]
+ then
+ break
+ fi
- # Failed to find a disk, take action now
- opt_fail
+ # Failed to find a disk, take action now
+ opt_fail
- done
+ done
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-networking.sh b/usr/sbin/pc-sysinstall/backend/functions-networking.sh
index 95eeaad..fa0fa06 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-networking.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-networking.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-networking.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-networking.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Functions which perform our networking setup
@@ -68,8 +68,8 @@ get_first_wired_nic()
check_is_wifi ${NIC}
if [ "$?" != "0" ]
then
- VAL="${NIC}" ; export VAL
- return
+ VAL="${NIC}" ; export VAL
+ return
fi
done < ${TMPDIR}/.niclist
fi
@@ -241,22 +241,23 @@ enable_auto_dhcp()
is_nic_active "${NIC}"
if [ "$?" = "0" ] ; then
- echo_log "Trying DHCP on $NIC $DESC"
- dhclient ${NIC} >/dev/null 2>/dev/null
- if [ "$?" = "0" ] ; then
- # Got a valid DHCP IP, we can return now
- WRKNIC="$NIC" ; export WRKNIC
- return 0
- fi
+ echo_log "Trying DHCP on $NIC $DESC"
+ dhclient ${NIC} >/dev/null 2>/dev/null
+ if [ "$?" = "0" ] ; then
+ # Got a valid DHCP IP, we can return now
+ WRKNIC="$NIC" ; export WRKNIC
+ return 0
+ fi
fi
done < ${TMPDIR}/.niclist
};
# Get the mac address of a target NIC
-get_nic_mac() {
- FOUNDMAC="`ifconfig ${1} | grep 'ether' | tr -d '\t' | cut -d ' ' -f 2`"
- export FOUNDMAC
+get_nic_mac()
+{
+ FOUNDMAC="`ifconfig ${1} | grep 'ether' | tr -d '\t' | cut -d ' ' -f 2`"
+ export FOUNDMAC
}
# Function which performs the manual setup of a target nic in the cfg
diff --git a/usr/sbin/pc-sysinstall/backend/functions-newfs.sh b/usr/sbin/pc-sysinstall/backend/functions-newfs.sh
index ec333f9..5525d1c 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-newfs.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-newfs.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-newfs.sh,v 1.3 2010/07/31 19:27:43 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-newfs.sh,v 1.6 2010/10/09 08:52:09 imp Exp $
# Functions related to disk operations using newfs
@@ -81,102 +81,137 @@ setup_zfs_filesystem()
setup_filesystems()
{
- # Create the keydir
- rm -rf ${GELIKEYDIR} >/dev/null 2>/dev/null
- mkdir ${GELIKEYDIR}
-
- # Lets go ahead and read through the saved partitions we created, and determine if we need to run
- # newfs on any of them
- for PART in `ls ${PARTDIR}`
- do
- if [ ! -e "/dev/${PART}" ]
- then
- exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
- fi
+ # Create the keydir
+ rm -rf ${GELIKEYDIR} >/dev/null 2>/dev/null
+ mkdir ${GELIKEYDIR}
+
+ # Lets go ahead and read through the saved partitions we created, and determine if we need to run
+ # newfs on any of them
+ for PART in `ls ${PARTDIR}`
+ do
+ if [ ! -e "/dev/${PART}" ]
+ then
+ exit_err "ERROR: The partition ${PART} does not exist. Failure in bsdlabel?"
+ fi
- PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
- PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
- PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
- PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`"
- PARTGEOM="`cat ${PARTDIR}/${PART} | cut -d ':' -f 5`"
- PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 6`"
-
- # Make sure journaling isn't enabled on this device
- if [ -e "/dev/${PART}.journal" ]
- then
- rc_nohalt "gjournal stop -f ${PART}.journal"
- rc_nohalt "gjournal clear ${PART}"
- fi
-
- # Setup encryption if necessary
- if [ "${PARTENC}" = "ON" -a "${PARTFS}" != "SWAP" ]
- then
- echo_log "Creating geli provider for ${PART}"
- rc_halt "dd if=/dev/random of=${GELIKEYDIR}/${PART}.key bs=64 count=1"
- rc_halt "geli init -b -s 4096 -P -K ${GELIKEYDIR}/${PART}.key /dev/${PART}"
- rc_halt "geli attach -p -k ${GELIKEYDIR}/${PART}.key /dev/${PART}"
-
- EXT=".eli"
- else
- # No Encryption
- EXT=""
- fi
-
- case ${PARTFS} in
- UFS) echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
- sleep 2
- rc_halt "newfs /dev/${PART}${EXT}"
- sleep 2
- rc_halt "sync"
- rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
- rc_halt "sync"
-
- # Set flag that we've found a boot partition
- if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
- HAVEBOOT="YES"
- fi
- sleep 2
- ;;
- UFS+S) echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
- sleep 2
- rc_halt "newfs -U /dev/${PART}${EXT}"
- sleep 2
- rc_halt "sync"
- rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
- rc_halt "sync"
- # Set flag that we've found a boot partition
- if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
- HAVEBOOT="YES"
- fi
- sleep 2
- ;;
- UFS+J) echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
- sleep 2
- rc_halt "newfs /dev/${PART}${EXT}"
- sleep 2
- rc_halt "gjournal label -f /dev/${PART}${EXT}"
- sleep 2
- rc_halt "newfs -O 2 -J /dev/${PART}${EXT}.journal"
- sleep 2
- rc_halt "sync"
- rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal"
- rc_halt "sync"
- # Set flag that we've found a boot partition
- if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
- HAVEBOOT="YES"
- fi
- sleep 2
- ;;
- ZFS) echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
- setup_zfs_filesystem "${PART}" "${PARTFS}" "${PARTMNT}" "${EXT}" "${PARTGEOM}" "${PARTXTRAOPTS}"
- ;;
- SWAP) rc_halt "sync"
- rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
- rc_halt "sync"
- sleep 2
- ;;
- *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
- esac
-
- done
+ PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
+ PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
+ PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
+ PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`"
+ PARTGEOM="`cat ${PARTDIR}/${PART} | cut -d ':' -f 5`"
+ PARTXTRAOPTS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 6`"
+ PARTIMAGE="`cat ${PARTDIR}/${PART} | cut -d ':' -f 7`"
+
+ # Make sure journaling isn't enabled on this device
+ if [ -e "/dev/${PART}.journal" ]
+ then
+ rc_nohalt "gjournal stop -f ${PART}.journal"
+ rc_nohalt "gjournal clear ${PART}"
+ fi
+
+ # Setup encryption if necessary
+ if [ "${PARTENC}" = "ON" -a "${PARTFS}" != "SWAP" ]
+ then
+ echo_log "Creating geli provider for ${PART}"
+ rc_halt "dd if=/dev/random of=${GELIKEYDIR}/${PART}.key bs=64 count=1"
+ rc_halt "geli init -b -s 4096 -P -K ${GELIKEYDIR}/${PART}.key /dev/${PART}"
+ rc_halt "geli attach -p -k ${GELIKEYDIR}/${PART}.key /dev/${PART}"
+
+ EXT=".eli"
+ else
+ # No Encryption
+ EXT=""
+ fi
+
+ case ${PARTFS} in
+ UFS)
+ echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+ sleep 2
+ rc_halt "newfs /dev/${PART}${EXT}"
+ sleep 2
+ rc_halt "sync"
+ rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
+ rc_halt "sync"
+
+ # Set flag that we've found a boot partition
+ if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
+ HAVEBOOT="YES"
+ fi
+ sleep 2
+ ;;
+
+ UFS+S)
+ echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+ sleep 2
+ rc_halt "newfs -U /dev/${PART}${EXT}"
+ sleep 2
+ rc_halt "sync"
+ rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
+ rc_halt "sync"
+ # Set flag that we've found a boot partition
+ if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
+ HAVEBOOT="YES"
+ fi
+ sleep 2
+ ;;
+
+ UFS+SUJ)
+ echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+ sleep 2
+ rc_halt "newfs -U /dev/${PART}${EXT}"
+ sleep 2
+ rc_halt "sync"
+ rc_halt "tunefs -j enable /dev/${PART}${EXT}"
+ sleep 2
+ rc_halt "sync"
+ rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
+ rc_halt "sync"
+ # Set flag that we've found a boot partition
+ if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
+ HAVEBOOT="YES"
+ fi
+ sleep 2
+ ;;
+
+
+ UFS+J)
+ echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+ sleep 2
+ rc_halt "newfs /dev/${PART}${EXT}"
+ sleep 2
+ rc_halt "gjournal label -f /dev/${PART}${EXT}"
+ sleep 2
+ rc_halt "newfs -O 2 -J /dev/${PART}${EXT}.journal"
+ sleep 2
+ rc_halt "sync"
+ rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal"
+ rc_halt "sync"
+ # Set flag that we've found a boot partition
+ if [ "$PARTMNT" = "/boot" -o "${PARTMNT}" = "/" ] ; then
+ HAVEBOOT="YES"
+ fi
+ sleep 2
+ ;;
+
+ ZFS)
+ echo_log "NEWFS: /dev/${PART} - ${PARTFS}"
+ setup_zfs_filesystem "${PART}" "${PARTFS}" "${PARTMNT}" "${EXT}" "${PARTGEOM}" "${PARTXTRAOPTS}"
+ ;;
+
+ SWAP)
+ rc_halt "sync"
+ rc_halt "glabel label ${PARTLABEL} /dev/${PART}${EXT}"
+ rc_halt "sync"
+ sleep 2
+ ;;
+
+ IMAGE)
+ write_image "${PARTIMAGE}" "${PART}"
+ sleep 2
+ ;;
+
+ *) exit_err "ERROR: Got unknown file-system type $PARTFS" ;;
+ esac
+
+ done
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-packages.sh b/usr/sbin/pc-sysinstall/backend/functions-packages.sh
index 4166f9e..ac5e213 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-packages.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-packages.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-packages.sh,v 1.1 2010/07/13 23:47:12 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-packages.sh,v 1.6 2010/09/08 20:10:24 imp Exp $
# Functions which runs commands on the system
@@ -32,117 +32,345 @@
. ${BACKEND}/functions-ftp.sh
+get_package_index_by_ftp()
+{
+ local INDEX_FILE
+ local FTP_SERVER
+
+ FTP_SERVER="${1}"
+ INDEX_FILE="INDEX"
+ USE_BZIP2=0
+
+ if [ -f "/usr/bin/bzip2" ]
+ then
+ INDEX_FILE="${INDEX_FILE}.bz2"
+ USE_BZIP2=1
+ fi
+
+ INDEX_PATH="${CONFDIR}/${INDEX_FILE}"
+ fetch_file "${FTP_SERVER}/${INDEX_FILE}" "${INDEX_PATH}" "1"
+ if [ -f "${INDEX_PATH}" ] && [ "${USE_BZIP2}" -eq "1" ]
+ then
+ bzip2 -d "${INDEX_PATH}"
+ fi
+};
+
+get_package_index_by_fs()
+{
+ local INDEX_FILE
+
+ INDEX_FILE="${CDMNT}/packages/INDEX"
+ fetch_file "${INDEX_FILE}" "${CONFDIR}/" "0"
+};
+
+get_package_index_size()
+{
+ if [ -f "${CONFDIR}/INDEX" ]
+ then
+ SIZE=`ls -l ${CONFDIR}/INDEX | awk '{ print $5 }'`
+ else
+ get_ftp_mirror
+ FTPHOST="${VAL}"
+
+ FTPDIR="/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}"
+ FTPPATH="ftp://${FTPHOST}${FTPDIR}/packages"
+
+ fetch -s "${FTPPATH}/INDEX.bz2"
+ fi
+};
+
get_package_index()
{
- FTP_SERVER="${1}"
- FTP_DIR="ftp://${FTP_SERVER}/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}/packages"
- INDEX_FILE="INDEX"
- USE_BZIP2=0
-
- if [ -f "/usr/bin/bzip2" ]
- then
- INDEX_FILE="${INDEX_FILE}.bz2"
- USE_BZIP2=1
- fi
-
- ftp "${FTP_DIR}/${INDEX_FILE}"
- if [ -f "${INDEX_FILE}" ]
- then
- if [ "${USE_BZIP2}" -eq "1" ]
- then
- bzip2 -d "${INDEX_FILE}"
- INDEX_FILE="${INDEX_FILE%.bz2}"
- fi
-
- mv "${INDEX_FILE}" "${PKGDIR}"
- fi
-}
+ RES=0
+
+ if [ -z "${INSTALLMODE}" ]
+ then
+ get_ftp_mirror
+ FTPHOST="${VAL}"
+
+ FTPDIR="/pub/FreeBSD/releases/${FBSD_ARCH}/${FBSD_BRANCH}"
+ FTPPATH="ftp://${FTPHOST}${FTPDIR}/packages"
+
+ get_package_index_by_ftp "${FTPPATH}"
+
+ else
+ get_value_from_cfg ftpHost
+ if [ -z "$VAL" ]
+ then
+ exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!"
+ fi
+
+ FTPHOST="${VAL}"
+
+ get_value_from_cfg ftpDir
+ if [ -z "$VAL" ]
+ then
+ exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!"
+ fi
+
+ FTPDIR="${VAL}"
+ FTPPATH="ftp://${FTPHOST}${FTPDIR}"
+
+ case "${INSTALLMEDIUM}" in
+ usb|dvd) get_package_index_by_fs ;;
+ ftp) get_package_index_by_ftp "${FTPPATH}" ;;
+ sftp) ;;
+ *) RES=1 ;;
+ esac
+
+ fi
+
+ return ${RES}
+};
parse_package_index()
{
- INDEX_FILE="${PKGDIR}/INDEX"
+ INDEX_FILE="${PKGDIR}/INDEX"
+
+ exec 3<&0
+ exec 0<"${INDEX_FILE}"
+
+ while read -r line
+ do
+ PKGNAME=""
+ CATEGORY=""
+ PACKAGE=""
+ DESC=""
+ DEPS=""
+ i=0
- exec 3<&0
- exec 0<"${INDEX_FILE}"
+ SAVE_IFS="${IFS}"
+ IFS="|"
- while read -r line
- do
- CATEGORY=""
- PACKAGE=""
- DESC=""
- i=0
+ for part in ${line}
+ do
+ if [ "${i}" -eq "0" ]
+ then
+ PKGNAME="${part}"
- SAVE_IFS="${IFS}"
- IFS="|"
+ elif [ "${i}" -eq "1" ]
+ then
+ PACKAGE=`basename "${part}"`
- for part in ${line}
- do
- if [ "${i}" -eq "1" ]
- then
- PACKAGE=`basename "${part}"`
+ elif [ "${i}" -eq "3" ]
+ then
+ DESC="${part}"
- elif [ "${i}" -eq "3" ]
- then
- DESC="${part}"
+ elif [ "${i}" -eq "6" ]
+ then
+ CATEGORY=`echo "${part}" | cut -f1 -d' '`
- elif [ "${i}" -eq "6" ]
- then
- CATEGORY=`echo "${part}" | cut -f1 -d' '`
- fi
+ elif [ "${i}" -eq "8" ]
+ then
+ DEPS="${part}"
+ fi
- i=$((i+1))
- done
+ i=$((i+1))
+ done
- echo "${CATEGORY}|${PACKAGE}|${DESC}" >> "${INDEX_FILE}.parsed"
- IFS="${SAVE_IFS}"
- done
+ echo "${CATEGORY}|${PACKAGE}|${DESC}" >> "${INDEX_FILE}.parsed"
+ echo "${PACKAGE}|${PKGNAME}|${DEPS}" >> "${INDEX_FILE}.deps"
- exec 0<&3
-}
+ IFS="${SAVE_IFS}"
+ done
+
+ exec 0<&3
+};
show_package_file()
{
- PKGFILE="${1}"
+ PKGFILE="${1}"
+
+ echo "Available Packages:"
- exec 3<&0
- exec 0<"${PKGFILE}"
+ exec 3<&0
+ exec 0<"${PKGFILE}"
- while read -r line
- do
- CATEGORY=`echo "${line}" | cut -f1 -d'|'`
- PACKAGE=`echo "${line}" | cut -f2 -d'|'`
- DESC=`echo "${line}" | cut -f3 -d'|'`
+ while read -r line
+ do
+ CATEGORY=`echo "${line}" | cut -f1 -d'|'`
+ PACKAGE=`echo "${line}" | cut -f2 -d'|'`
+ DESC=`echo "${line}" | cut -f3 -d'|'`
- echo "${CATEGORY}/${PACKAGE}:${DESC}"
- done
+ echo "${CATEGORY}/${PACKAGE}:${DESC}"
+ done
- exec 0<&3
-}
+ exec 0<&3
+};
show_packages_by_category()
{
- CATEGORY="${1}"
- INDEX_FILE="${PKGDIR}/INDEX.parsed"
- TMPFILE="/tmp/.pkg.cat"
+ CATEGORY="${1}"
+ INDEX_FILE="${PKGDIR}/INDEX.parsed"
+ TMPFILE="/tmp/.pkg.cat"
- grep "^${CATEGORY}|" "${INDEX_FILE}" > "${TMPFILE}"
- show_package_file "${TMPFILE}"
- rm "${TMPFILE}"
-}
+ grep "^${CATEGORY}|" "${INDEX_FILE}" > "${TMPFILE}"
+ show_package_file "${TMPFILE}"
+ rm "${TMPFILE}"
+};
show_package_by_name()
{
- CATEGORY="${1}"
- PACKAGE="${2}"
- INDEX_FILE="${PKGDIR}/INDEX.parsed"
- TMPFILE="/tmp/.pkg.cat.pak"
+ CATEGORY="${1}"
+ PACKAGE="${2}"
+ INDEX_FILE="${PKGDIR}/INDEX.parsed"
+ TMPFILE="/tmp/.pkg.cat.pak"
- grep "^${CATEGORY}|${PACKAGE}" "${INDEX_FILE}" > "${TMPFILE}"
- show_package_file "${TMPFILE}"
- rm "${TMPFILE}"
-}
+ grep "^${CATEGORY}|${PACKAGE}" "${INDEX_FILE}" > "${TMPFILE}"
+ show_package_file "${TMPFILE}"
+ rm "${TMPFILE}"
+};
show_packages()
{
- show_package_file "${PKGDIR}/INDEX.parsed"
-}
+ show_package_file "${PKGDIR}/INDEX.parsed"
+};
+
+get_package_dependencies()
+{
+ PACKAGE="${1}"
+ LONG="${2:-0}"
+ RES=0
+
+ INDEX_FILE="${PKGDIR}/INDEX.deps"
+ REGEX="^${PACKAGE}|"
+
+ if [ "${LONG}" -ne "0" ]
+ then
+ REGEX="^.*|${PACKAGE}|"
+ fi
+
+ LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null`
+ DEPS=`echo "${LINE}"|cut -f3 -d'|'`
+
+ VAL="${DEPS}"
+ export VAL
+
+ if [ -z "${VAL}" ]
+ then
+ RES=1
+ fi
+
+ return ${RES}
+};
+
+get_package_name()
+{
+ PACKAGE="${1}"
+ RES=0
+
+ INDEX_FILE="${PKGDIR}/INDEX.deps"
+ REGEX="^${PACKAGE}|"
+
+ LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null`
+ NAME=`echo "${LINE}"|cut -f2 -d'|'`
+
+ VAL="${NAME}"
+ export VAL
+
+ if [ -z "${VAL}" ]
+ then
+ RES=1
+ fi
+
+ return ${RES}
+};
+
+get_package_short_name()
+{
+ PACKAGE="${1}"
+ RES=0
+
+ INDEX_FILE="${PKGDIR}/INDEX.deps"
+ REGEX="^.*|${PACKAGE}|"
+
+ LINE=`grep "${REGEX}" "${INDEX_FILE}" 2>/dev/null`
+ NAME=`echo "${LINE}"|cut -f1 -d'|'`
+
+ VAL="${NAME}"
+ export VAL
+
+ if [ -z "${VAL}" ]
+ then
+ RES=1
+ fi
+
+ return ${RES}
+};
+
+get_package_category()
+{
+ PACKAGE="${1}"
+ INDEX_FILE="${PKGDIR}/INDEX.parsed"
+ RES=0
+
+ LINE=`grep "|${PACKAGE}|" "${INDEX_FILE}" 2>/dev/null`
+ NAME=`echo "${LINE}"|cut -f1 -d'|'`
+
+ VAL="${NAME}"
+ export VAL
+
+ if [ -z "${VAL}" ]
+ then
+ RES=1
+ fi
+
+ return ${RES}
+};
+
+fetch_package_by_ftp()
+{
+ CATEGORY="${1}"
+ PACKAGE="${2}"
+ SAVEDIR="${3}"
+
+ get_value_from_cfg ftpHost
+ if [ -z "$VAL" ]
+ then
+ exit_err "ERROR: Install medium was set to ftp, but no ftpHost was provided!"
+ fi
+ FTPHOST="${VAL}"
+
+ get_value_from_cfg ftpDir
+ if [ -z "$VAL" ]
+ then
+ exit_err "ERROR: Install medium was set to ftp, but no ftpDir was provided!"
+ fi
+ FTPDIR="${VAL}"
+
+ PACKAGE="${PACKAGE}.tbz"
+ FTP_SERVER="ftp://${FTPHOST}${FTPDIR}"
+
+ if [ ! -f "${SAVEDIR}/${PACKAGE}" ]
+ then
+ PKGPATH="${CATEGORY}/${PACKAGE}"
+ FTP_PATH="${FTP_HOST}/packages/${PKGPATH}"
+ fetch_file "${FTP_PATH}" "${SAVEDIR}/" "0"
+ fi
+};
+
+fetch_package_by_fs()
+{
+ CATEGORY="${1}"
+ PACKAGE="${2}"
+ SAVEDIR="${3}"
+
+ PACKAGE="${PACKAGE}.tbz"
+ if [ ! -f "${SAVEDIR}/${PACKAGE}" ]
+ then
+ fetch_file "${CDMNT}/packages/${CATEGORY}/${PACKAGE}" "${SAVEDIR}/" "0"
+ fi
+};
+
+fetch_package()
+{
+ CATEGORY="${1}"
+ PACKAGE="${2}"
+ SAVEDIR="${3}"
+
+ case "${INSTALLMEDIUM}" in
+ usb|dvd) fetch_package_by_fs "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;;
+ ftp) fetch_package_by_ftp "${CATEGORY}" "${PACKAGE}" "${SAVEDIR}" ;;
+ sftp) ;;
+ esac
+};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-parse.sh b/usr/sbin/pc-sysinstall/backend/functions-parse.sh
index a9453cc..d8e5723 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-parse.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-parse.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-parse.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-parse.sh,v 1.4 2010/09/08 20:10:24 imp Exp $
# functions.sh
# Library of functions which pc-sysinstall may call upon for parsing the config
@@ -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"
@@ -132,19 +133,19 @@ file_sanity_check()
then
for i in $1
do
- grep "^${i}=" $CFGF >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- LN=`grep "^${i}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '`
- if [ -z "${LN}" ]
- then
- echo "Error: Config fails sanity test! ${i}= is empty"
- exit 1
- fi
- else
- echo "Error: Config fails sanity test! Missing ${i}="
- exit 1
- fi
+ grep "^${i}=" $CFGF >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ LN=`grep "^${i}=" ${CFGF} | head -n 1 | cut -d '=' -f 2 | tr -d ' '`
+ if [ -z "${LN}" ]
+ then
+ echo "Error: Config fails sanity test! ${i}= is empty"
+ exit 1
+ fi
+ else
+ echo "Error: Config fails sanity test! Missing ${i}="
+ exit 1
+ fi
done
else
echo "Error: Missing config file, and / or values to sanity check for!"
diff --git a/usr/sbin/pc-sysinstall/backend/functions-runcommands.sh b/usr/sbin/pc-sysinstall/backend/functions-runcommands.sh
index daa8e6d..29e3606 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-runcommands.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-runcommands.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-runcommands.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-runcommands.sh,v 1.3 2010/08/19 05:59:27 imp Exp $
# Functions which runs commands on the system
@@ -37,7 +37,10 @@ run_chroot_cmd()
echo "$CMD" >${FSMNT}/.runcmd.sh
chmod 755 ${FSMNT}/.runcmd.sh
chroot ${FSMNT} sh /.runcmd.sh
+ RES=$?
+
rm ${FSMNT}/.runcmd.sh
+ return ${RES}
};
run_chroot_script()
@@ -50,8 +53,10 @@ run_chroot_script()
echo_log "Running chroot script: ${SCRIPT}"
chroot ${FSMNT} /.${SBASE}
+ RES=$?
rm ${FSMNT}/.${SBASE}
+ return ${RES}
};
@@ -64,7 +69,10 @@ run_ext_cmd()
echo "${CMD}"> ${TMPDIR}/.runcmd.sh
chmod 755 ${TMPDIR}/.runcmd.sh
sh ${TMPDIR}/.runcmd.sh
+ RES=$?
+
rm ${TMPDIR}/.runcmd.sh
+ return ${RES}
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-unmount.sh b/usr/sbin/pc-sysinstall/backend/functions-unmount.sh
index d0121dd..367cb27 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-unmount.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-unmount.sh
@@ -23,18 +23,19 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-unmount.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-unmount.sh,v 1.4 2010/10/09 07:45:24 imp Exp $
# Functions which unmount all mounted disk filesystems
# Unmount all mounted partitions under specified dir
-umount_all_dir() {
- _udir="$1"
- _umntdirs=`mount | sort -r | grep "on $_udir" | cut -d ' ' -f 3`
- for _ud in $_umntdirs
- do
- umount -f ${_ud}
- done
+umount_all_dir()
+{
+ _udir="$1"
+ _umntdirs=`mount | sort -r | grep "on $_udir" | cut -d ' ' -f 3`
+ for _ud in $_umntdirs
+ do
+ umount -f ${_ud}
+ done
}
# Script that adds our gmirror devices for syncing
@@ -58,93 +59,95 @@ start_gmirror_sync()
# Unmounts all our mounted file-systems
unmount_all_filesystems()
{
- # Copy the logfile to disk before we unmount
- cp ${LOGOUT} ${FSMNT}/root/pc-sysinstall.log
- cd /
+ # Copy the logfile to disk before we unmount
+ cp ${LOGOUT} ${FSMNT}/root/pc-sysinstall.log
+ cd /
- # Start by unmounting any ZFS partitions
- zfs_cleanup_unmount
+ # Start by unmounting any ZFS partitions
+ zfs_cleanup_unmount
- # Lets read our partition list, and unmount each
- ##################################################################
- for PART in `ls ${PARTDIR}`
- do
-
- PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
- PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
- PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
- PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`"
-
- if [ "${PARTENC}" = "ON" ]
- then
- EXT=".eli"
- else
- EXT=""
- fi
-
- #if [ "${PARTFS}" = "SWAP" ]
- #then
- # rc_nohalt "swapoff /dev/${PART}${EXT}"
- #fi
-
- # Check if we've found "/", and unmount that last
- if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ]
- then
- #rc_halt "umount -f /dev/${PART}${EXT}"
-
- # Re-check if we are missing a label for this device and create it again if so
- if [ ! -e "/dev/label/${PARTLABEL}" ]
- then
- case ${PARTFS} in
- UFS) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;;
- UFS+S) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;;
- UFS+J) glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal ;;
- *) ;;
- esac
- fi
- fi
-
- # Check if we've found "/" and make sure the label exists
- if [ "$PARTMNT" = "/" -a "${PARTFS}" != "ZFS" ]
- then
- if [ ! -e "/dev/label/${PARTLABEL}" ]
- then
- case ${PARTFS} in
- UFS) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;;
- UFS+S) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;;
- UFS+J) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal" ;;
- *) ;;
- esac
- fi
- fi
- done
-
- # Last lets the /mnt partition
- #########################################################
- #rc_nohalt "umount -f ${FSMNT}"
-
- # If are using a ZFS on "/" set it to legacy
- if [ ! -z "${FOUNDZFSROOT}" ]
- then
- #rc_halt "zfs set mountpoint=legacy ${FOUNDZFSROOT}"
- fi
+ # Lets read our partition list, and unmount each
+ ##################################################################
+ for PART in `ls ${PARTDIR}`
+ do
+
+ PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
+ PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
+ PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
+ PARTLABEL="`cat ${PARTDIR}/${PART} | cut -d ':' -f 4`"
- # If we need to relabel "/" do it now
- if [ ! -z "${ROOTRELABEL}" ]
- then
- ${ROOTRELABEL}
- fi
+ if [ "${PARTENC}" = "ON" ]
+ then
+ EXT=".eli"
+ else
+ EXT=""
+ fi
- # Unmount our CDMNT
- #rc_nohalt "umount -f ${CDMNT}" >/dev/null 2>/dev/null
+ #if [ "${PARTFS}" = "SWAP" ]
+ #then
+ # rc_nohalt "swapoff /dev/${PART}${EXT}"
+ #fi
- # Check if we need to run any gmirror syncing
- ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- # Lets start syncing now
- start_gmirror_sync
- fi
+ # Check if we've found "/", and unmount that last
+ if [ "$PARTMNT" != "/" -a "${PARTMNT}" != "none" -a "${PARTFS}" != "ZFS" ]
+ then
+ #rc_halt "umount -f /dev/${PART}${EXT}"
+
+ # Re-check if we are missing a label for this device and create it again if so
+ if [ ! -e "/dev/label/${PARTLABEL}" ]
+ then
+ case ${PARTFS} in
+ UFS) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;;
+ UFS+S) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;;
+ UFS+SUJ) glabel label ${PARTLABEL} /dev/${PART}${EXT} ;;
+ UFS+J) glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal ;;
+ *) ;;
+ esac
+ fi
+ fi
+
+ # Check if we've found "/" and make sure the label exists
+ if [ "$PARTMNT" = "/" -a "${PARTFS}" != "ZFS" ]
+ then
+ if [ ! -e "/dev/label/${PARTLABEL}" ]
+ then
+ case ${PARTFS} in
+ UFS) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;;
+ UFS+S) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;;
+ UFS+SUJ) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}" ;;
+ UFS+J) ROOTRELABEL="glabel label ${PARTLABEL} /dev/${PART}${EXT}.journal" ;;
+ *) ;;
+ esac
+ fi
+ fi
+ done
+
+ # Last lets the /mnt partition
+ #########################################################
+ #rc_nohalt "umount -f ${FSMNT}"
+
+ # If are using a ZFS on "/" set it to legacy
+ if [ ! -z "${FOUNDZFSROOT}" ]
+ then
+ rc_halt "zfs set mountpoint=legacy ${FOUNDZFSROOT}"
+ fi
+
+ # If we need to relabel "/" do it now
+ if [ ! -z "${ROOTRELABEL}" ]
+ then
+ ${ROOTRELABEL}
+ fi
+
+ # Unmount our CDMNT
+ #rc_nohalt "umount -f ${CDMNT}" >/dev/null 2>/dev/null
+
+ # Check if we need to run any gmirror syncing
+ ls ${MIRRORCFGDIR}/* >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Lets start syncing now
+ start_gmirror_sync
+ fi
};
@@ -164,43 +167,43 @@ unmount_all_filesystems_failure()
for PART in `ls ${PARTDIR}`
do
- PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
- PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
- PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
-
- #if [ "${PARTFS}" = "SWAP" ]
- #then
- # if [ "${PARTENC}" = "ON" ]
- # then
- # rc_nohalt "swapoff /dev/${PART}.eli"
- # else
- # rc_nohalt "swapoff /dev/${PART}"
- # 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 /dev/${PART}"
- #rc_nohalt "umount -f ${FSMNT}${PARTMNT}"
- fi
- done
-
- # Last lets the /mnt partition
- #########################################################
- #rc_nohalt "umount -f ${FSMNT}"
+ PARTFS="`cat ${PARTDIR}/${PART} | cut -d ':' -f 1`"
+ PARTMNT="`cat ${PARTDIR}/${PART} | cut -d ':' -f 2`"
+ PARTENC="`cat ${PARTDIR}/${PART} | cut -d ':' -f 3`"
+
+ #if [ "${PARTFS}" = "SWAP" ]
+ #then
+ # if [ "${PARTENC}" = "ON" ]
+ # then
+ # rc_nohalt "swapoff /dev/${PART}.eli"
+ # else
+ # rc_nohalt "swapoff /dev/${PART}"
+ # 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 /dev/${PART}"
+ #rc_nohalt "umount -f ${FSMNT}${PARTMNT}"
+ fi
+ done
+
+ # Last lets the /mnt partition
+ #########################################################
+ #rc_nohalt "umount -f ${FSMNT}"
- 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"
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"
+ fi
- # Unmount our CDMNT
- #rc_nohalt "umount ${CDMNT}"
+ # Unmount our CDMNT
+ #rc_nohalt "umount ${CDMNT}"
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-upgrade.sh b/usr/sbin/pc-sysinstall/backend/functions-upgrade.sh
index bf9e704..0b06630 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-upgrade.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-upgrade.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-upgrade.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Functions which perform the mounting / unmount for upgrades
@@ -43,8 +43,8 @@ mount_target_slice()
if [ -e "/dev/${MPART}" ] ; then
rc_nohalt "mount /dev/${MPART} ${FSMNT}"
if [ "$?" != "0" ] ; then
- # Check if we have ZFS tank name
- rc_halt "mount -t zfs ${MPART} ${FSMNT}"
+ # Check if we have ZFS tank name
+ rc_halt "mount -t zfs ${MPART} ${FSMNT}"
fi
else
# Check if we have ZFS tank name
@@ -104,7 +104,7 @@ done
run_chroot_cmd "rm -rf /libexec" >/dev/null 2>/dev/null
fi
-}
+};
# Mount the target upgrade partitions
mount_upgrade()
@@ -116,33 +116,33 @@ 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" ]
- then
-
- # Found a disk= entry, lets get the disk we are working on
- get_value_from_string "${line}"
- strip_white_space "$VAL"
- DISK="$VAL"
- fi
-
- echo $line | grep "^commitDiskPart" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- # Found our flag to commit this disk setup / lets do sanity check and do it
- if [ ! -z "${DISK}" ]
- then
-
- # Start mounting this slice
- mount_target_slice "${DISK}"
-
- # Increment our disk counter to look for next disk and unset
- unset DISK
- break
- else
- exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!"
- fi
- fi
+ echo $line | grep "^disk0=" >/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"
+ 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}" ]
+ then
+
+ # Start mounting this slice
+ mount_target_slice "${DISK}"
+
+ # Increment our disk counter to look for next disk and unset
+ unset DISK
+ break
+ else
+ exit_err "ERROR: commitDiskPart was called without procceding disk<num>= and partition= entries!!!"
+ fi
+ fi
done <${CFGF}
@@ -151,8 +151,8 @@ mount_upgrade()
copy_skel_files_upgrade()
{
- # Now make sure we fix any user profile scripts, which cause problems from 7.x->8.x
- echo '#!/bin/sh
+ # Now make sure we fix any user profile scripts, which cause problems from 7.x->8.x
+ echo '#!/bin/sh
cd /home
for i in `ls`
@@ -179,17 +179,17 @@ do
done
' >${FSMNT}/.fixUserProfile.sh
- chmod 755 ${FSMNT}/.fixUserProfile.sh
- chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null
- rm ${FSMNT}/.fixUserProfile.sh
+ chmod 755 ${FSMNT}/.fixUserProfile.sh
+ chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null
+ rm ${FSMNT}/.fixUserProfile.sh
- # if the user wants to keep their original .kde4 profile
- ###########################################################################
- get_value_from_cfg "upgradeKeepDesktopProfile"
- if [ "$VAL" = "YES" -o "$VAL" = "yes" ] ; then
- echo '#!/bin/sh
+ # if the user wants to keep their original .kde4 profile
+ ###########################################################################
+ get_value_from_cfg "upgradeKeepDesktopProfile"
+ if [ "$VAL" = "YES" -o "$VAL" = "yes" ] ; then
+ echo '#!/bin/sh
cd /home
for i in `ls`
do
@@ -202,11 +202,11 @@ do
fi
done
' >${FSMNT}/.fixUserProfile.sh
- chmod 755 ${FSMNT}/.fixUserProfile.sh
- chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null
- rm ${FSMNT}/.fixUserProfile.sh
+ chmod 755 ${FSMNT}/.fixUserProfile.sh
+ chroot ${FSMNT} /.fixUserProfile.sh >/dev/null 2>/dev/null
+ rm ${FSMNT}/.fixUserProfile.sh
- fi
+ fi
};
@@ -230,18 +230,18 @@ merge_old_configs()
unmount_upgrade()
{
- # If on PC-BSD, make sure we copy any fixed skel files
- if [ "$INSTALLTYPE" != "FreeBSD" ] ; then
- copy_skel_files_upgrade
- fi
+ # If on PC-BSD, make sure we copy any fixed skel files
+ if [ "$INSTALLTYPE" != "FreeBSD" ] ; then
+ copy_skel_files_upgrade
+ fi
- cd /
+ cd /
- # Unmount FS
- umount_all_dir "${FSMNT}"
+ # Unmount FS
+ umount_all_dir "${FSMNT}"
- # Run our saved unmount script for these file-systems
- rc_nohalt "umount -f ${FSMNT}"
+ # Run our saved unmount script for these file-systems
+ rc_nohalt "umount -f ${FSMNT}"
- umount ${CDMNT}
+ umount ${CDMNT}
};
diff --git a/usr/sbin/pc-sysinstall/backend/functions-users.sh b/usr/sbin/pc-sysinstall/backend/functions-users.sh
index 0c66279..be786a1 100755
--- a/usr/sbin/pc-sysinstall/backend/functions-users.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions-users.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-users.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions-users.sh,v 1.3 2010/08/24 06:11:46 imp Exp $
# Functions which runs commands on the system
@@ -72,99 +72,99 @@ setup_users()
while read line
do
- echo $line | grep "^userName=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- get_value_from_string "${line}"
- USERNAME="$VAL"
- fi
-
- echo $line | grep "^userComment=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- get_value_from_string "${line}"
- USERCOMMENT="$VAL"
- fi
-
- echo $line | grep "^userPass=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- get_value_from_string "${line}"
- USERPASS="$VAL"
- fi
-
- echo $line | grep "^userShell=" >/dev/null 2>/dev/null
- if [ "$?" = "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" ]
- then
- get_value_from_string "${line}"
- USERHOME="$VAL"
- fi
-
- echo $line | grep "^userGroups=" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- get_value_from_string "${line}"
- USERGROUPS="$VAL"
- fi
-
-
- echo $line | grep "^commitUser" >/dev/null 2>/dev/null
- if [ "$?" = "0" ]
- then
- # Found our flag to commit this user, lets check and do it
- if [ ! -z "${USERNAME}" ]
- then
-
- # Now add this user to the system, by building our args list
- ARGS="-n ${USERNAME}"
-
- if [ ! -z "${USERCOMMENT}" ]
- then
- ARGS="${ARGS} -c \"${USERCOMMENT}\""
- fi
+ echo $line | grep "^userName=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ get_value_from_string "${line}"
+ USERNAME="$VAL"
+ fi
+
+ echo $line | grep "^userComment=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ get_value_from_string "${line}"
+ USERCOMMENT="$VAL"
+ fi
+
+ echo $line | grep "^userPass=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ get_value_from_string "${line}"
+ USERPASS="$VAL"
+ fi
+
+ echo $line | grep "^userShell=" >/dev/null 2>/dev/null
+ if [ "$?" = "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" ]
+ then
+ get_value_from_string "${line}"
+ USERHOME="$VAL"
+ fi
+
+ echo $line | grep "^userGroups=" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ get_value_from_string "${line}"
+ USERGROUPS="$VAL"
+ fi
+
+
+ echo $line | grep "^commitUser" >/dev/null 2>/dev/null
+ if [ "$?" = "0" ]
+ then
+ # Found our flag to commit this user, lets check and do it
+ if [ ! -z "${USERNAME}" ]
+ then
+
+ # Now add this user to the system, by building our args list
+ ARGS="-n ${USERNAME}"
+
+ if [ ! -z "${USERCOMMENT}" ]
+ then
+ ARGS="${ARGS} -c \"${USERCOMMENT}\""
+ fi
- if [ ! -z "${USERPASS}" ]
- then
- ARGS="${ARGS} -h 0"
- echo "${USERPASS}" >${FSMNT}/.tmpPass
- else
- ARGS="${ARGS} -h -"
- rm ${FSMNT}/.tmpPass 2>/dev/null 2>/dev/null
- fi
-
- if [ ! -z "${USERSHELL}" ]
- then
- ARGS="${ARGS} -s \"${USERSHELL}\""
- else
- ARGS="${ARGS} -s \"/nonexistant\""
- fi
+ if [ ! -z "${USERPASS}" ]
+ then
+ ARGS="${ARGS} -h 0"
+ echo "${USERPASS}" >${FSMNT}/.tmpPass
+ else
+ ARGS="${ARGS} -h -"
+ rm ${FSMNT}/.tmpPass 2>/dev/null 2>/dev/null
+ fi
+
+ if [ ! -z "${USERSHELL}" ]
+ then
+ ARGS="${ARGS} -s \"${USERSHELL}\""
+ else
+ ARGS="${ARGS} -s \"/nonexistant\""
+ fi
- if [ ! -z "${USERHOME}" ]
- then
- ARGS="${ARGS} -m -d \"${USERHOME}\""
- fi
-
- if [ ! -z "${USERGROUPS}" ]
- then
- ARGS="${ARGS} -G \"${USERGROUPS}\""
- fi
-
- add_user "${ARGS}"
-
- # Unset our vars before looking for any more users
- unset USERNAME USERCOMMENT USERPASS USERSHELL USERHOME USERGROUPS
- else
- exit_err "ERROR: commitUser was called without any userName= entry!!!"
- fi
- fi
+ if [ ! -z "${USERHOME}" ]
+ then
+ ARGS="${ARGS} -m -d \"${USERHOME}\""
+ fi
+
+ if [ ! -z "${USERGROUPS}" ]
+ then
+ ARGS="${ARGS} -G \"${USERGROUPS}\""
+ fi
+
+ add_user "${ARGS}"
+
+ # Unset our vars before looking for any more users
+ unset USERNAME USERCOMMENT USERPASS USERSHELL USERHOME USERGROUPS
+ else
+ exit_err "ERROR: commitUser was called without any userName= entry!!!"
+ fi
+ fi
done <${CFGF}
diff --git a/usr/sbin/pc-sysinstall/backend/functions.sh b/usr/sbin/pc-sysinstall/backend/functions.sh
index 6221087..5d52009 100755
--- a/usr/sbin/pc-sysinstall/backend/functions.sh
+++ b/usr/sbin/pc-sysinstall/backend/functions.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/functions.sh,v 1.7 2010/10/21 22:33:50 imp Exp $
# functions.sh
# Library of functions which pc-sysinstall may call upon
@@ -98,18 +98,18 @@ strip_white_space()
# Displays an error message and exits with error 1
exit_err()
{
- # Echo the message for the users benefit
- echo "$1"
+ # Echo the message for the users benefit
+ echo "$1"
- # Save this error to the log file
- echo "${1}" >>$LOGOUT
+ # Save this error to the log file
+ echo "${1}" >>$LOGOUT
- # Check if we need to unmount any file-systems after this failure
- unmount_all_filesystems_failure
+ # Check if we need to unmount any file-systems after this failure
+ unmount_all_filesystems_failure
- echo "For more details see log file: $LOGOUT"
+ echo "For more details see log file: $LOGOUT"
- exit 1
+ exit 1
};
# Run-command, don't halt if command exits with non-0
@@ -138,7 +138,7 @@ rc_halt()
fi
echo "Running: ${CMD}" >>${LOGOUT}
- ${CMD} >>${LOGOUT} 2>>${LOGOUT}
+ eval ${CMD} >>${LOGOUT} 2>>${LOGOUT}
STATUS="$?"
if [ "${STATUS}" != "0" ]
then
@@ -195,66 +195,67 @@ echo_log()
};
# Make sure we have a numeric
-is_num() {
- expr $1 + 1 2>/dev/null
- return $?
+is_num()
+{
+ expr $1 + 1 2>/dev/null
+ return $?
}
# Function which uses "fetch" to download a file, and display a progress report
fetch_file()
{
-FETCHFILE="$1"
-FETCHOUTFILE="$2"
-EXITFAILED="$3"
-
-SIZEFILE="${TMPDIR}/.fetchSize"
-EXITFILE="${TMPDIR}/.fetchExit"
-
-rm ${SIZEFILE} 2>/dev/null >/dev/null
-rm ${FETCHOUTFILE} 2>/dev/null >/dev/null
-
-fetch -s "${FETCHFILE}" >${SIZEFILE}
-SIZE="`cat ${SIZEFILE}`"
-SIZE="`expr ${SIZE} / 1024`"
-echo "FETCH: ${FETCHFILE}"
-echo "FETCH: ${FETCHOUTFILE}" >>${LOGOUT}
-
-( fetch -o ${FETCHOUTFILE} "${FETCHFILE}" >/dev/null 2>/dev/null ; echo "$?" > ${EXITFILE} ) &
-PID="$!"
-while
-z=1
-do
-
- if [ -e "${FETCHOUTFILE}" ]
- then
- DSIZE=`du -k ${FETCHOUTFILE} | tr -d '\t' | cut -d '/' -f 1`
- if [ $(is_num "$DSIZE") ] ; then
- if [ $SIZE -lt $DSIZE ] ; then DSIZE="$SIZE"; fi
+ FETCHFILE="$1"
+ FETCHOUTFILE="$2"
+ EXITFAILED="$3"
+
+ SIZEFILE="${TMPDIR}/.fetchSize"
+ EXITFILE="${TMPDIR}/.fetchExit"
+
+ rm ${SIZEFILE} 2>/dev/null >/dev/null
+ rm ${FETCHOUTFILE} 2>/dev/null >/dev/null
+
+ fetch -s "${FETCHFILE}" >${SIZEFILE}
+ SIZE="`cat ${SIZEFILE}`"
+ SIZE="`expr ${SIZE} / 1024`"
+ echo "FETCH: ${FETCHFILE}"
+ echo "FETCH: ${FETCHOUTFILE}" >>${LOGOUT}
+
+ ( fetch -o ${FETCHOUTFILE} "${FETCHFILE}" >/dev/null 2>/dev/null ; echo "$?" > ${EXITFILE} ) &
+ PID="$!"
+ while
+ z=1
+ do
+
+ if [ -e "${FETCHOUTFILE}" ]
+ then
+ DSIZE=`du -k ${FETCHOUTFILE} | tr -d '\t' | cut -d '/' -f 1`
+ if [ $(is_num "$DSIZE") ] ; then
+ if [ $SIZE -lt $DSIZE ] ; then DSIZE="$SIZE"; fi
echo "SIZE: ${SIZE} DOWNLOADED: ${DSIZE}"
echo "SIZE: ${SIZE} DOWNLOADED: ${DSIZE}" >>${LOGOUT}
+ fi
fi
- fi
- # Check if the download is finished
- ps -p ${PID} >/dev/null 2>/dev/null
- if [ "$?" != "0" ]
- then
- break;
- fi
+ # Check if the download is finished
+ ps -p ${PID} >/dev/null 2>/dev/null
+ if [ "$?" != "0" ]
+ then
+ break;
+ fi
- sleep 2
-done
+ sleep 2
+ done
-echo "FETCHDONE"
+ echo "FETCHDONE"
-EXIT="`cat ${EXITFILE}`"
-if [ "${EXIT}" != "0" -a "$EXITFAILED" = "1" ]
-then
- exit_err "Error: Failed to download ${FETCHFILE}"
-fi
+ EXIT="`cat ${EXITFILE}`"
+ if [ "${EXIT}" != "0" -a "$EXITFAILED" = "1" ]
+ then
+ exit_err "Error: Failed to download ${FETCHFILE}"
+ fi
-return $EXIT
+ return $EXIT
};
@@ -282,3 +283,215 @@ get_zpool_name()
return
fi
};
+
+iscompressed()
+{
+ local FILE
+ local RES
+
+ FILE="$1"
+ RES=1
+
+ if echo "${FILE}" | \
+ grep -iE '\.(Z|lzo|lzw|lzma|gz|bz2|xz|zip)$' >/dev/null 2>&1
+ then
+ RES=0
+ fi
+
+ return ${RES}
+}
+
+get_compression_type()
+{
+ local FILE
+ local SUFFIX
+
+ FILE="$1"
+ SUFFIX=`echo "${FILE}" | sed -E 's|^(.+)\.(.+)$|\2|'`
+
+ VAL=""
+ SUFFIX=`echo "${SUFFIX}" | tr A-Z a-z`
+ case "${SUFFIX}" in
+ z) VAL="lzw" ;;
+ lzo) VAL="lzo" ;;
+ lzw) VAL="lzw" ;;
+ lzma) VAL="lzma" ;;
+ gz) VAL="gzip" ;;
+ bz2) VAL="bzip2" ;;
+ xz) VAL="xz" ;;
+ zip) VAL="zip" ;;
+ esac
+
+ export VAL
+}
+
+write_image()
+{
+ local DEVICE_FILE
+
+ IMAGE_FILE="$1"
+ DEVICE_FILE="$2"
+
+ if [ -z "${IMAGE_FILE}" ]
+ then
+ exit_err "ERROR: Image file not specified!"
+ fi
+
+ if [ -z "${DEVICE_FILE}" ]
+ then
+ exit_err "ERROR: Device file not specified!"
+ fi
+
+ if [ ! -f "${IMAGE_FILE}" ]
+ then
+ exit_err "ERROR: '${IMAGE_FILE}' does not exist!"
+ fi
+
+ DEVICE_FILE="${DEVICE_FILE#/dev/}"
+ DEVICE_FILE="/dev/${DEVICE_FILE}"
+
+ if [ ! -c "${DEVICE_FILE}" ]
+ then
+ exit_err "ERROR: '${DEVICE_FILE}' is not a character device!"
+ fi
+
+ if iscompressed "${IMAGE_FILE}"
+ then
+ local COMPRESSION
+
+ get_compression_type "${IMAGE_FILE}"
+ COMPRESSION="${VAL}"
+
+ case "${COMPRESSION}" in
+ lzw)
+ rc_halt "uncompress ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}"
+ IMAGE_FILE="${IMAGE_FILE%.Z}"
+ ;;
+
+ lzo)
+ rc_halt "lzop -d $IMAGE_{FILE} -c | dd of=${DEVICE_FILE}"
+ IMAGE_FILE="${IMAGE_FILE%.lzo}"
+ ;;
+
+ lzma)
+ rc_halt "lzma -d ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}"
+ IMAGE_FILE="${IMAGE_FILE%.lzma}"
+ ;;
+
+ gzip)
+ rc_halt "gunzip ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}"
+ IMAGE_FILE="${IMAGE_FILE%.gz}"
+ ;;
+
+ bzip2)
+ rc_halt "bunzip2 ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}"
+ IMAGE_FILE="${IMAGE_FILE%.bz2}"
+ ;;
+
+ xz)
+ rc_halt "xz -d ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}"
+ IMAGE_FILE="${IMAGE_FILE%.xz}"
+ ;;
+
+ zip)
+ rc_halt "unzip ${IMAGE_FILE} -c | dd of=${DEVICE_FILE}"
+ IMAGE_FILE="${IMAGE_FILE%.zip}"
+ ;;
+
+ *)
+ exit_err "ERROR: ${COMPRESSION} compression is not supported"
+ ;;
+ esac
+
+ else
+ rc_halt "dd if=${IMAGE_FILE} of=${DEVICE_FILE}"
+
+ fi
+};
+
+install_fresh()
+{
+ # Lets start setting up the disk slices now
+ setup_disk_slice
+
+ if [ -z "${ROOTIMAGE}" ]
+ then
+
+ # 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
+ fi
+
+ echo_log "Installation finished!"
+};
+
+install_image()
+{
+ # We are ready to begin extraction, lets start now
+ init_extraction
+
+ echo_log "Installation finished!"
+};
+
+install_upgrade()
+{
+ # We're going to do an upgrade, skip all the disk setup
+ # and start by mounting the target drive/slices
+ mount_upgrade
+
+ # Start the extraction process
+ init_extraction
+
+ # Do any localization in configuration
+ run_localize
+
+ # ow run any commands specified
+ run_commands
+
+ # Merge any old configuration files
+ merge_old_configs
+
+ # Check if we have any optional modules to load
+ install_components
+
+ # Check if we have any packages to install
+ install_packages
+
+ # All finished, unmount the file-systems
+ unmount_upgrade
+
+ echo_log "Upgrade finished!"
+};
diff --git a/usr/sbin/pc-sysinstall/backend/parseconfig.sh b/usr/sbin/pc-sysinstall/backend/parseconfig.sh
index 7d4a800..83c6042 100755
--- a/usr/sbin/pc-sysinstall/backend/parseconfig.sh
+++ b/usr/sbin/pc-sysinstall/backend/parseconfig.sh
@@ -23,7 +23,7 @@
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
-# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/parseconfig.sh,v 1.2 2010/06/27 16:46:11 imp Exp $
+# $FreeBSD: src/usr.sbin/pc-sysinstall/backend/parseconfig.sh,v 1.6 2010/10/09 08:52:09 imp Exp $
# Main install configuration parsing script
#
@@ -35,12 +35,15 @@
. ${BACKEND}/functions-disk.sh
. ${BACKEND}/functions-extractimage.sh
. ${BACKEND}/functions-installcomponents.sh
+. ${BACKEND}/functions-installpackages.sh
. ${BACKEND}/functions-localize.sh
. ${BACKEND}/functions-mountdisk.sh
. ${BACKEND}/functions-networking.sh
. ${BACKEND}/functions-newfs.sh
+. ${BACKEND}/functions-packages.sh
. ${BACKEND}/functions-parse.sh
. ${BACKEND}/functions-runcommands.sh
+. ${BACKEND}/functions-ftp.sh
. ${BACKEND}/functions-unmount.sh
. ${BACKEND}/functions-upgrade.sh
. ${BACKEND}/functions-users.sh
@@ -95,73 +98,23 @@ PACKAGETYPE="${VAL}" ; export PACKAGETYPE
start_networking
# If we are not doing an upgrade, lets go ahead and setup the disk
-if [ "${INSTALLMODE}" = "fresh" ]
-then
-
- # 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
-
- # 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
-
- # All finished, unmount the file-systems
- unmount_upgrade
-
- echo_log "Upgrade finished!"
- exit 0
-fi
-
+case "${INSTALLMODE}" in
+ fresh)
+ if [ "${INSTALLMEDIUM}" = "image" ]
+ then
+ install_image
+ else
+ install_fresh
+ fi
+ ;;
+
+ upgrade)
+ install_upgrade
+ ;;
+
+ *)
+ exit 1
+ ;;
+esac
+
+exit 0
OpenPOWER on IntegriCloud