From f9bd26d1592ccfbf57adb47d6a22cbafb343e3a3 Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Fri, 3 Jan 2020 14:03:35 +0100 Subject: mount-crypts: use sh more thoroughly --- mount-crypts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/mount-crypts b/mount-crypts index 08b1975..b7ba106 100755 --- a/mount-crypts +++ b/mount-crypts @@ -1,14 +1,16 @@ #!/bin/bash -i=1 maxWait=60 -while [ $i -le $(sed "s/#.*$//" /etc/crypttab | grep -vc '^ *$') ]; do - s="$(sed "s/#.*$//" /etc/crypttab | grep -v '^ *$' | tail -n$i | head -n1 | sed "s/ */ /g")" - i=$((i+1)) - name=$(echo $s | awk '{print $1}') - device=$(echo $s | awk '{print $2}') - key=$(echo $s | awk '{print $3}') +sed 's/#.*$//' /etc/crypttab \ +| grep -v '^ *$' \ +| if [ "x$1" = 'x-u' ]; then + tac +else + cat +fi \ +| while read -r name device key; do + while [ ${maxWait} -gt 0 ] && [ ! -b "${device}" ]; do sleep 1 maxWait=$[${maxWait}-1] -- cgit v1.2.3-70-g09d2