|
Packit Service |
a2ae7a |
(*
|
|
Packit Service |
a2ae7a |
Module: Ntpd
|
|
Packit Service |
a2ae7a |
Parses OpenNTPD's ntpd.conf
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
Author: Jasper Lievisse Adriaanse <jasper@jasper.la>
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Reference
|
|
Packit Service |
a2ae7a |
This lens is used to parse OpenNTPD's configuration file, ntpd.conf.
|
|
Packit Service |
a2ae7a |
http://openntpd.org/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Usage Example
|
|
Packit Service |
a2ae7a |
To be documented
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: License
|
|
Packit Service |
a2ae7a |
This file is licensed under the LGPL v2+, like the rest of Augeas.
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
About: Configuration files
|
|
Packit Service |
a2ae7a |
This lens applies to /etc/ntpd.conf.
|
|
Packit Service |
a2ae7a |
See <filter>.
|
|
Packit Service |
a2ae7a |
*)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
module Ntpd =
|
|
Packit Service |
a2ae7a |
autoload xfm
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: Utility variables/functions
|
|
Packit Service |
a2ae7a |
************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: comment *)
|
|
Packit Service |
a2ae7a |
let comment = Util.comment
|
|
Packit Service |
a2ae7a |
(* View: empty *)
|
|
Packit Service |
a2ae7a |
let empty = Util.empty
|
|
Packit Service |
a2ae7a |
(* View: eol *)
|
|
Packit Service |
a2ae7a |
let eol = Util.eol
|
|
Packit Service |
a2ae7a |
(* View: space *)
|
|
Packit Service |
a2ae7a |
let space = Sep.space
|
|
Packit Service |
a2ae7a |
(* View: word *)
|
|
Packit Service |
a2ae7a |
let word = Rx.word
|
|
Packit Service |
a2ae7a |
(* View: device_re *)
|
|
Packit Service |
a2ae7a |
let device_re = Rx.device_name | /\*/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: address_re *)
|
|
Packit Service |
a2ae7a |
let address_re = Rx.ip | /\*/ | Rx.hostname
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: stratum_re
|
|
Packit Service |
a2ae7a |
value between 1 and 15 *)
|
|
Packit Service |
a2ae7a |
let stratum_re = /1[0-5]|[1-9]/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: refid_re
|
|
Packit Service |
a2ae7a |
string with length < 5 *)
|
|
Packit Service |
a2ae7a |
let refid_re = /[A-Za-z0-9_.-]{1,5}/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: weight_re
|
|
Packit Service |
a2ae7a |
value between 1 and 10 *)
|
|
Packit Service |
a2ae7a |
let weight_re = /10|[1-9]/
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: rtable_re
|
|
Packit Service |
a2ae7a |
0 - RT_TABLE_MAX *)
|
|
Packit Service |
a2ae7a |
let rtable_re = Rx.byte
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: correction_re
|
|
Packit Service |
a2ae7a |
should actually only match between -127000000 and 127000000 *)
|
|
Packit Service |
a2ae7a |
let correction_re = Rx.relinteger_noplus
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: key_opt_rtable_line
|
|
Packit Service |
a2ae7a |
* A subnode with a keyword, an optional routing table id and an end
|
|
Packit Service |
a2ae7a |
* of line.
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Parameters:
|
|
Packit Service |
a2ae7a |
* kw:regexp - the pattern to match as key
|
|
Packit Service |
a2ae7a |
* sto:lens - the storing lens
|
|
Packit Service |
a2ae7a |
************************************************************************)
|
|
Packit Service |
a2ae7a |
let key_opt_rtable_line (kw:regexp) (sto:lens) =
|
|
Packit Service |
a2ae7a |
let rtable = [ Util.del_str "rtable" . space . label "rtable"
|
|
Packit Service |
a2ae7a |
. store rtable_re ]
|
|
Packit Service |
a2ae7a |
in [ key kw . space . sto . (space . rtable)? . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: key_opt_weight_rtable_line
|
|
Packit Service |
a2ae7a |
* A subnode with a keyword, an optional routing table id, an optional
|
|
Packit Service |
a2ae7a |
* weight-value and an end of line.
|
|
Packit Service |
a2ae7a |
* of line.
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Parameters:
|
|
Packit Service |
a2ae7a |
* kw:regexp - the pattern to match as key
|
|
Packit Service |
a2ae7a |
* sto:lens - the storing lens
|
|
Packit Service |
a2ae7a |
************************************************************************)
|
|
Packit Service |
a2ae7a |
let key_opt_weight_rtable_line (kw:regexp) (sto:lens) =
|
|
Packit Service |
a2ae7a |
let rtable = [ Util.del_str "rtable" . space . label "rtable" . store rtable_re ]
|
|
Packit Service |
a2ae7a |
in let weight = [ Util.del_str "weight" . space . label "weight"
|
|
Packit Service |
a2ae7a |
. store weight_re ]
|
|
Packit Service |
a2ae7a |
in [ key kw . space . sto . (space . weight)? . (space . rtable)? . eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* View: opt_value
|
|
Packit Service |
a2ae7a |
* A subnode for optional values.
|
|
Packit Service |
a2ae7a |
*
|
|
Packit Service |
a2ae7a |
* Parameters:
|
|
Packit Service |
a2ae7a |
* s:string - the option name and subtree label
|
|
Packit Service |
a2ae7a |
* r:regexp - the pattern to match as store
|
|
Packit Service |
a2ae7a |
************************************************************************)
|
|
Packit Service |
a2ae7a |
let opt_value (s:string) (r:regexp) =
|
|
Packit Service |
a2ae7a |
Build.key_value s space (store r)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: Keywords
|
|
Packit Service |
a2ae7a |
************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: listen
|
|
Packit Service |
a2ae7a |
listen on address [rtable table-id] *)
|
|
Packit Service |
a2ae7a |
let listen =
|
|
Packit Service |
a2ae7a |
let addr = [ label "address" . store address_re ]
|
|
Packit Service |
a2ae7a |
in key_opt_rtable_line "listen on" addr
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: server
|
|
Packit Service |
a2ae7a |
server address [weight weight-value] [rtable table-id] *)
|
|
Packit Service |
a2ae7a |
let server =
|
|
Packit Service |
a2ae7a |
let addr = [ label "address" . store address_re ]
|
|
Packit Service |
a2ae7a |
in key_opt_weight_rtable_line "server" addr
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: servers
|
|
Packit Service |
a2ae7a |
servers address [weight weight-value] [rtable table-id] *)
|
|
Packit Service |
a2ae7a |
let servers =
|
|
Packit Service |
a2ae7a |
let addr = [ label "address" . store address_re ]
|
|
Packit Service |
a2ae7a |
in key_opt_weight_rtable_line "servers" addr
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: sensor
|
|
Packit Service |
a2ae7a |
sensor device [correction microseconds] [weight weight-value] [refid
|
|
Packit Service |
a2ae7a |
string] [stratum stratum-value] *)
|
|
Packit Service |
a2ae7a |
let sensor =
|
|
Packit Service |
a2ae7a |
let device = [ label "device" . store device_re ]
|
|
Packit Service |
a2ae7a |
in let correction = opt_value "correction" correction_re
|
|
Packit Service |
a2ae7a |
in let weight = opt_value "weight" weight_re
|
|
Packit Service |
a2ae7a |
in let refid = opt_value "refid" refid_re
|
|
Packit Service |
a2ae7a |
in let stratum = opt_value "stratum" stratum_re
|
|
Packit Service |
a2ae7a |
in [ key "sensor" . space . device
|
|
Packit Service |
a2ae7a |
. (space . correction)?
|
|
Packit Service |
a2ae7a |
. (space . weight)?
|
|
Packit Service |
a2ae7a |
. (space . refid)?
|
|
Packit Service |
a2ae7a |
. (space . stratum)?
|
|
Packit Service |
a2ae7a |
. eol ]
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(************************************************************************
|
|
Packit Service |
a2ae7a |
* Group: Lens
|
|
Packit Service |
a2ae7a |
************************************************************************)
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: keyword *)
|
|
Packit Service |
a2ae7a |
let keyword = listen | server | servers | sensor
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: lns *)
|
|
Packit Service |
a2ae7a |
let lns = ( empty | comment | keyword )*
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
(* View: filter *)
|
|
Packit Service |
a2ae7a |
let filter = (incl "/etc/ntpd.conf")
|
|
Packit Service |
a2ae7a |
|
|
Packit Service |
a2ae7a |
let xfm = transform lns filter
|