Files
mgmt/examples/lang/reverse3.mcl
James Shubin 3d4b345728 examples: lang: Improve reverse example
It's cool to show just the mode changes.
2020-01-12 17:42:20 -05:00

28 lines
588 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 || $mod1 || $mod2 || $mod3
file "/tmp/mgmt/" {
state => "exists",
}
# file should change the mode every four seconds
# editing the file contents at anytime is allowed
# you should create the file before you run this
if $mod {
file "/tmp/mgmt/hello" {
#state => "exists", # omit to see it change the mode only!
mode => "0777",
Meta:reverse => true,
}
}