|
|
@ -72,13 +72,16 @@ do
|
|
|
|
CDROOT=1
|
|
|
|
CDROOT=1
|
|
|
|
CDROOT_DEV=`parse_opt "${x}"`
|
|
|
|
CDROOT_DEV=`parse_opt "${x}"`
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
# Start livecd loop and looptype options
|
|
|
|
# Start livecd loop, looptype options and encryption
|
|
|
|
loop\=*)
|
|
|
|
loop\=*)
|
|
|
|
LOOP=`parse_opt "${x}"`
|
|
|
|
LOOP=`parse_opt "${x}"`
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
looptype\=*)
|
|
|
|
looptype\=*)
|
|
|
|
LOOPTYPE=`parse_opt "${x}"`
|
|
|
|
LOOPTYPE=`parse_opt "${x}"`
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
|
|
|
|
loop_crypt\=*)
|
|
|
|
|
|
|
|
LOOP_CRYPT=`parse_opt "${x}"`
|
|
|
|
|
|
|
|
;;
|
|
|
|
# Start Device Manager options
|
|
|
|
# Start Device Manager options
|
|
|
|
devfs)
|
|
|
|
devfs)
|
|
|
|
USE_DEVFS_NORMAL=1
|
|
|
|
USE_DEVFS_NORMAL=1
|
|
|
@ -261,7 +264,7 @@ then
|
|
|
|
mount -t tmpfs tmpfs ${NEW_ROOT}
|
|
|
|
mount -t tmpfs tmpfs ${NEW_ROOT}
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
for i in dev mnt mnt/cdrom mnt/livecd tmp tmp/.initrd mnt/gentoo sys
|
|
|
|
for i in dev mnt mnt/cdrom mnt/livecd mnt/key tmp tmp/.initrd mnt/gentoo sys
|
|
|
|
do
|
|
|
|
do
|
|
|
|
mkdir -p ${NEW_ROOT}/$i
|
|
|
|
mkdir -p ${NEW_ROOT}/$i
|
|
|
|
chmod 755 ${NEW_ROOT}/$i
|
|
|
|
chmod 755 ${NEW_ROOT}/$i
|
|
|
@ -490,66 +493,104 @@ then
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
cache_cd_contents
|
|
|
|
cache_cd_contents
|
|
|
|
# Setup the loopback mounts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ "${LOOPTYPE}" = 'normal' ]
|
|
|
|
# If encrypted, find key and mount, otherwise mount as usual
|
|
|
|
|
|
|
|
if [ "${LOOP_CRYPT}" != '' ]
|
|
|
|
then
|
|
|
|
then
|
|
|
|
good_msg 'Mounting loop filesystem'
|
|
|
|
good_msg 'You booted an encrypted livecd'
|
|
|
|
mount -t ext2 -o loop,ro ${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP} ${NEW_ROOT}/mnt/livecd
|
|
|
|
KEYNAME=$(head -n 1 ${NEW_ROOT}/mnt/cdrom/livecd)
|
|
|
|
test_success 'Mount filesystem'
|
|
|
|
|
|
|
|
FS_LOCATION='mnt/livecd'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if [ "${KEYNAME}" = '' ]
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
good_msg 'It's not locked with a gpg key, attempting to decrypt manually'
|
|
|
|
|
|
|
|
losetup -e ${LOOP_CRYPT} /dev/loop1 ${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif [ "${LOOPTYPE}" = 'squashfs' ]
|
|
|
|
else
|
|
|
|
then
|
|
|
|
good_msg 'Livecd locked with gpg key'
|
|
|
|
good_msg 'Mounting squashfs filesystem'
|
|
|
|
bootstrapKey
|
|
|
|
mount -t squashfs -o loop,ro ${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP} ${NEW_ROOT}/mnt/livecd
|
|
|
|
good_msg 'Attempting to decrypt with key'
|
|
|
|
|
|
|
|
losetup -K ${NEW_ROOT}/mnt/key/${SUBDIR}/${KEYNAME} -e ${LOOP_CRYPT} /dev/loop1 \
|
|
|
|
|
|
|
|
${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_success 'Unencrypting loop'
|
|
|
|
|
|
|
|
|
|
|
|
test_success 'Mount filesystem'
|
|
|
|
case ${LOOPTYPE} in
|
|
|
|
FS_LOCATION='mnt/livecd'
|
|
|
|
squashfs)
|
|
|
|
|
|
|
|
MOUNTTYPE="squashfs"
|
|
|
|
elif [ "${LOOPTYPE}" = 'gcloop' ]
|
|
|
|
normal)
|
|
|
|
then
|
|
|
|
MOUNTTYPE="ext2"
|
|
|
|
good_msg 'Mounting gcloop filesystem'
|
|
|
|
esac
|
|
|
|
echo ' ' | losetup -E 19 -e ucl-0 -p0 ${NEW_ROOT}/dev/loop0 ${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}
|
|
|
|
|
|
|
|
test_success 'losetup the loop device'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mount -t ext2 -o ro ${NEW_ROOT}/dev/loop0 ${NEW_ROOT}/mnt/livecd
|
|
|
|
mount -t ${MOUNTTYPE} -o ro /dev/loop1 ${NEW_ROOT}/mnt/livecd
|
|
|
|
test_success 'Mount the losetup loop device'
|
|
|
|
|
|
|
|
|
|
|
|
test_success 'Mount filesystem, checking key'
|
|
|
|
FS_LOCATION='mnt/livecd'
|
|
|
|
FS_LOCATION='mnt/livecd'
|
|
|
|
|
|
|
|
|
|
|
|
elif [ "${LOOPTYPE}" = 'zisofs' ]
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
FS_LOCATION="mnt/cdrom/${LOOPEXT}${LOOP}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif [ "${LOOPTYPE}" = 'noloop' ]
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
FS_LOCATION='mnt/cdrom'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif [ "${LOOPTYPE}" = 'sgimips' ]
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
# getdvhoff finds the starting offset (in bytes) of the squashfs
|
|
|
|
|
|
|
|
# partition on the cdrom and returns this offset for losetup
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# All currently supported SGI Systems use SCSI CD-ROMs, so
|
|
|
|
|
|
|
|
# so we know that the CD-ROM is usually going to be /dev/sr0.
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# We use the value given to losetup to set /dev/loop0 to point
|
|
|
|
|
|
|
|
# to the liveCD root partition, and then mount /dev/loop0 as
|
|
|
|
|
|
|
|
# the LiveCD rootfs
|
|
|
|
|
|
|
|
good_msg 'Locating the SGI LiveCD Root Partition'
|
|
|
|
|
|
|
|
echo ' ' | \
|
|
|
|
|
|
|
|
losetup -o $(/bin/getdvhoff ${NEW_ROOT}${REAL_ROOT} 0) \
|
|
|
|
|
|
|
|
${NEW_ROOT}${CDROOT_DEV} \
|
|
|
|
|
|
|
|
${NEW_ROOT}${REAL_ROOT}
|
|
|
|
|
|
|
|
test_success 'losetup /dev/sr0 /dev/loop0'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
good_msg 'Mounting the Root Partition'
|
|
|
|
|
|
|
|
mount -t squashfs -o ro ${NEW_ROOT}${CDROOT_DEV} ${NEW_ROOT}/mnt/livecd
|
|
|
|
|
|
|
|
test_success 'mount /dev/loop0 /'
|
|
|
|
|
|
|
|
FS_LOCATION='mnt/livecd'
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Setup the loopback mounts, if unencrypted
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
if [ "${LOOPTYPE}" = 'normal' ]
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
good_msg 'Mounting loop filesystem'
|
|
|
|
|
|
|
|
mount -t ext2 -o loop,ro ${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP} ${NEW_ROOT}/mnt/livecd
|
|
|
|
|
|
|
|
test_success 'Mount filesystem'
|
|
|
|
|
|
|
|
FS_LOCATION='mnt/livecd'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif [ "${LOOPTYPE}" = 'squashfs' ]
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
good_msg 'Mounting squashfs filesystem'
|
|
|
|
|
|
|
|
mount -t squashfs -o loop,ro ${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP} ${NEW_ROOT}/mnt/livecd
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
test_success 'Mount filesystem'
|
|
|
|
|
|
|
|
FS_LOCATION='mnt/livecd'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif [ "${LOOPTYPE}" = 'gcloop' ]
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
good_msg 'Mounting gcloop filesystem'
|
|
|
|
|
|
|
|
echo ' ' | losetup -E 19 -e ucl-0 -p0 ${NEW_ROOT}/dev/loop0 ${NEW_ROOT}/mnt/cdrom/${LOOPEXT}${LOOP}
|
|
|
|
|
|
|
|
test_success 'losetup the loop device'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mount -t ext2 -o ro ${NEW_ROOT}/dev/loop0 ${NEW_ROOT}/mnt/livecd
|
|
|
|
|
|
|
|
test_success 'Mount the losetup loop device'
|
|
|
|
|
|
|
|
FS_LOCATION='mnt/livecd'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif [ "${LOOPTYPE}" = 'zisofs' ]
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
FS_LOCATION="mnt/cdrom/${LOOPEXT}${LOOP}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif [ "${LOOPTYPE}" = 'noloop' ]
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
FS_LOCATION='mnt/cdrom'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
elif [ "${LOOPTYPE}" = 'sgimips' ]
|
|
|
|
|
|
|
|
then
|
|
|
|
|
|
|
|
# getdvhoff finds the starting offset (in bytes) of the squashfs
|
|
|
|
|
|
|
|
# partition on the cdrom and returns this offset for losetup
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# All currently supported SGI Systems use SCSI CD-ROMs, so
|
|
|
|
|
|
|
|
# so we know that the CD-ROM is usually going to be /dev/sr0.
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# We use the value given to losetup to set /dev/loop0 to point
|
|
|
|
|
|
|
|
# to the liveCD root partition, and then mount /dev/loop0 as
|
|
|
|
|
|
|
|
# the LiveCD rootfs
|
|
|
|
|
|
|
|
good_msg 'Locating the SGI LiveCD Root Partition'
|
|
|
|
|
|
|
|
echo ' ' | \
|
|
|
|
|
|
|
|
losetup -o $(/bin/getdvhoff ${NEW_ROOT}${REAL_ROOT} 0) \
|
|
|
|
|
|
|
|
${NEW_ROOT}${CDROOT_DEV} \
|
|
|
|
|
|
|
|
${NEW_ROOT}${REAL_ROOT}
|
|
|
|
|
|
|
|
test_success 'losetup /dev/sr0 /dev/loop0'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
good_msg 'Mounting the Root Partition'
|
|
|
|
|
|
|
|
mount -t squashfs -o ro ${NEW_ROOT}${CDROOT_DEV} ${NEW_ROOT}/mnt/livecd
|
|
|
|
|
|
|
|
test_success 'mount /dev/loop0 /'
|
|
|
|
|
|
|
|
FS_LOCATION='mnt/livecd'
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
#
|
|
|
|
# End cdrom looptype determination and mounting if necessary
|
|
|
|
# End cdrom looptype determination and mounting if necessary
|
|
|
|
#
|
|
|
|
#
|
|
|
|