Files
mgmt/examples/lang/tftp0.mcl
James Shubin 90fd8023dd lang, engine: Add a facility for resources to export constants
Since we focus on safety, it would be nice to reduce the chance of any
runtime errors if we made a typo for a resource parameter. With this
patch, each resource can export constants into the global namespace so
that typos would cause a compile error.

Of course in the future if we had a more advanced type system, then we
could support precise types for each individual resource param, but in
an attempt to keep things simple, we'll leave that for another day. It
would add complexity too if we ever wanted to store a parameter
externally.

Lastly, we might consider adding "special case" parsing so that directly
specified fields would parse intelligently. For example, we could allow:

	file "/tmp/hello" {
		state => exists,	# magic sugar!
	}

This isn't supported for now, but if it works after all the other parser
changes have been made, it might be something to consider.
2020-01-29 11:16:04 -05:00

45 lines
1.1 KiB
Plaintext

$root = "/tmp/tftproot/"
file $root {
state => $const.res.file.state.exists,
}
file "${root}file0" {
content => "i'm file0 in ${root}\n",
state => $const.res.file.state.exists,
}
tftp:server ":1069" { # by default tftp uses :69 but using :1069 avoids needing root!
#address => ":1069", # you can override the name like this
timeout => 60, # increase the timeout
root => $root, # add a tftproot (optional)
}
# you can add a raw file like this...
tftp:file "/file1" {
data => "hello, world, i'm file1 and i don't exist on disk!\n",
}
# or if there's a file on disk you care about...
$f2 = "/tmp/some_file"
file $f2 {
content => "i'm a cool file in /tmp\n",
state => $const.res.file.state.exists,
}
# you can point to it directly...
tftp:file "/file2" {
path => $f2,
Depend => File[$f2], # TODO: add autoedges
}
# here's a file in the middle of nowhere that still works...
tftp:file "/i/am/some/deeply/nested/file" {
data => "how did you find me!\n",
}
# and this file won't autogroup with the main tftp server
tftp:file "/nope/noway" {
data => "i won't be seen!\n",
server => "someone else!", # normally we don't use this this way
}