|
|
|
@ -6,6 +6,38 @@ entrosource="${LVP_ENTROPY_SOURCE}" |
|
|
|
process_encrypted(){ |
|
|
|
target="livesystem" |
|
|
|
|
|
|
|
for module in twofish blowfish serpent ; do |
|
|
|
eval "encryption_${module}=0" |
|
|
|
modprobe loop_${module} >/dev/null 2>&1 # fails for kernel >= 2.5.48 if module already loaded |
|
|
|
[ `lsmod | grep -c "loop_${module}"` -eq 1 ] && eval "encryption_${module}=1" |
|
|
|
done |
|
|
|
|
|
|
|
encryption_available=0 |
|
|
|
[ ${encryption_twofish} -eq 1 -o ${encryption_blowfish} -eq 1 -o ${encryption_serpent} -eq 1 ] && \ |
|
|
|
encryption_available=1 |
|
|
|
|
|
|
|
if [ ${encryption_available} -eq 0 ] ; then |
|
|
|
echo "Sorry, you do not have loop-aes on your system. Please have a look at" |
|
|
|
echo "http://loop-aes.sourceforge.net" |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
eval "avail=\${encryption_${LVP_ENCRYPTION}}" |
|
|
|
if [ "${avail}" == "0" ] ; then |
|
|
|
echo "Sorry, ${LVP_ENCRYPTION} is not available on your system." |
|
|
|
echo "Please check your kernel configuration." |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
echo "Loading kernel module for linear mode" |
|
|
|
modprobe linear 2>&1 >/dev/null || true |
|
|
|
if ! grep -q linear /proc/mdstat ; then |
|
|
|
echo "Sorry, you don't have linear RAID support in your kernel." |
|
|
|
echo "Since V0.4.2 this is required for encrypted LVPs to use" |
|
|
|
echo "available disk space more efficiently." |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
echo -n "Checking necessary filesystem size ... " |
|
|
|
filesize=0 |
|
|
|
|
|
|
|
@ -19,12 +51,13 @@ process_encrypted(){ |
|
|
|
|
|
|
|
echo -n "Checking Livesystem size ... " |
|
|
|
livesize=`du -sb ${target} --exclude=lvp.data? | cut -f1` |
|
|
|
livesize=$(( ${livesize} + `du -sb isolinux | cut -f1` )) |
|
|
|
echo "`human_readable ${livesize}`" |
|
|
|
filesize=$(( $filesize + $livesize )) |
|
|
|
filesize=$(( ${filesize} + ${livesize} )) |
|
|
|
echo |
|
|
|
echo "Total space needed: $(( ${filesize} / 1024 / 1024 )) MB" |
|
|
|
|
|
|
|
if [ $(( ${filesize} / 1024 / 1024 )) -gt $size ] ; then |
|
|
|
if [ $(( ${filesize} / 1024 / 1024 )) -gt ${size} ] ; then |
|
|
|
echo |
|
|
|
echo "This may be more than fits onto your medium." |
|
|
|
echo "You specified ${size} MB to fit onto your medium." |
|
|
|
@ -51,12 +84,22 @@ process_encrypted(){ |
|
|
|
fi |
|
|
|
done |
|
|
|
|
|
|
|
if [ ${needed_loopdevices} -gt 0 ] ; then |
|
|
|
echo "Not enough free loop-devices found!" |
|
|
|
echo "Please either free ${needed_loopdevices} more loop-devices" |
|
|
|
echo "(check with losetup -a) or increase the" |
|
|
|
echo "number of available loop-devices." |
|
|
|
exit 1 |
|
|
|
fi |
|
|
|
|
|
|
|
echo "Okay, Now creating files that will hold the pseudo filesystems" |
|
|
|
unset ddparam |
|
|
|
[ `dd --help | grep -c stat` -eq 1 ] && ddparam="conv=stat" |
|
|
|
unset cpparam |
|
|
|
cp -D ${moviefiles} /dev/null 2>&1 >/dev/null && cpparam="-D" |
|
|
|
|
|
|
|
if [ -e livesystem/lvp.data1 ] ; then |
|
|
|
for x in livesystem/lvp.data* ; do |
|
|
|
if [ -e ${target}/lvp.data1 ] ; then |
|
|
|
for x in ${target}/lvp.data* ; do |
|
|
|
if [ ${x##*lvp.data} -gt ${needed_pseudofs} ] ; then\ |
|
|
|
echo "Found ${x##*/}, but we don't need it. Deleting it." |
|
|
|
rm -f ${x} |
|
|
|
@ -68,7 +111,7 @@ process_encrypted(){ |
|
|
|
while [ ${filesystem} -lt ${needed_pseudofs} ] ; do |
|
|
|
filesystem=$(( ${filesystem} + 1 )) |
|
|
|
echo "Filesystem ${filesystem} of ${needed_pseudofs}" |
|
|
|
file="livesystem/lvp.data${filesystem}" |
|
|
|
file="${target}/lvp.data${filesystem}" |
|
|
|
|
|
|
|
if [ ${filesystem} -lt ${needed_pseudofs} ] ; then |
|
|
|
size=2147481600 |
|
|
|
@ -83,21 +126,17 @@ process_encrypted(){ |
|
|
|
echo "lvp.data${filesystem} already exists and has correct filesize. Using it." |
|
|
|
else |
|
|
|
echo "lvp.data${filesystem} already exists but has wrong filesize. Deleting it" |
|
|
|
rm -f livesystem/lvp.data${filesystem} |
|
|
|
rm -f ${target}/lvp.data${filesystem} |
|
|
|
fi |
|
|
|
fi |
|
|
|
[ -f livesystem/lvp.data${filesystem} ] && continue |
|
|
|
dd if=/dev/${entrosource} of=livesystem/lvp.data${filesystem} \ |
|
|
|
bs=2k count=$(( $size / 2048 )) ${ddparam} |
|
|
|
[ -f ${target}/lvp.data${filesystem} ] && continue |
|
|
|
dd if=/dev/${entrosource} of=${target}/lvp.data${filesystem} \ |
|
|
|
bs=2k count=$(( ${size} / 2048 )) ${ddparam} |
|
|
|
done |
|
|
|
|
|
|
|
echo "Creating mountpoints" |
|
|
|
rm -rf livesystem/mnt* |
|
|
|
filesystem=1 |
|
|
|
while [ ${filesystem} -le ${needed_pseudofs} ] ; do |
|
|
|
mkdir -p livesystem/mnt${filesystem} |
|
|
|
filesystem=$(( ${filesystem} + 1 )) |
|
|
|
done |
|
|
|
echo "Creating mountpoint" |
|
|
|
rm -rf ${target}/mnt* |
|
|
|
mkdir ${target}/mnt1 |
|
|
|
|
|
|
|
echo "Using ${LVP_ENCRYPTION} encryption." |
|
|
|
|
|
|
|
@ -107,13 +146,14 @@ process_encrypted(){ |
|
|
|
while [ "${passphrase}" != "${passphrase_confirm}" ] ; do |
|
|
|
read -p "Enter passphrase: " -s passphrase |
|
|
|
echo |
|
|
|
read -p "Confirm: " -s passphrase_confirm |
|
|
|
echo |
|
|
|
if [ "${passphrase:20}" = "" ] ; then |
|
|
|
echo "The Passphrase must be at lest 20 characters!" |
|
|
|
echo "The Passphrase must be at least 20 characters!" |
|
|
|
passphrase="MEEP" |
|
|
|
passphrase_confirm="MOOP" |
|
|
|
continue |
|
|
|
fi |
|
|
|
read -p "Confirm: " -s passphrase_confirm |
|
|
|
echo |
|
|
|
if [ "${passphrase}" != "${passphrase_confirm}" ] ; then |
|
|
|
echo "The passphrases do not match." |
|
|
|
fi |
|
|
|
@ -123,59 +163,69 @@ process_encrypted(){ |
|
|
|
lvpdata=1 |
|
|
|
while [ ${lvpdata} -le ${needed_pseudofs} ] ; do |
|
|
|
eval "lodev=\${loopdevice_${lvpdata}}" |
|
|
|
file="livesystem/lvp.data${lvpdata}" |
|
|
|
file="${target}/lvp.data${lvpdata}" |
|
|
|
|
|
|
|
echo "Setting up loopdevice ${lvpdata}" |
|
|
|
echo "${passphrase}" | losetup -p 0 -e ${LVP_ENCRYPTION}256 ${lodev} ${file} |
|
|
|
lvpdata=$(( ${lvpdata} + 1 )) |
|
|
|
done |
|
|
|
|
|
|
|
echo "Creating Filesystem ${lvpdata}" |
|
|
|
mkfs.ext2 -m 0 ${lodev} >/dev/null 2>&1 |
|
|
|
|
|
|
|
echo "Mounting Filesystem ${lvpdata}" |
|
|
|
mount ${lodev} livesystem/mnt${lvpdata} |
|
|
|
rm -rf livesystem/mnt${lvpdata}/* |
|
|
|
|
|
|
|
echo "Setting up linear device" |
|
|
|
mddev="" |
|
|
|
for x in /dev/md/* ; do |
|
|
|
[ ! -z "${mddev}" ] && break |
|
|
|
[ `mdadm --misc -Q ${x} | grep -c "not active"` -eq 1 ] && mddev="${x}" |
|
|
|
done |
|
|
|
mdloopdevs="" |
|
|
|
lvpdata=1 |
|
|
|
while [ ${lvpdata} -le ${needed_pseudofs} ] ; do |
|
|
|
eval "mdloopdevs=\"\${mdloopdevs} \${loopdevice_${lvpdata}}\"" |
|
|
|
lvpdata=$(( ${lvpdata} + 1 )) |
|
|
|
done |
|
|
|
${target}/sbin/mdadm --build ${mddev} -l linear -n ${needed_pseudofs} ${mdloopdevs} |
|
|
|
|
|
|
|
echo "Creating filesystem on ${mddev}" |
|
|
|
mkfs.ext2 -m 0 ${mddev} >/dev/null 2>&1 |
|
|
|
echo "Mounting filesystem ${mddev}" |
|
|
|
mount ${mddev} ${target}/mnt1 |
|
|
|
rm -rf ${target}/mnt1/* |
|
|
|
|
|
|
|
continue=0 |
|
|
|
while read file ; do |
|
|
|
[ ! -f "${file}" ] && continue |
|
|
|
[ ${continue} -eq 1 ] && continue |
|
|
|
[ ${continue} -eq 1 ] && break |
|
|
|
|
|
|
|
unset target |
|
|
|
unset targetdir |
|
|
|
thisfile=`ls -l "${file}" | sed 's, *, ,g' | cut -f5 -d' '` |
|
|
|
for dir in livesystem/mnt? ; do |
|
|
|
for dir in ${target}/mnt? ; do # I leave this here for historical reasons, maybe we need it again some day |
|
|
|
avail=`df -P ${dir} | grep / | sed 's, *, ,g' | cut -f4 -d' '` |
|
|
|
avail=$(( ${avail} * 1024 )) |
|
|
|
[ -z "${target}" -a ${avail} -gt ${thisfile} ] && target=${dir} |
|
|
|
[ -z "${targetdir}" -a ${avail} -gt ${thisfile} ] && targetdir=${dir} |
|
|
|
done |
|
|
|
|
|
|
|
if [ -z "${target}" ] ; then |
|
|
|
if [ -z "${targetdir}" ] ; then |
|
|
|
echo "Not enough space available for ${file}. Skipping remaining files." >&2 |
|
|
|
continue=1 |
|
|
|
fi |
|
|
|
[ ${continue} -eq 1 ] && continue |
|
|
|
|
|
|
|
echo "Copying ${file} to ${target}/${file##*/}" |
|
|
|
if [ -z "${ddparam}" ] ; then |
|
|
|
cp "${file}" "${target}/${file##*/}" |
|
|
|
else |
|
|
|
dd "if=${file}" "of=${target}/${file##*/}" bs=1k ${ddparam} |
|
|
|
fi |
|
|
|
echo "Copying ${file} to ${targetdir}/${file##*/}" |
|
|
|
cp ${cpparam} "${file}" "${targetdir}/${file##*/}" |
|
|
|
|
|
|
|
environment="`echo ${file} | tr '[. \-!]' '_'`" |
|
|
|
eval "export file_${environment##*/}=\"${target#*livesystem}/${file##*/}\"" |
|
|
|
eval "export file_${environment##*/}=\"${targetdir#*${target}}/${file##*/}\"" |
|
|
|
done < ${moviefiles} |
|
|
|
|
|
|
|
lvpxml=livesystem/mnt1/lvp.xml |
|
|
|
lvpxml=${target}/mnt1/lvp.xml |
|
|
|
process_create_lvpxml |
|
|
|
|
|
|
|
echo "Umounting filesystem ${mddev}" |
|
|
|
umount ${mddev} |
|
|
|
echo "Shutting down ${mddev}" |
|
|
|
mdadm ${mddev} -S |
|
|
|
|
|
|
|
lvpdata=${needed_pseudofs} |
|
|
|
while [ ${lvpdata} -ge 1 ] ; do |
|
|
|
echo "Umounting Filesystem ${lvpdata}" |
|
|
|
umount livesystem/mnt${lvpdata} |
|
|
|
|
|
|
|
eval "lodev=\${loopdevice_${lvpdata}}" |
|
|
|
echo "Shutting down loopdevice ${lodev}" |
|
|
|
losetup -d ${lodev} |
|
|
|
|