nuageinit: Create parent directories in write_files
Currently, 'write_files' does not create parent directories, and 'runcmd' cannot be used here, since those scripts run after the files have been written. The only workaround is to create the files in an existing directory, such as '/root' or '/tmp', and then move those files using 'runcmd', but this is cumbersome when there are many files, even if they are small. With this change, nuageinit now creates the parent directories for each file using the path field, which mimics the same behavior as in cloud-init. Permissions and ownership can also be configured using 'runcmd'. Reviewed by: bapt@ Approved by: bapt@ Differential Revision: https://reviews.freebsd.org/D57395
This commit is contained in:
@@ -832,6 +832,7 @@ local function addfile(file, defer)
|
||||
root = ""
|
||||
end
|
||||
local filepath = root .. file.path
|
||||
mkdir_p(dirname(filepath))
|
||||
local f = assert(io.open(filepath, mode))
|
||||
if content then
|
||||
f:write(content)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
.\" Copyright (c) 2025 Baptiste Daroussin <bapt@FreeBSD.org>
|
||||
.\" Copyright (c) 2025 Jesús Daniel Colmenares Oviedo <dtxdf@FreeBSD.org>
|
||||
.\"
|
||||
.Dd June 6, 2026
|
||||
.Dd June 8, 2026
|
||||
.Dt NUAGEINIT 7
|
||||
.Os
|
||||
.Sh NAME
|
||||
@@ -615,7 +615,7 @@ and
|
||||
are supported for now.
|
||||
.It Ic path
|
||||
The path of the file to be created.
|
||||
.Pq Note intermerdiary directories will not be created .
|
||||
.Pq Note intermerdiary directories will be created .
|
||||
.It Ic permissions
|
||||
A string representing the permission of the file in octal.
|
||||
.It Ic owner
|
||||
|
||||
Reference in New Issue
Block a user