summaryrefslogtreecommitdiff
path: root/sys-boot/myinitramfs/files/init.enc
diff options
context:
space:
mode:
Diffstat (limited to 'sys-boot/myinitramfs/files/init.enc')
-rwxr-xr-xsys-boot/myinitramfs/files/init.enc23
1 files changed, 10 insertions, 13 deletions
diff --git a/sys-boot/myinitramfs/files/init.enc b/sys-boot/myinitramfs/files/init.enc
index 9fcde55..b1cd3a2 100755
--- a/sys-boot/myinitramfs/files/init.enc
+++ b/sys-boot/myinitramfs/files/init.enc
@@ -1,4 +1,4 @@
-#!/bin/busybox sh
+#!/bin/busybox ash
# vim:ft=sh
# Init must have pid 1 otherwise switch_root won't work.
@@ -42,17 +42,14 @@ busybox mount -t sysfs none /sys || fail "/sys mount failed!"
busybox mount -t devtmpfs none /dev || fail "/dev mount failed!"
# Now open and mount root
-root=""
+uuid=""
rootflags=""
recovery=false
for opt in $(cat /proc/cmdline); do
case "$opt" in
- root=*)
- root=${opt:5}
- ;;
rootuuid=*)
- root="$(blkid | awk "/UUID=\"${opt:9}\"/{ print \$1 }" | tr -d ':')"
+ uuid="${opt:9}"
;;
rootflags=*)
rootflags=${opt:10}
@@ -60,7 +57,7 @@ for opt in $(cat /proc/cmdline); do
recovery)
recovery=true
;;
- BOOT_IMAGE=*|initrd=*)
+ BOOT_IMAGE=*|initrd=*|fbcon=*)
# Ignore those
;;
*)
@@ -71,19 +68,19 @@ done
$recovery && fail "Requested recovery."
-[ -z "$root" ] && fail "Missing root argument!"
+[ -z "$uuid" ] && fail "Missing rootuuid argument!"
-echo -ne "${C_GRAY}Waiting for root ($root)..."
+echo -ne "${C_GRAY}Waiting for root ($uuid)..."
CNT=10
-while [ ! -e "$root" ] && [ $CNT -gt 0 ]; do
- CNT=$(expr $CNT - 1)
+while [ $CNT -gt 0 ] && ! blkid | grep -q "UUID=\"$uuid\""; do
+ CNT=$((CNT - 1))
sleep 1
echo -n " $CNT"
done
echo -e "${C_NO}"
-[ -e "$root" ] || fail "Root not located!"
-# TODO mount boot parition and look for key saved there (on unlock remove it)
+root="$(blkid | awk -v uuid="UUID=\"$uuid\"" '$2 == uuid { gsub(/:$/,"",$1); print $1 }')"
+[ -e "$root" ] || fail "Root not located!"
echo -e "${C_GREEN}Unlocking root...${C_NO}"
cryptsetup open "$root" encroot || fail "Unlocking root failed! /proc/cmdline=$(cat /proc/cmdline)"