|
Packit Service |
a2ae7a |
(* Intefraces module for Augeas
|
|
Packit Service |
a2ae7a |
Author: Free Ekanayaka <free@64studio.com>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
Reference: man dhclient.conf
|
|
Packit Service |
a2ae7a |
The only difference with the reference syntax is that this lens assumes
|
|
Packit Service |
a2ae7a |
that statements end with a new line, while the reference syntax allows
|
|
Packit Service |
a2ae7a |
new statements to be started right after the trailing ";" of the
|
|
Packit Service |
a2ae7a |
previous statement. This should not be a problem in real-life
|
|
Packit Service |
a2ae7a |
configuration files as statements get usually split across several
|
|
Packit Service |
a2ae7a |
lines, rather than merged in a single one.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
module Dhclient =
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
autoload xfm
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* USEFUL PRIMITIVES
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let eol = Util.eol
|
|
Packit Service |
a2ae7a |
let comment = Util.comment
|
|
Packit Service |
a2ae7a |
let comment_or_eol = Util.comment_or_eol
|
|
Packit Service |
a2ae7a |
let empty = Util.empty
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Define separators *)
|
|
Packit Service |
a2ae7a |
let sep_spc = del /[ \t\n]+/ " "
|
|
Packit Service |
a2ae7a |
let sep_scl = del /[ \t]*;/ ";"
|
|
Packit Service |
a2ae7a |
let sep_obr = del /[ \t\n]*\{\n]*/ " {\n"
|
|
Packit Service |
a2ae7a |
let sep_cbr = del /[ \t\n]*\}/ " }"
|
|
Packit Service |
a2ae7a |
let sep_com = del /[ \t\n]*,[ \t\n]*/ ","
|
|
Packit Service |
a2ae7a |
let sep_slh = del "\/" "/"
|
|
Packit Service |
a2ae7a |
let sep_col = del ":" ":"
|
|
Packit Service |
a2ae7a |
let sep_eq = del /[ \t]*=[ \t]*/ "="
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Define basic types *)
|
|
Packit Service |
a2ae7a |
let word = /[A-Za-z0-9_.-]+(\[[0-9]+\])?/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* Define fields *)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* TODO: there could be a " " in the middle of a value ... *)
|
|
Packit Service |
a2ae7a |
let sto_to_spc = store /[^\\#,;{}" \t\n]+|"[^\\#"\n]+"/
|
|
Packit Service |
a2ae7a |
let sto_to_spc_noeval = store /[^=\\#,;{}" \t\n]|[^=\\#,;{}" \t\n][^\\#,;{}" \t\n]*|"[^\\#"\n]+"/
|
|
Packit Service |
a2ae7a |
let sto_to_scl = store /[^ \t\n][^;\n]+[^ \t]|[^ \t;\n]+/
|
|
Packit Service |
a2ae7a |
let rfc_code = [ key "code" . sep_spc . store word ]
|
|
Packit Service |
a2ae7a |
. sep_eq
|
|
Packit Service |
a2ae7a |
. [ label "value" . sto_to_scl ]
|
|
Packit Service |
a2ae7a |
let eval = [ label "#eval" . Sep.equal . sep_spc . sto_to_scl ]
|
|
Packit Service |
a2ae7a |
let sto_number = store /[0-9][0-9]*/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* SIMPLE STATEMENTS
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let stmt_simple_re = "timeout"
|
|
Packit Service |
a2ae7a |
| "retry"
|
|
Packit Service |
a2ae7a |
| "select-timeout"
|
|
Packit Service |
a2ae7a |
| "reboot"
|
|
Packit Service |
a2ae7a |
| "backoff-cutoff"
|
|
Packit Service |
a2ae7a |
| "initial-interval"
|
|
Packit Service |
a2ae7a |
| "do-forward-updates"
|
|
Packit Service |
a2ae7a |
| "reject"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let stmt_simple = [ key stmt_simple_re
|
|
Packit Service |
a2ae7a |
. sep_spc
|
|
Packit Service |
a2ae7a |
. sto_to_spc
|
|
Packit Service |
a2ae7a |
. sep_scl
|
|
Packit Service |
a2ae7a |
. comment_or_eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* ARRAY STATEMENTS
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* TODO: the array could also be empty, like in the request statement *)
|
|
Packit Service |
a2ae7a |
let stmt_array_re = "media"
|
|
Packit Service |
a2ae7a |
| "request"
|
|
Packit Service |
a2ae7a |
| "require"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let stmt_array = [ key stmt_array_re
|
|
Packit Service |
a2ae7a |
. sep_spc
|
|
Packit Service |
a2ae7a |
. counter "stmt_array"
|
|
Packit Service |
a2ae7a |
. [ seq "stmt_array" . sto_to_spc ]
|
|
Packit Service |
a2ae7a |
. [ sep_com . seq "stmt_array" . sto_to_spc ]*
|
|
Packit Service |
a2ae7a |
. sep_scl . comment_or_eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* HASH STATEMENTS
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let stmt_hash_re = "send"
|
|
Packit Service |
a2ae7a |
| "option"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let stmt_args = ( [ key word . sep_spc . sto_to_spc_noeval ]
|
|
Packit Service |
a2ae7a |
| [ key word . sep_spc . (rfc_code|eval) ] )
|
|
Packit Service |
a2ae7a |
. sep_scl
|
|
Packit Service |
a2ae7a |
. comment_or_eol
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let stmt_hash = [ key stmt_hash_re
|
|
Packit Service |
a2ae7a |
. sep_spc
|
|
Packit Service |
a2ae7a |
. stmt_args ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let stmt_opt_mod_re = "append"
|
|
Packit Service |
a2ae7a |
| "prepend"
|
|
Packit Service |
a2ae7a |
| "default"
|
|
Packit Service |
a2ae7a |
| "supersede"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let stmt_opt_mod = [ key stmt_opt_mod_re
|
|
Packit Service |
a2ae7a |
. sep_spc
|
|
Packit Service |
a2ae7a |
. stmt_args ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* BLOCK STATEMENTS
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let stmt_block_re = "interface"
|
|
Packit Service |
a2ae7a |
| "lease"
|
|
Packit Service |
a2ae7a |
| "alias"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let stmt_block_opt_re = "interface"
|
|
Packit Service |
a2ae7a |
| "script"
|
|
Packit Service |
a2ae7a |
| "bootp"
|
|
Packit Service |
a2ae7a |
| "fixed-address"
|
|
Packit Service |
a2ae7a |
| "filename"
|
|
Packit Service |
a2ae7a |
| "server-name"
|
|
Packit Service |
a2ae7a |
| "medium"
|
|
Packit Service |
a2ae7a |
| "vendor option space"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* TODO: some options could take no argument like bootp *)
|
|
Packit Service |
a2ae7a |
let stmt_block_opt = [ key stmt_block_opt_re
|
|
Packit Service |
a2ae7a |
. sep_spc
|
|
Packit Service |
a2ae7a |
. sto_to_spc
|
|
Packit Service |
a2ae7a |
. sep_scl
|
|
Packit Service |
a2ae7a |
. comment_or_eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let stmt_block_date_re
|
|
Packit Service |
a2ae7a |
= "renew"
|
|
Packit Service |
a2ae7a |
| "rebind"
|
|
Packit Service |
a2ae7a |
| "expire"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let stmt_block_date = [ key stmt_block_date_re
|
|
Packit Service |
a2ae7a |
. [ sep_spc . label "weekday" . sto_number ]
|
|
Packit Service |
a2ae7a |
. [ sep_spc . label "year" . sto_number ]
|
|
Packit Service |
a2ae7a |
. [ sep_slh . label "month" . sto_number ]
|
|
Packit Service |
a2ae7a |
. [ sep_slh . label "day" . sto_number ]
|
|
Packit Service |
a2ae7a |
. [ sep_spc . label "hour" . sto_number ]
|
|
Packit Service |
a2ae7a |
. [ sep_col . label "minute" . sto_number ]
|
|
Packit Service |
a2ae7a |
. [ sep_col . label "second" . sto_number ]
|
|
Packit Service |
a2ae7a |
. sep_scl
|
|
Packit Service |
a2ae7a |
. comment_or_eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let stmt_block_arg = sep_spc . sto_to_spc
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let stmt_block_entry = sep_spc
|
|
Packit Service |
a2ae7a |
. ( stmt_array
|
|
Packit Service |
a2ae7a |
| stmt_hash
|
|
Packit Service |
a2ae7a |
| stmt_opt_mod
|
|
Packit Service |
a2ae7a |
| stmt_block_opt
|
|
Packit Service |
a2ae7a |
| stmt_block_date )
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let stmt_block = [ key stmt_block_re
|
|
Packit Service |
a2ae7a |
. stmt_block_arg?
|
|
Packit Service |
a2ae7a |
. sep_obr
|
|
Packit Service |
a2ae7a |
. stmt_block_entry+
|
|
Packit Service |
a2ae7a |
. sep_cbr
|
|
Packit Service |
a2ae7a |
. comment_or_eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* LENS & FILTER
|
|
Packit Service |
a2ae7a |
*************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let statement = (stmt_simple|stmt_opt_mod|stmt_array|stmt_hash|stmt_block)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let lns = ( empty
|
|
Packit Service |
a2ae7a |
| comment
|
|
Packit Service |
a2ae7a |
| statement )*
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let filter = incl "/etc/dhcp3/dhclient.conf"
|
|
Packit Service |
a2ae7a |
. incl "/etc/dhcp/dhclient.conf"
|
|
Packit Service |
a2ae7a |
. incl "/etc/dhclient.conf"
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let xfm = transform lns filter
|