Imported Upstream version 1.7.0
[platform/upstream/augeas.git] / lenses / mysql.aug
1 (* MySQL module for Augeas                    *)
2 (* Author: Tim Stoop <tim@kumina.nl>          *)
3 (* Heavily based on php.aug by Raphael Pinson *)
4 (* <raphink@gmail.com>                        *)
5 (*                                            *)
6
7 module MySQL =
8   autoload xfm
9
10 (************************************************************************
11  * INI File settings
12  *************************************************************************)
13 let comment  = IniFile.comment IniFile.comment_re "#"
14
15 let sep      = IniFile.sep IniFile.sep_re IniFile.sep_default
16
17 let entry    =
18      let bare = Quote.do_dquote_opt_nil (store /[^#;" \t\r\n]+([ \t]+[^#;" \t\r\n]+)*/)
19   in let quoted = Quote.do_dquote (store /[^"\r\n]*[#;]+[^"\r\n]*/)
20   in [ Util.indent . key IniFile.entry_re . sep . Sep.opt_space . bare . (comment|IniFile.eol) ]
21    | [ Util.indent . key IniFile.entry_re . sep . Sep.opt_space . quoted . (comment|IniFile.eol) ]
22    | [ Util.indent . key IniFile.entry_re . store // .  (comment|IniFile.eol) ]
23    | comment
24
25 (************************************************************************
26  * sections, led by a "[section]" header
27  * We can't use titles as node names here since they could contain "/"
28  * We remove #comment from possible keys
29  * since it is used as label for comments
30  * We also remove / as first character
31  * because augeas doesn't like '/' keys (although it is legal in INI Files)
32  *************************************************************************)
33 let title   = IniFile.indented_title_label "target" IniFile.record_label_re
34 let record  = IniFile.record title entry
35
36 let includedir = Build.key_value_line /!include(dir)?/ Sep.space (store Rx.fspath)
37                . (comment|IniFile.empty)*
38
39 let lns    = (comment|IniFile.empty)* . (record|includedir)*
40
41 let filter = (incl "/etc/mysql/my.cnf")
42              . (incl "/etc/mysql/conf.d/*.cnf")
43              . (incl "/etc/my.cnf")
44              . (incl "/etc/my.cnf.d/*.cnf")
45
46 let xfm = transform lns filter
47