Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make lima-init.sh yaml parsing more robust #126

Merged
merged 1 commit into from
Mar 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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