Uses Build.opt_list to generate a list of labels
let label_opt_list (l:string) (r:lens) (s:lens) = Build.opt_list [ label l . r ] s
Either label_opt_list matches something or it emits a single label with the “or” string.
let label_opt_list_or (l:string) (r:lens) (s:lens) (or:string) = ( label_opt_list l r s | [ label l . store or ] )
A generic block with a title lens
let lens_block (title:lens) (sto:lens) = [ indent . title . opt_eol . lbracket . (sto | empty | comment)+ . indent . rbracket . eol ]
Build a list of identical lenses separated with a given separator (at least 2 elements)
let list (lns:lens) (sep:lens) = lns . ( sep . lns )+
A list of items
let list (kw:regexp) (elem:string) = let list_elems = Build.opt_list [seq elem . store Rx.word] (Sep.comma) in Build.key_value_line kw Sep.space list_elems
A list of values with given lens
let list_sto (kw:regexp) (lns:lens) = counter "item" . entry kw (Build.opt_list [lns] Sep.comma)
The crypttab lens
let lns = ( empty | comment | record ) *
The access.conf lens, any amount of
let lns = (comment|empty|entry) *
let lns = (comment | empty | alias)*
let lns = (empty | comment | kv) *
The apt.conf lens
let lns = (empty|comment|entry|include|clear)*
let lns = ( Util.empty | Util.comment | record ) *
The main lens, any amount of
let lns = ( empty | comment | user_record | group_record )*
The cron lens
let lns = ( empty | comment | shellvar | entry )*
Any number of empty lines, comments, and records.
let lns = ( empty | comment | record ) *
The disk_config lens
let lns = (disk_config|comment|empty)*
let lns = (comment | empty | menu_setting | boot | debian)*
let lns = ( Util.empty | Util.comment | entry )*
let lns = [ label "hostname" . store Rx.word . Util.eol ]
let lns = (Util.empty | Util.comment | entry)*
Generic INI File lens
let lns (record:lens) (comment:lens) = lns_noempty record (comment|empty)
The options lens
let lns = ( empty | comment | option )*
The keepalived lens
let lns = ( empty | comment | global_conf | vrrpd_conf | lvs_conf )*
The login.defs lens
let lns = (record | Util.comment | Util.empty) *
The mke2fs lens
let lns = (empty|comment)* . (defaults|fs_types)*
let lns = (comment|empty|entry)*
let lns = ( Util.empty | Util.comment | record ) *
main structure
let lns = ( Util.empty | Util.comment | param )*
let lns = ( Util.empty | Util.comment | entry )*
The Nrpe lens
let lns = ( command | item | include | include_dir | comment | empty ) *
let lns = ( empty | comment | database )*
The pbuilder lens
let lns = Shellvars.lns
The pg_hba.conf lens
let lns = ( record | Util.comment | Util.empty ) *
The lens is made of Util.empty, Util.comment and entry lines
let lns = (Util.empty|Util.comment|entry)*
let lns = ( empty | comment | entry )*
An IniFile.lns
let lns = IniFile.lns record comment
The services lens is either empty, comment or record
let lns = ( empty | comment | record )*
The shells lens
let lns = ( empty | comment | shell )*
let lns = ( empty | comment | cmd_moddir | cmd_kv "rootdev" Rx.fspath | cmd_kv "rootfs" Rx.word | cmd_kv "exclude" Rx.fspath | cmd_kv "include" Rx.fspath | cmd_kv "forceload" Rx.fspath | cmd_set )*
The sudoers lens, any amount of
let lns = ( empty | comment | includedir | alias | defaults | spec )*
generic entries then programs or hostnames matching blocs
let lns = entries . ( program | hostname )*
Test the full conf
test Access.lns get conf = { "access" = "+" { "user" = "ALL" } { "origin" = "LOCAL" } } { "access" = "+" { "user" = "root" } { "origin" = "localhost.localdomain" } } { "access" = "-" { "user" = "root" } { "origin" = "127.0.0.1" } { "origin" = ".localdomain" } } { "access" = "+" { "user" = "root" } { "user" = "alice" { "host" = "server1" } } { "netgroup" = "admins" } { "group" = "wheel" } { "origin" = "cron" } { "origin" = "crond" } { "origin" = ":0" } { "origin" = "tty1" } { "origin" = "tty2" } { "origin" = "tty3" } { "origin" = "tty4" } { "origin" = "tty5" } { "origin" = "tty6" } } { "#comment" = "IP v6 support" } { "access" = "+" { "user" = "john" } { "user" = "foo" } { "origin" = "2001:4ca0:0:101::1" } { "origin" = "2001:4ca0:0:101::/64" } } { "#comment" = "Except" } { "access" = "+" { "user" = "ALL" } { "except" { "user" = "john" } { "netgroup" = "wheel" } } { "origin" = "ALL" } { "except" { "origin" = "LOCAL" } { "origin" = ".win.tue.nl" } } } { "#comment" = "No spaces" } { "access" = "+" { "user" = "root" } { "origin" = ".example.com" } }
Testing Aliases.lns on file
test Aliases.lns get file = { } { "#comment" = "Aliases in this file will NOT be expanded in the header from" } { "#comment" = "Mail, but WILL be visible over networks or from /bin/mail." } {} { "#comment" = "Basic system aliases -- these MUST be present." } { "1" { "name" = "mailer-daemon" } { "value" = "postmaster" } } { "2" { "name" = "postmaster" } { "value" = "root" } } {} { "#comment" = "General redirections for pseudo accounts." } { "3" { "name" = "bin" } { "value" = "root" } { "value" = "adm" } { "value" = "bob" } } { "4" { "name" = "daemon" } { "value" = "root" } } { "5" { "name" = "adm" } { "value" = "root" } } { "6" { "name" = "file" } { "value" = "/var/foo" } } { "7" { "name" = "pipe1" } { "value" = "|/bin/ls" } } { "8" { "name" = "pipe2" } { "value" = "|\"/usr/bin/ls args,\"" } }
Testing Approx.lns on default_approx
test Approx.lns get default_approx = { "#comment" = "The following are the defaults, so there is no need" } { "#comment" = "to uncomment them unless you want a different value." } { "#comment" = "See approx.conf(5) for details." } { } { "$interface" = "any" } { "$port" = "9999" } { "$interval" = "720" } { "$max_wait" = "10" } { "$max_rate" = "unlimited" } { "$debug" = "false" } { } { "#comment" = "Here are some examples of remote repository mappings." } { "#comment" = "See http://www.debian.org/mirror/list for mirror sites." } { } { "debian" = "http://ftp.nl.debian.org/debian" } { "debian-volatile" = "http://ftp.nl.debian.org/debian-volatile" } { "security" = "http://security.debian.org" }
Testing the full FAI_DiskConfig.lns on simple_config
test FAI_DiskConfig.lns get simple_config = { "#comment" = "A comment" } { "disk_config" = "disk2" { "raw-disk" { "mountpoint" = "-" } { "size" = "0" } { "filesystem" = "-" } { "mount_options" { "1" = "-" } } } } { } { "disk_config" = "lvm" { "vg" { "name" = "my_pv" } { "disk" = "sda2" } } { "vg" { "name" = "test" } { "disk" = "disk1" { "partition" = "9" } } } { "lv" { "vg" = "my_pv" } { "name" = "_swap" } { "mountpoint" = "swap" } { "size" = "2048" } { "filesystem" = "swap" } { "mount_options" { "1" = "sw" } } } { "lv" { "vg" = "my_pv" } { "name" = "_root" } { "mountpoint" = "/" } { "size" = "2048" } { "filesystem" = "ext3" } { "mount_options" { "1" = "rw" } { "2" = "errors" { "value" = "remount-ro" } } } } } { } { "disk_config" = "raid" { "raid1" { "mountpoint" = "/boot" } { "disk" = "disk1" { "partition" = "1" } } { "disk" = "disk2" { "partition" = "1" } } { "disk" = "disk3" { "partition" = "1" } } { "disk" = "disk4" { "partition" = "1" } } { "disk" = "disk5" { "partition" = "1" } } { "disk" = "disk6" { "partition" = "1" } } { "filesystem" = "ext3" } { "mount_options" { "1" = "rw" } } } { "raid1" { "mountpoint" = "swap" } { "disk" = "disk1" { "partition" = "2" } } { "disk" = "disk2" { "partition" = "2" } } { "disk" = "disk3" { "partition" = "2" } } { "disk" = "disk4" { "partition" = "2" } } { "disk" = "disk5" { "partition" = "2" } } { "disk" = "disk6" { "partition" = "2" } } { "filesystem" = "swap" } { "mount_options" { "1" = "sw" } } } { "raid5" { "mountpoint" = "/srv/data" } { "disk" = "disk1" { "partition" = "11" } } { "disk" = "disk2" { "partition" = "11" } } { "disk" = "disk3" { "partition" = "11" } } { "disk" = "disk4" { "partition" = "11" } } { "disk" = "disk5" { "partition" = "11" } } { "disk" = "disk6" { "partition" = "11" } } { "filesystem" = "ext3" } { "mount_options" { "1" = "ro" } } { "fs_options" { "createopts" = "-m 0" } } } { "raid0" { "mountpoint" = "-" } { "disk" = "disk2" { "partition" = "2" } } { "disk" = "sdc1" } { "disk" = "sde1" { "spare" } { "missing" } } { "filesystem" = "ext2" } { "mount_options" { "1" = "default" } } } } { } { "disk_config" = "tmpfs" { "tmpfs" { "mountpoint" = "/var/opt/hosting/tmp" } { "size" = "500" } { "mount_options" { "1" = "defaults" } } } }
Test the full conf
test Keepalived.lns get conf = { "#comment" = "This is a comment" } { "#comment" = "Configuration File for keepalived" } {} { "global_defs" { } { "#comment" = "this is who emails will go to on alerts" } { "notification_email" { } { "email" = "admins@example.com" } { "email" = "fakepager@example.com" } { "#comment" = "add a few more email addresses here if you would like" } } { "notification_email_from" = "admins@example.com" } { } { "smtp_server" = "127.0.0.1" { "#comment" = "I use the local machine to relay mail" } } { "smtp_connect_timeout" = "30" } {} { "#comment" = "each load balancer should have a different ID" } { "#comment" = "this will be used in SMTP alerts, so you should make" } { "#comment" = "each router easily identifiable" } { "lvs_id" = "LVS_EXAMPLE_01" } } {} { "vrrp_sync_group" = "VG1" { } { "group" { } { "inside_network" { "#comment" = "name of vrrp_instance (below)" } } { "outside_network" { "#comment" = "One for each moveable IP." } } } } {}
Testing the full conf against Reprepro_Uploaders.lns
test Reprepro_Uploaders.lns get conf = { "#comment" = "ftpmaster" } { "allow" = "*" { "by" = "key" { "key" = "74BF771E" } } } { } { "allow" { "and" { "or" = "sections" { "or" = "desktop/*" } } } { "by" = "anybody" } } { "allow" { "and" { "or" = "sections" { "or" = "gforge/*" } } } { "and" { "or" = "binaries" { "contain" } { "or" = "bzr" } } { "or" = "source" { "not" } { "or" = "*melanie*" } { "or" = "katya" } } } { "by" = "key" { "key" = "any" } } }
test Xml.lns put "<a></a >" after set "/a/#text[1]" "foo"; set "/a/#text[2]" "bar" = "<a>foobar</a >"
The xorg.conf lens
let lns = ( empty | comment | section )*
let lns_ace = IniFile.lns record_ace comment_ace
let lns_acf = IniFile.lns_noempty record_acf comment_acf
let lns_ade = IniFile.lns record_ade comment_ade
let lns_adf = IniFile.lns_noempty record_adf comment_adf
let lns_bce = IniFile.lns record_bce comment_bce
let lns_bcf = IniFile.lns_noempty record_bce comment_bcf
let lns_bde = IniFile.lns record_bde comment_bde
let lns_bdf = IniFile.lns_noempty record_bdf comment_bdf
Generic INI File lens with no empty lines
let lns_noempty (record:lens) (comment:lens) = comment* . record*
a loghost is an @ sign followed by the hostname and a possible port
let loghost = at . [ label "hostname" . store loghost_r ] . (colon . [ label "port" . store /[0-9]+/ ] )?
Matches a hostname, that is labels speparated by dots, labels can’t start or end with a “-”.
let loghost_r = /[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?)*/
A logical construction for condition and condition_list
let logic_construct_condition (kw:string) (lns:lens) = [ label kw . lns ] . [ Sep.space . key kw . Sep.space . lns ]*
A generic definition for condition_field
let logic_construct_field (kw:string) (sep:string) (lns:lens) = [ label kw . lns ] . [ Build.xchgs sep kw . lns ]*
a log program begins with a pipe
let logprogram = pipe . [ label "program" . store /[^ \t\n][^\n]+[^ \t\n]/ ]
let lvmoption =
contains subblocks of Virtual server group(s) and Virtual server(s)
let lvs_conf = virtual_server | virtual_server_group