First commit, supports multiple devices via cryptdevice=, cryptdevice1= etc

This commit is contained in:
Travis Burtrum 2016-09-26 01:03:42 -04:00
parent 4a9b980eb5
commit fbab5a5348
1 changed files with 132 additions and 111 deletions

View File

@ -4,6 +4,36 @@ run_hook() {
modprobe -a -q dm-crypt >/dev/null 2>&1
[ "${quiet}" = "y" ] && CSQUIET=">/dev/null"
count=0
while true
do
num=$count
[ $count -eq 0 ] && num=""
cryptdevice_name="cryptdevice$num"
#cryptdevice=${!cryptdevice_name} # this would work with bash
cryptdevice="$(eval echo "$""$cryptdevice_name")"
cryptkey_name="cryptkey$num"
cryptkey="$(eval echo "$""$cryptkey_name")"
crypto_name="crypto$num"
crypto="$(eval echo "$""$crypto_name")"
if [ -n "${cryptdevice}" ]; then
DEPRECATED_CRYPT=0
IFS=: read cryptdev cryptname cryptoptions <<EOF
$cryptdevice
EOF
else
if [ $count -ne 0 ]; then
break;
fi
DEPRECATED_CRYPT=1
cryptdev="${root}"
cryptname="root"
fi
# Get keyfile if specified
ckeyfile="/crypto_keyfile.bin"
if [ -n "$cryptkey" ]; then
@ -33,17 +63,6 @@ EOF
[ ! -f ${ckeyfile} ] && echo "Keyfile could not be opened. Reverting to passphrase."
fi
if [ -n "${cryptdevice}" ]; then
DEPRECATED_CRYPT=0
IFS=: read cryptdev cryptname cryptoptions <<EOF
$cryptdevice
EOF
else
DEPRECATED_CRYPT=1
cryptdev="${root}"
cryptname="root"
fi
warn_deprecated() {
echo "The syntax 'root=${root}' where '${root}' is an encrypted volume is deprecated"
echo "Use 'cryptdevice=${root}:root root=/dev/mapper/root' instead."
@ -134,6 +153,8 @@ EOF
fi
fi
rm -f ${ckeyfile}
count=$((count + 1))
done
}
# vim: set ft=sh ts=4 sw=4 et: