Skip to content

Commit

Permalink
Merge pull request #126 from rancher-sandbox/mounts
Browse files Browse the repository at this point in the history
Make lima-init.sh yaml parsing more robust
  • Loading branch information
AkihiroSuda authored Mar 9, 2024
2 parents a4b10ce + 46e5baa commit 5a09f68
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions lima-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,18 @@ awk -f- "${LIMA_CIDATA_MNT}"/user-data <<'EOF' >>"${MOUNT_SCRIPT}"
flag = 1
next
}
/^ *$/ {
flag = 0
}
flag {
/^- / && flag {
# Use a pattern unlikely to appear in a filename. "\0" unfortunately doesn't work.
FS = "<;><><;>"
sub(/^ *- \[/, "")
sub(/"?\] *$/, "")
gsub("\"?, \"?", FS)
printf "mkdir -p \"%s\"\n", $2
printf "mount -t %s -o \"%s\" %s \"%s\"\n", $3, $4, $1, $2
next
}
{
flag = 0
}
EOF
chmod +x "${MOUNT_SCRIPT}"
Expand Down Expand Up @@ -134,16 +135,21 @@ awk -f- "${LIMA_CIDATA_MNT}"/user-data <<'EOF' > ${LIMA_CA_CERTS}
trusted = 1
next
}
/^ *$/ {
cacerts = 0
trusted = 0
}
/^ -/ {
next
}
trusted {
/^ / && trusted {
sub(/^ +/, "")
print
next
}
# As long as the line is indented we may still be in the ca_certs block, looking for "trusted"
/^ / {
next
}
{
cacerts = 0
trusted = 0
}
EOF
if [ -s ${LIMA_CA_CERTS} ]; then
Expand Down

0 comments on commit 5a09f68

Please sign in to comment.