Skip to content

Commit

Permalink
nixos/luksroot: Replace string substitutions with while loops
Browse files Browse the repository at this point in the history
Avoid a very large string expansion when the "$secs" argument is a
large number.
  • Loading branch information
CyberShadow committed Dec 31, 2024
1 parent 2038d9a commit 4a3574d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions nixos/modules/system/boot/luksroot.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ let
if ! dev_exist $target; then
echo -n "Waiting $secs seconds for $desc..."
local success=false;
for try in $(seq $secs); do
local try=0
while [ $try -lt $secs ] ; do
echo -n "."
sleep 1
try=$((try+1))
if dev_exist $target; then
success=true
break
Expand All @@ -61,9 +63,11 @@ let
if [ $? != 0 ]; then
echo -n "Waiting $secs seconds for YubiKey to appear..."
local success=false
for try in $(seq $secs); do
echo -n .
local try=0
while [ $try -lt $secs ] ; do
echo -n "."
sleep 1
try=$((try+1))
ykinfo -v 1>/dev/null 2>&1
if [ $? == 0 ]; then
success=true
Expand All @@ -88,9 +92,11 @@ let
if [ $? != 0 ]; then
echo -n "Waiting $secs seconds for GPG Card to appear"
local success=false
for try in $(seq $secs); do
echo -n .
local try=0
while [ $try -lt $secs ] ; do
echo -n "."
sleep 1
try=$((try+1))
gpg --card-status > /dev/null 2> /dev/null
if [ $? == 0 ]; then
success=true
Expand Down

0 comments on commit 4a3574d

Please sign in to comment.