Files
mgmt/examples/lang/reverse2.mcl
James Shubin 05d570d250 lang: parser, funcs: Change the logical operators to OR, AND, NOT
This makes it easier to read for some, and easier to parse for us. This
also frees up more characters to use elsewhere.
2023-10-09 17:19:08 -04:00

26 lines
564 B
Plaintext

import "datetime"
import "math"
$now = datetime.now()
# alternate every four seconds
$mod0 = math.mod($now, 8) == 0
$mod1 = math.mod($now, 8) == 1
$mod2 = math.mod($now, 8) == 2
$mod3 = math.mod($now, 8) == 3
$mod = $mod0 or $mod1 or $mod2 or $mod3
file "/tmp/mgmt/" {
state => $const.res.file.state.exists,
}
# file should re-appear and disappear every four seconds
# it will even preserve and then restore the pre-existing content!
if $mod {
file "/tmp/mgmt/hello" {
state => $const.res.file.state.absent, # delete the file
Meta:reverse => true,
}
}