nixos: initrd/luks: make uuid specified devices discoverable

This commit is contained in:
Edward Tjörnhammar 2018-09-03 19:45:54 +02:00
parent 4b1e3376d1
commit 8ab4cbdac3

View File

@ -11,19 +11,30 @@ let
exit 1 exit 1
} }
dev_exist() {
local target="$1"
if [ -e $target ]; then
return 0
else
local uuid=$(echo -n $target | sed -e 's,UUID=\(.*\),\1,g')
local dev=$(blkid --uuid $uuid)
return $?
fi
}
wait_target() { wait_target() {
local name="$1" local name="$1"
local target="$2" local target="$2"
local secs="''${3:-10}" local secs="''${3:-10}"
local desc="''${4:-$name $target to appear}" local desc="''${4:-$name $target to appear}"
if [ ! -e $target ]; then if ! dev_exist $target; then
echo -n "Waiting $secs seconds for $desc..." echo -n "Waiting $secs seconds for $desc..."
local success=false; local success=false;
for try in $(seq $secs); do for try in $(seq $secs); do
echo -n "." echo -n "."
sleep 1 sleep 1
if [ -e $target ]; then if dev_exist $target; then
success=true success=true
break break
fi fi