Browse code

Move configuration functions into inc/*

* config/INI functions from functions-common to to inc/ini-config
* local.conf meta-config functions from lib/config to inc/meta-config

Change-Id: I00fab724075a693529273878875cfd292d00b18a

Dean Troyer authored on 2015/03/10 05:16:10
Showing 13 changed files
... ...
@@ -156,7 +156,6 @@ Scripts
156 156
 * `lib/ceilometer <lib/ceilometer.html>`__
157 157
 * `lib/ceph <lib/ceph.html>`__
158 158
 * `lib/cinder <lib/cinder.html>`__
159
-* `lib/config <lib/config.html>`__
160 159
 * `lib/database <lib/database.html>`__
161 160
 * `lib/dstat <lib/dstat.html>`__
162 161
 * `lib/glance <lib/glance.html>`__
... ...
@@ -188,6 +187,12 @@ Scripts
188 188
 * `extras.d/70-zaqar.sh <extras.d/70-zaqar.sh.html>`__
189 189
 * `extras.d/80-tempest.sh <extras.d/80-tempest.sh.html>`__
190 190
 
191
+* `inc/ini-config <inc/ini-config.html>`__
192
+* `inc/meta-config <inc/meta-config.html>`__
193
+* `inc/python <inc/python.html>`__
194
+
195
+* `pkg/elasticsearch.sh <pkg/elasticsearch.sh.html>`_
196
+
191 197
 Configuration
192 198
 -------------
193 199
 
... ...
@@ -13,6 +13,7 @@
13 13
 # Include the common functions
14 14
 FUNC_DIR=$(cd $(dirname "${BASH_SOURCE:-$0}") && pwd)
15 15
 source ${FUNC_DIR}/functions-common
16
+source ${FUNC_DIR}/inc/ini-config
16 17
 source ${FUNC_DIR}/inc/python
17 18
 
18 19
 # Save trace setting
... ...
@@ -43,197 +43,6 @@ declare -A GITDIR
43 43
 
44 44
 TRACK_DEPENDS=${TRACK_DEPENDS:-False}
45 45
 
46
-# Config Functions
47
-# ================
48
-
49
-# Append a new option in an ini file without replacing the old value
50
-# iniadd config-file section option value1 value2 value3 ...
51
-function iniadd {
52
-    local xtrace=$(set +o | grep xtrace)
53
-    set +o xtrace
54
-    local file=$1
55
-    local section=$2
56
-    local option=$3
57
-    shift 3
58
-
59
-    local values="$(iniget_multiline $file $section $option) $@"
60
-    iniset_multiline $file $section $option $values
61
-    $xtrace
62
-}
63
-
64
-# Comment an option in an INI file
65
-# inicomment config-file section option
66
-function inicomment {
67
-    local xtrace=$(set +o | grep xtrace)
68
-    set +o xtrace
69
-    local file=$1
70
-    local section=$2
71
-    local option=$3
72
-
73
-    sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=.*$\)|#\1|" "$file"
74
-    $xtrace
75
-}
76
-
77
-# Get an option from an INI file
78
-# iniget config-file section option
79
-function iniget {
80
-    local xtrace=$(set +o | grep xtrace)
81
-    set +o xtrace
82
-    local file=$1
83
-    local section=$2
84
-    local option=$3
85
-    local line
86
-
87
-    line=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ p; }" "$file")
88
-    echo ${line#*=}
89
-    $xtrace
90
-}
91
-
92
-# Get a multiple line option from an INI file
93
-# iniget_multiline config-file section option
94
-function iniget_multiline {
95
-    local xtrace=$(set +o | grep xtrace)
96
-    set +o xtrace
97
-    local file=$1
98
-    local section=$2
99
-    local option=$3
100
-    local values
101
-
102
-    values=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { s/^$option[ \t]*=[ \t]*//gp; }" "$file")
103
-    echo ${values}
104
-    $xtrace
105
-}
106
-
107
-# Determinate is the given option present in the INI file
108
-# ini_has_option config-file section option
109
-function ini_has_option {
110
-    local xtrace=$(set +o | grep xtrace)
111
-    set +o xtrace
112
-    local file=$1
113
-    local section=$2
114
-    local option=$3
115
-    local line
116
-
117
-    line=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ p; }" "$file")
118
-    $xtrace
119
-    [ -n "$line" ]
120
-}
121
-
122
-# Add another config line for a multi-line option.
123
-# It's normally called after iniset of the same option and assumes
124
-# that the section already exists.
125
-#
126
-# Note that iniset_multiline requires all the 'lines' to be supplied
127
-# in the argument list. Doing that will cause incorrect configuration
128
-# if spaces are used in the config values.
129
-#
130
-# iniadd_literal config-file section option value
131
-function iniadd_literal {
132
-    local xtrace=$(set +o | grep xtrace)
133
-    set +o xtrace
134
-    local file=$1
135
-    local section=$2
136
-    local option=$3
137
-    local value=$4
138
-
139
-    [[ -z $section || -z $option ]] && return
140
-
141
-    # Add it
142
-    sed -i -e "/^\[$section\]/ a\\
143
-$option = $value
144
-" "$file"
145
-
146
-    $xtrace
147
-}
148
-
149
-function inidelete {
150
-    local xtrace=$(set +o | grep xtrace)
151
-    set +o xtrace
152
-    local file=$1
153
-    local section=$2
154
-    local option=$3
155
-
156
-    [[ -z $section || -z $option ]] && return
157
-
158
-    # Remove old values
159
-    sed -i -e "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ d; }" "$file"
160
-
161
-    $xtrace
162
-}
163
-
164
-# Set an option in an INI file
165
-# iniset config-file section option value
166
-function iniset {
167
-    local xtrace=$(set +o | grep xtrace)
168
-    set +o xtrace
169
-    local file=$1
170
-    local section=$2
171
-    local option=$3
172
-    local value=$4
173
-
174
-    [[ -z $section || -z $option ]] && return
175
-
176
-    if ! grep -q "^\[$section\]" "$file" 2>/dev/null; then
177
-        # Add section at the end
178
-        echo -e "\n[$section]" >>"$file"
179
-    fi
180
-    if ! ini_has_option "$file" "$section" "$option"; then
181
-        # Add it
182
-        sed -i -e "/^\[$section\]/ a\\
183
-$option = $value
184
-" "$file"
185
-    else
186
-        local sep=$(echo -ne "\x01")
187
-        # Replace it
188
-        sed -i -e '/^\['${section}'\]/,/^\[.*\]/ s'${sep}'^\('${option}'[ \t]*=[ \t]*\).*$'${sep}'\1'"${value}"${sep} "$file"
189
-    fi
190
-    $xtrace
191
-}
192
-
193
-# Set a multiple line option in an INI file
194
-# iniset_multiline config-file section option value1 value2 valu3 ...
195
-function iniset_multiline {
196
-    local xtrace=$(set +o | grep xtrace)
197
-    set +o xtrace
198
-    local file=$1
199
-    local section=$2
200
-    local option=$3
201
-
202
-    shift 3
203
-    local values
204
-    for v in $@; do
205
-        # The later sed command inserts each new value in the line next to
206
-        # the section identifier, which causes the values to be inserted in
207
-        # the reverse order. Do a reverse here to keep the original order.
208
-        values="$v ${values}"
209
-    done
210
-    if ! grep -q "^\[$section\]" "$file"; then
211
-        # Add section at the end
212
-        echo -e "\n[$section]" >>"$file"
213
-    else
214
-        # Remove old values
215
-        sed -i -e "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ d; }" "$file"
216
-    fi
217
-    # Add new ones
218
-    for v in $values; do
219
-        sed -i -e "/^\[$section\]/ a\\
220
-$option = $v
221
-" "$file"
222
-    done
223
-    $xtrace
224
-}
225
-
226
-# Uncomment an option in an INI file
227
-# iniuncomment config-file section option
228
-function iniuncomment {
229
-    local xtrace=$(set +o | grep xtrace)
230
-    set +o xtrace
231
-    local file=$1
232
-    local section=$2
233
-    local option=$3
234
-    sed -i -e "/^\[$section\]/,/^\[.*\]/ s|[^ \t]*#[ \t]*\($option[ \t]*=.*$\)|\1|" "$file"
235
-    $xtrace
236
-}
237 46
 
238 47
 # Normalize config values to True or False
239 48
 # Accepts as False: 0 no No NO false False FALSE
... ...
@@ -253,14 +62,6 @@ function trueorfalse {
253 253
     $xtrace
254 254
 }
255 255
 
256
-function isset {
257
-    nounset=$(set +o | grep nounset)
258
-    set +o nounset
259
-    [[ -n "${!1+x}" ]]
260
-    result=$?
261
-    $nounset
262
-    return $result
263
-}
264 256
 
265 257
 # Control Functions
266 258
 # =================
267 259
new file mode 100644
... ...
@@ -0,0 +1,223 @@
0
+#!/bin/bash
1
+#
2
+# **inc/ini-config** - Configuration/INI functions
3
+#
4
+# Support for manipulating INI-style configuration files
5
+#
6
+# These functions have no external dependencies and no side-effects
7
+
8
+# Save trace setting
9
+INC_CONF_TRACE=$(set +o | grep xtrace)
10
+set +o xtrace
11
+
12
+
13
+# Config Functions
14
+# ================
15
+
16
+# Append a new option in an ini file without replacing the old value
17
+# iniadd config-file section option value1 value2 value3 ...
18
+function iniadd {
19
+    local xtrace=$(set +o | grep xtrace)
20
+    set +o xtrace
21
+    local file=$1
22
+    local section=$2
23
+    local option=$3
24
+    shift 3
25
+
26
+    local values="$(iniget_multiline $file $section $option) $@"
27
+    iniset_multiline $file $section $option $values
28
+    $xtrace
29
+}
30
+
31
+# Comment an option in an INI file
32
+# inicomment config-file section option
33
+function inicomment {
34
+    local xtrace=$(set +o | grep xtrace)
35
+    set +o xtrace
36
+    local file=$1
37
+    local section=$2
38
+    local option=$3
39
+
40
+    sed -i -e "/^\[$section\]/,/^\[.*\]/ s|^\($option[ \t]*=.*$\)|#\1|" "$file"
41
+    $xtrace
42
+}
43
+
44
+# Get an option from an INI file
45
+# iniget config-file section option
46
+function iniget {
47
+    local xtrace=$(set +o | grep xtrace)
48
+    set +o xtrace
49
+    local file=$1
50
+    local section=$2
51
+    local option=$3
52
+    local line
53
+
54
+    line=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ p; }" "$file")
55
+    echo ${line#*=}
56
+    $xtrace
57
+}
58
+
59
+# Get a multiple line option from an INI file
60
+# iniget_multiline config-file section option
61
+function iniget_multiline {
62
+    local xtrace=$(set +o | grep xtrace)
63
+    set +o xtrace
64
+    local file=$1
65
+    local section=$2
66
+    local option=$3
67
+    local values
68
+
69
+    values=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { s/^$option[ \t]*=[ \t]*//gp; }" "$file")
70
+    echo ${values}
71
+    $xtrace
72
+}
73
+
74
+# Determinate is the given option present in the INI file
75
+# ini_has_option config-file section option
76
+function ini_has_option {
77
+    local xtrace=$(set +o | grep xtrace)
78
+    set +o xtrace
79
+    local file=$1
80
+    local section=$2
81
+    local option=$3
82
+    local line
83
+
84
+    line=$(sed -ne "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ p; }" "$file")
85
+    $xtrace
86
+    [ -n "$line" ]
87
+}
88
+
89
+# Add another config line for a multi-line option.
90
+# It's normally called after iniset of the same option and assumes
91
+# that the section already exists.
92
+#
93
+# Note that iniset_multiline requires all the 'lines' to be supplied
94
+# in the argument list. Doing that will cause incorrect configuration
95
+# if spaces are used in the config values.
96
+#
97
+# iniadd_literal config-file section option value
98
+function iniadd_literal {
99
+    local xtrace=$(set +o | grep xtrace)
100
+    set +o xtrace
101
+    local file=$1
102
+    local section=$2
103
+    local option=$3
104
+    local value=$4
105
+
106
+    [[ -z $section || -z $option ]] && return
107
+
108
+    # Add it
109
+    sed -i -e "/^\[$section\]/ a\\
110
+$option = $value
111
+" "$file"
112
+
113
+    $xtrace
114
+}
115
+
116
+# Remove an option from an INI file
117
+# inidelete config-file section option
118
+function inidelete {
119
+    local xtrace=$(set +o | grep xtrace)
120
+    set +o xtrace
121
+    local file=$1
122
+    local section=$2
123
+    local option=$3
124
+
125
+    [[ -z $section || -z $option ]] && return
126
+
127
+    # Remove old values
128
+    sed -i -e "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ d; }" "$file"
129
+
130
+    $xtrace
131
+}
132
+
133
+# Set an option in an INI file
134
+# iniset config-file section option value
135
+function iniset {
136
+    local xtrace=$(set +o | grep xtrace)
137
+    set +o xtrace
138
+    local file=$1
139
+    local section=$2
140
+    local option=$3
141
+    local value=$4
142
+
143
+    [[ -z $section || -z $option ]] && return
144
+
145
+    if ! grep -q "^\[$section\]" "$file" 2>/dev/null; then
146
+        # Add section at the end
147
+        echo -e "\n[$section]" >>"$file"
148
+    fi
149
+    if ! ini_has_option "$file" "$section" "$option"; then
150
+        # Add it
151
+        sed -i -e "/^\[$section\]/ a\\
152
+$option = $value
153
+" "$file"
154
+    else
155
+        local sep=$(echo -ne "\x01")
156
+        # Replace it
157
+        sed -i -e '/^\['${section}'\]/,/^\[.*\]/ s'${sep}'^\('${option}'[ \t]*=[ \t]*\).*$'${sep}'\1'"${value}"${sep} "$file"
158
+    fi
159
+    $xtrace
160
+}
161
+
162
+# Set a multiple line option in an INI file
163
+# iniset_multiline config-file section option value1 value2 valu3 ...
164
+function iniset_multiline {
165
+    local xtrace=$(set +o | grep xtrace)
166
+    set +o xtrace
167
+    local file=$1
168
+    local section=$2
169
+    local option=$3
170
+
171
+    shift 3
172
+    local values
173
+    for v in $@; do
174
+        # The later sed command inserts each new value in the line next to
175
+        # the section identifier, which causes the values to be inserted in
176
+        # the reverse order. Do a reverse here to keep the original order.
177
+        values="$v ${values}"
178
+    done
179
+    if ! grep -q "^\[$section\]" "$file"; then
180
+        # Add section at the end
181
+        echo -e "\n[$section]" >>"$file"
182
+    else
183
+        # Remove old values
184
+        sed -i -e "/^\[$section\]/,/^\[.*\]/ { /^$option[ \t]*=/ d; }" "$file"
185
+    fi
186
+    # Add new ones
187
+    for v in $values; do
188
+        sed -i -e "/^\[$section\]/ a\\
189
+$option = $v
190
+" "$file"
191
+    done
192
+    $xtrace
193
+}
194
+
195
+# Uncomment an option in an INI file
196
+# iniuncomment config-file section option
197
+function iniuncomment {
198
+    local xtrace=$(set +o | grep xtrace)
199
+    set +o xtrace
200
+    local file=$1
201
+    local section=$2
202
+    local option=$3
203
+    sed -i -e "/^\[$section\]/,/^\[.*\]/ s|[^ \t]*#[ \t]*\($option[ \t]*=.*$\)|\1|" "$file"
204
+    $xtrace
205
+}
206
+
207
+function isset {
208
+    nounset=$(set +o | grep nounset)
209
+    set +o nounset
210
+    [[ -n "${!1+x}" ]]
211
+    result=$?
212
+    $nounset
213
+    return $result
214
+}
215
+
216
+
217
+# Restore xtrace
218
+$INC_CONF_TRACE
219
+
220
+# Local variables:
221
+# mode: shell-script
222
+# End:
0 223
new file mode 100644
... ...
@@ -0,0 +1,185 @@
0
+#!/bin/bash
1
+#
2
+# **lib/meta-config** - Configuration file manipulation functions
3
+#
4
+# Support for DevStack's local.conf meta-config sections
5
+#
6
+# These functions have no external dependencies and the following side-effects:
7
+#
8
+# CONFIG_AWK_CMD is defined, default is ``awk``
9
+
10
+# Meta-config files contain multiple INI-style configuration files
11
+# using a specific new section header to delimit them:
12
+#
13
+#   [[group-name|file-name]]
14
+#
15
+# group-name refers to the group of configuration file changes to be processed
16
+# at a particular time.  These are called phases in ``stack.sh`` but
17
+# group here as these functions are not DevStack-specific.
18
+#
19
+# file-name is the destination of the config file
20
+
21
+# Save trace setting
22
+INC_META_XTRACE=$(set +o | grep xtrace)
23
+set +o xtrace
24
+
25
+
26
+# Allow the awk command to be overridden on legacy platforms
27
+CONFIG_AWK_CMD=${CONFIG_AWK_CMD:-awk}
28
+
29
+# Get the section for the specific group and config file
30
+# get_meta_section infile group configfile
31
+function get_meta_section {
32
+    local file=$1
33
+    local matchgroup=$2
34
+    local configfile=$3
35
+
36
+    [[ -r $file ]] || return 0
37
+    [[ -z $configfile ]] && return 0
38
+
39
+    $CONFIG_AWK_CMD -v matchgroup=$matchgroup -v configfile=$configfile '
40
+        BEGIN { group = "" }
41
+        /^\[\[.+\|.*\]\]/ {
42
+            if (group == "") {
43
+                gsub("[][]", "", $1);
44
+                split($1, a, "|");
45
+                if (a[1] == matchgroup && a[2] == configfile) {
46
+                    group=a[1]
47
+                }
48
+            } else {
49
+                group=""
50
+            }
51
+            next
52
+        }
53
+        {
54
+            if (group != "")
55
+                print $0
56
+        }
57
+    ' $file
58
+}
59
+
60
+
61
+# Get a list of config files for a specific group
62
+# get_meta_section_files infile group
63
+function get_meta_section_files {
64
+    local file=$1
65
+    local matchgroup=$2
66
+
67
+    [[ -r $file ]] || return 0
68
+
69
+    $CONFIG_AWK_CMD -v matchgroup=$matchgroup '
70
+        /^\[\[.+\|.*\]\]/ {
71
+            gsub("[][]", "", $1);
72
+            split($1, a, "|");
73
+            if (a[1] == matchgroup)
74
+                print a[2]
75
+        }
76
+    ' $file
77
+}
78
+
79
+
80
+# Merge the contents of a meta-config file into its destination config file
81
+# If configfile does not exist it will be created.
82
+# merge_config_file infile group configfile
83
+function merge_config_file {
84
+    local file=$1
85
+    local matchgroup=$2
86
+    local configfile=$3
87
+
88
+    get_meta_section $file $matchgroup $configfile | \
89
+    $CONFIG_AWK_CMD -v configfile=$configfile '
90
+        BEGIN {
91
+            section = ""
92
+            last_section = ""
93
+            section_count = 0
94
+        }
95
+        /^\[.+\]/ {
96
+            gsub("[][]", "", $1);
97
+            section=$1
98
+            next
99
+        }
100
+        /^ *\#/ {
101
+            next
102
+        }
103
+        /^[^ \t]+/ {
104
+            # get offset of first '=' in $0
105
+            eq_idx = index($0, "=")
106
+            # extract attr & value from $0
107
+            attr = substr($0, 1, eq_idx - 1)
108
+            value = substr($0, eq_idx + 1)
109
+            # only need to strip trailing whitespace from attr
110
+            sub(/[ \t]*$/, "", attr)
111
+            # need to strip leading & trailing whitespace from value
112
+            sub(/^[ \t]*/, "", value)
113
+            sub(/[ \t]*$/, "", value)
114
+
115
+            # cfg_attr_count: number of config lines per [section, attr]
116
+            # cfg_attr: three dimensional array to keep all the config lines per [section, attr]
117
+            # cfg_section: keep the section names in the same order as they appear in local.conf
118
+            # cfg_sec_attr_name: keep the attr names in the same order as they appear in local.conf
119
+            if (! (section, attr) in cfg_attr_count) {
120
+                if (section != last_section) {
121
+                    cfg_section[section_count++] = section
122
+                    last_section = section
123
+                }
124
+                attr_count = cfg_sec_attr_count[section_count - 1]++
125
+                cfg_sec_attr_name[section_count - 1, attr_count] = attr
126
+
127
+                cfg_attr[section, attr, 0] = value
128
+                cfg_attr_count[section, attr] = 1
129
+            } else {
130
+                lno = cfg_attr_count[section, attr]++
131
+                cfg_attr[section, attr, lno] = value
132
+            }
133
+        }
134
+        END {
135
+            # Process each section in order
136
+            for (sno = 0; sno < section_count; sno++) {
137
+                section = cfg_section[sno]
138
+                # The ini routines simply append a config item immediately
139
+                # after the section header. To keep the same order as defined
140
+                # in local.conf, invoke the ini routines in the reverse order
141
+                for (attr_no = cfg_sec_attr_count[sno] - 1; attr_no >=0; attr_no--) {
142
+                    attr = cfg_sec_attr_name[sno, attr_no]
143
+                    if (cfg_attr_count[section, attr] == 1)
144
+                        print "iniset " configfile " " section " " attr " \"" cfg_attr[section, attr, 0] "\""
145
+                    else {
146
+                        # For multiline, invoke the ini routines in the reverse order
147
+                        count = cfg_attr_count[section, attr]
148
+                        print "inidelete " configfile " " section " " attr
149
+                        print "iniset " configfile " " section " " attr " \"" cfg_attr[section, attr, count - 1] "\""
150
+                        for (l = count -2; l >= 0; l--)
151
+                            print "iniadd_literal " configfile " " section " " attr " \"" cfg_attr[section, attr, l] "\""
152
+                    }
153
+                }
154
+            }
155
+        }
156
+    ' | while read a; do eval "$a"; done
157
+}
158
+
159
+
160
+# Merge all of the files specified by group
161
+# merge_config_group infile group [group ...]
162
+function merge_config_group {
163
+    local localfile=$1; shift
164
+    local matchgroups=$@
165
+
166
+    [[ -r $localfile ]] || return 0
167
+
168
+    local configfile group
169
+    for group in $matchgroups; do
170
+        for configfile in $(get_meta_section_files $localfile $group); do
171
+            if [[ -d $(dirname $(eval "echo $configfile")) ]]; then
172
+                merge_config_file $localfile $group $configfile
173
+            fi
174
+        done
175
+    done
176
+}
177
+
178
+
179
+# Restore xtrace
180
+$INC_META_XTRACE
181
+
182
+# Local variables:
183
+# mode: shell-script
184
+# End:
0 185
deleted file mode 100644
... ...
@@ -1,183 +0,0 @@
1
-#!/bin/bash
2
-#
3
-# lib/config - Configuration file manipulation functions
4
-
5
-# These functions have no external dependencies and the following side-effects:
6
-#
7
-# CONFIG_AWK_CMD is defined, default is ``awk``
8
-
9
-# Meta-config files contain multiple INI-style configuration files
10
-# using a specific new section header to delimit them:
11
-#
12
-#   [[group-name|file-name]]
13
-#
14
-# group-name refers to the group of configuration file changes to be processed
15
-# at a particular time.  These are called phases in ``stack.sh`` but
16
-# group here as these functions are not DevStack-specific.
17
-#
18
-# file-name is the destination of the config file
19
-
20
-# Save trace setting
21
-C_XTRACE=$(set +o | grep xtrace)
22
-set +o xtrace
23
-
24
-
25
-# Allow the awk command to be overridden on legacy platforms
26
-CONFIG_AWK_CMD=${CONFIG_AWK_CMD:-awk}
27
-
28
-# Get the section for the specific group and config file
29
-# get_meta_section infile group configfile
30
-function get_meta_section {
31
-    local file=$1
32
-    local matchgroup=$2
33
-    local configfile=$3
34
-
35
-    [[ -r $file ]] || return 0
36
-    [[ -z $configfile ]] && return 0
37
-
38
-    $CONFIG_AWK_CMD -v matchgroup=$matchgroup -v configfile=$configfile '
39
-        BEGIN { group = "" }
40
-        /^\[\[.+\|.*\]\]/ {
41
-            if (group == "") {
42
-                gsub("[][]", "", $1);
43
-                split($1, a, "|");
44
-                if (a[1] == matchgroup && a[2] == configfile) {
45
-                    group=a[1]
46
-                }
47
-            } else {
48
-                group=""
49
-            }
50
-            next
51
-        }
52
-        {
53
-            if (group != "")
54
-                print $0
55
-        }
56
-    ' $file
57
-}
58
-
59
-
60
-# Get a list of config files for a specific group
61
-# get_meta_section_files infile group
62
-function get_meta_section_files {
63
-    local file=$1
64
-    local matchgroup=$2
65
-
66
-    [[ -r $file ]] || return 0
67
-
68
-    $CONFIG_AWK_CMD -v matchgroup=$matchgroup '
69
-        /^\[\[.+\|.*\]\]/ {
70
-            gsub("[][]", "", $1);
71
-            split($1, a, "|");
72
-            if (a[1] == matchgroup)
73
-                print a[2]
74
-        }
75
-    ' $file
76
-}
77
-
78
-
79
-# Merge the contents of a meta-config file into its destination config file
80
-# If configfile does not exist it will be created.
81
-# merge_config_file infile group configfile
82
-function merge_config_file {
83
-    local file=$1
84
-    local matchgroup=$2
85
-    local configfile=$3
86
-
87
-    get_meta_section $file $matchgroup $configfile | \
88
-    $CONFIG_AWK_CMD -v configfile=$configfile '
89
-        BEGIN {
90
-            section = ""
91
-            last_section = ""
92
-            section_count = 0
93
-        }
94
-        /^\[.+\]/ {
95
-            gsub("[][]", "", $1);
96
-            section=$1
97
-            next
98
-        }
99
-        /^ *\#/ {
100
-            next
101
-        }
102
-        /^[^ \t]+/ {
103
-            # get offset of first '=' in $0
104
-            eq_idx = index($0, "=")
105
-            # extract attr & value from $0
106
-            attr = substr($0, 1, eq_idx - 1)
107
-            value = substr($0, eq_idx + 1)
108
-            # only need to strip trailing whitespace from attr
109
-            sub(/[ \t]*$/, "", attr)
110
-            # need to strip leading & trailing whitespace from value
111
-            sub(/^[ \t]*/, "", value)
112
-            sub(/[ \t]*$/, "", value)
113
-
114
-            # cfg_attr_count: number of config lines per [section, attr]
115
-            # cfg_attr: three dimensional array to keep all the config lines per [section, attr]
116
-            # cfg_section: keep the section names in the same order as they appear in local.conf
117
-            # cfg_sec_attr_name: keep the attr names in the same order as they appear in local.conf
118
-            if (! (section, attr) in cfg_attr_count) {
119
-                if (section != last_section) {
120
-                    cfg_section[section_count++] = section
121
-                    last_section = section
122
-                }
123
-                attr_count = cfg_sec_attr_count[section_count - 1]++
124
-                cfg_sec_attr_name[section_count - 1, attr_count] = attr
125
-
126
-                cfg_attr[section, attr, 0] = value
127
-                cfg_attr_count[section, attr] = 1
128
-            } else {
129
-                lno = cfg_attr_count[section, attr]++
130
-                cfg_attr[section, attr, lno] = value
131
-            }
132
-        }
133
-        END {
134
-            # Process each section in order
135
-            for (sno = 0; sno < section_count; sno++) {
136
-                section = cfg_section[sno]
137
-                # The ini routines simply append a config item immediately
138
-                # after the section header. To keep the same order as defined
139
-                # in local.conf, invoke the ini routines in the reverse order
140
-                for (attr_no = cfg_sec_attr_count[sno] - 1; attr_no >=0; attr_no--) {
141
-                    attr = cfg_sec_attr_name[sno, attr_no]
142
-                    if (cfg_attr_count[section, attr] == 1)
143
-                        print "iniset " configfile " " section " " attr " \"" cfg_attr[section, attr, 0] "\""
144
-                    else {
145
-                        # For multiline, invoke the ini routines in the reverse order
146
-                        count = cfg_attr_count[section, attr]
147
-                        print "inidelete " configfile " " section " " attr
148
-                        print "iniset " configfile " " section " " attr " \"" cfg_attr[section, attr, count - 1] "\""
149
-                        for (l = count -2; l >= 0; l--)
150
-                            print "iniadd_literal " configfile " " section " " attr " \"" cfg_attr[section, attr, l] "\""
151
-                    }
152
-                }
153
-            }
154
-        }
155
-    ' | while read a; do eval "$a"; done
156
-}
157
-
158
-
159
-# Merge all of the files specified by group
160
-# merge_config_group infile group [group ...]
161
-function merge_config_group {
162
-    local localfile=$1; shift
163
-    local matchgroups=$@
164
-
165
-    [[ -r $localfile ]] || return 0
166
-
167
-    local configfile group
168
-    for group in $matchgroups; do
169
-        for configfile in $(get_meta_section_files $localfile $group); do
170
-            if [[ -d $(dirname $(eval "echo $configfile")) ]]; then
171
-                merge_config_file $localfile $group $configfile
172
-            fi
173
-        done
174
-    done
175
-}
176
-
177
-
178
-# Restore xtrace
179
-$C_XTRACE
180
-
181
-# Local variables:
182
-# mode: shell-script
183
-# End:
... ...
@@ -92,7 +92,7 @@ LAST_SPINNER_PID=""
92 92
 source $TOP_DIR/functions
93 93
 
94 94
 # Import config functions
95
-source $TOP_DIR/lib/config
95
+source $TOP_DIR/inc/meta-config
96 96
 
97 97
 # Import 'public' stack.sh functions
98 98
 source $TOP_DIR/lib/stack
99 99
deleted file mode 100755
... ...
@@ -1,346 +0,0 @@
1
-#!/usr/bin/env bash
2
-
3
-# Tests for DevStack meta-config functions
4
-
5
-TOP=$(cd $(dirname "$0")/.. && pwd)
6
-
7
-# Import common functions
8
-source $TOP/functions
9
-
10
-# Import config functions
11
-source $TOP/lib/config
12
-
13
-# check_result() tests and reports the result values
14
-# check_result "actual" "expected"
15
-function check_result {
16
-    local actual=$1
17
-    local expected=$2
18
-    if [[ "$actual" == "$expected" ]]; then
19
-        echo "OK"
20
-    else
21
-        echo -e "failed: $actual != $expected\n"
22
-    fi
23
-}
24
-
25
-TEST_1C_ADD="[eee]
26
-type=new
27
-multi = foo2"
28
-
29
-function create_test1c {
30
-    cat >test1c.conf <<EOF
31
-[eee]
32
-# original comment
33
-type=original
34
-EOF
35
-}
36
-
37
-function create_test2a {
38
-    cat >test2a.conf <<EOF
39
-[ddd]
40
-# original comment
41
-type=original
42
-EOF
43
-}
44
-
45
-function setup_test4 {
46
-    mkdir -p test-etc
47
-    cat >test-etc/test4.conf <<EOF
48
-[fff]
49
-# original comment
50
-type=original
51
-EOF
52
-    TEST4_DIR="test-etc"
53
-    TEST4_FILE="test4.conf"
54
-}
55
-
56
-cat >test.conf <<EOF
57
-[[test1|test1a.conf]]
58
-[default]
59
-# comment an option
60
-#log_file=./log.conf
61
-log_file=/etc/log.conf
62
-handlers=do not disturb
63
-
64
-[aaa]
65
-# the commented option should not change
66
-#handlers=cc,dd
67
-handlers = aa, bb
68
-
69
-[[test1|test1b.conf]]
70
-[bbb]
71
-handlers=ee,ff
72
-
73
-[ ccc ]
74
-spaces  =  yes
75
-
76
-[[test2|test2a.conf]]
77
-[ddd]
78
-# new comment
79
-type=new
80
-additional=true
81
-
82
-[[test1|test1c.conf]]
83
-$TEST_1C_ADD
84
-
85
-[[test3|test-space.conf]]
86
-[DEFAULT]
87
-attribute=value
88
- 
89
-# the above line has a single space
90
-
91
-[[test4|\$TEST4_DIR/\$TEST4_FILE]]
92
-[fff]
93
-type=new
94
-
95
-[[test-env|test-env.conf]]
96
-[foo]
97
-foo=\${FOO_BAR_BAZ}
98
-
99
-[[test5|test-equals.conf]]
100
-[DEFAULT]
101
-drivers = driver=python.import.path.Driver
102
-
103
-[[test6|test-strip.conf]]
104
-[DEFAULT]
105
-# next line has trailing space
106
-attr = strip_trailing_space
107
-
108
-[[test7|test-colon.conf]]
109
-[DEFAULT]
110
-servers=10.11.12.13:80
111
-
112
-[[test-multi-sections|test-multi-sections.conf]]
113
-[sec-1]
114
-cfg_item1 = abcd
115
-cfg_item2 = efgh
116
-
117
-[sec-2]
118
-cfg_item1 = abcd
119
-cfg_item3 = /1/2/3/4:5
120
-cfg_item4 = end
121
-
122
-[sec-3]
123
-cfg_item5 = 5555
124
-cfg_item6 = 6666
125
-cfg_item5 = 5555another
126
-
127
-[[test-multiline|test-multiline.conf]]
128
-[multi]
129
-cfg_item1 = ab:cd:ef:gh
130
-cfg_item1 = abcd
131
-cfg_item2 = efgh
132
-cfg_item2 = \${FOO_BAR_BAZ}
133
-
134
-EOF
135
-
136
-echo -n "get_meta_section_files: test0 doesn't exist: "
137
-VAL=$(get_meta_section_files test.conf test0)
138
-check_result "$VAL" ""
139
-
140
-echo -n "get_meta_section_files: test1 3 files: "
141
-VAL=$(get_meta_section_files test.conf test1)
142
-EXPECT_VAL="test1a.conf
143
-test1b.conf
144
-test1c.conf"
145
-check_result "$VAL" "$EXPECT_VAL"
146
-
147
-echo -n "get_meta_section_files: test2 1 file: "
148
-VAL=$(get_meta_section_files test.conf test2)
149
-EXPECT_VAL="test2a.conf"
150
-check_result "$VAL" "$EXPECT_VAL"
151
-
152
-
153
-# Get a section from a group that doesn't exist
154
-echo -n "get_meta_section: test0 doesn't exist: "
155
-VAL=$(get_meta_section test.conf test0 test0.conf)
156
-check_result "$VAL" ""
157
-
158
-# Get a single section from a group with multiple files
159
-echo -n "get_meta_section: test1c single section: "
160
-VAL=$(get_meta_section test.conf test1 test1c.conf)
161
-check_result "$VAL" "$TEST_1C_ADD"
162
-
163
-# Get a single section from a group with a single file
164
-echo -n "get_meta_section: test2a single section: "
165
-VAL=$(get_meta_section test.conf test2 test2a.conf)
166
-EXPECT_VAL="[ddd]
167
-# new comment
168
-type=new
169
-additional=true"
170
-check_result "$VAL" "$EXPECT_VAL"
171
-
172
-# Get a single section that doesn't exist from a group
173
-echo -n "get_meta_section: test2z.conf not in test2: "
174
-VAL=$(get_meta_section test.conf test2 test2z.conf)
175
-check_result "$VAL" ""
176
-
177
-# Get a section from a conf file that doesn't exist
178
-echo -n "get_meta_section: nofile doesn't exist: "
179
-VAL=$(get_meta_section nofile.ini test1)
180
-check_result "$VAL" ""
181
-
182
-echo -n "get_meta_section: nofile doesn't exist: "
183
-VAL=$(get_meta_section nofile.ini test0 test0.conf)
184
-check_result "$VAL" ""
185
-
186
-echo -n "merge_config_file test1c exists: "
187
-create_test1c
188
-merge_config_file test.conf test1 test1c.conf
189
-VAL=$(cat test1c.conf)
190
-# iniset adds values immediately under the section header
191
-EXPECT_VAL="[eee]
192
-multi = foo2
193
-# original comment
194
-type=new"
195
-check_result "$VAL" "$EXPECT_VAL"
196
-
197
-echo -n "merge_config_file test2a exists: "
198
-create_test2a
199
-merge_config_file test.conf test2 test2a.conf
200
-VAL=$(cat test2a.conf)
201
-# iniset adds values immediately under the section header
202
-EXPECT_VAL="[ddd]
203
-additional = true
204
-# original comment
205
-type=new"
206
-check_result "$VAL" "$EXPECT_VAL"
207
-
208
-echo -n "merge_config_file test2a not exist: "
209
-rm test2a.conf
210
-merge_config_file test.conf test2 test2a.conf
211
-VAL=$(cat test2a.conf)
212
-# iniset adds a blank line if it creates the file...
213
-EXPECT_VAL="
214
-[ddd]
215
-type = new
216
-additional = true"
217
-check_result "$VAL" "$EXPECT_VAL"
218
-
219
-echo -n "merge_config_file test-multi-sections: "
220
-rm -f test-multi-sections.conf
221
-merge_config_file test.conf test-multi-sections test-multi-sections.conf
222
-VAL=$(cat test-multi-sections.conf)
223
-EXPECT_VAL='
224
-[sec-1]
225
-cfg_item1 = abcd
226
-cfg_item2 = efgh
227
-
228
-[sec-2]
229
-cfg_item1 = abcd
230
-cfg_item3 = /1/2/3/4:5
231
-cfg_item4 = end
232
-
233
-[sec-3]
234
-cfg_item5 = 5555
235
-cfg_item5 = 5555another
236
-cfg_item6 = 6666'
237
-check_result "$VAL" "$EXPECT_VAL"
238
-
239
-echo -n "merge_config_file test-multiline: "
240
-rm -f test-multiline.conf
241
-FOO_BAR_BAZ="foo bar baz"
242
-merge_config_file test.conf test-multiline test-multiline.conf
243
-VAL=$(cat test-multiline.conf)
244
-EXPECT_VAL='
245
-[multi]
246
-cfg_item1 = ab:cd:ef:gh
247
-cfg_item1 = abcd
248
-cfg_item2 = efgh
249
-cfg_item2 = foo bar baz'
250
-check_result "$VAL" "$EXPECT_VAL"
251
-unset FOO_BAR_BAZ
252
-
253
-echo -n "merge_config_group test2: "
254
-rm test2a.conf
255
-merge_config_group test.conf test2
256
-VAL=$(cat test2a.conf)
257
-# iniset adds a blank line if it creates the file...
258
-EXPECT_VAL="
259
-[ddd]
260
-type = new
261
-additional = true"
262
-check_result "$VAL" "$EXPECT_VAL"
263
-
264
-echo -n "merge_config_group test2 no conf file: "
265
-rm test2a.conf
266
-merge_config_group x-test.conf test2
267
-if [[ ! -r test2a.conf ]]; then
268
-    echo "OK"
269
-else
270
-    echo "failed: $VAL != $EXPECT_VAL"
271
-fi
272
-
273
-echo -n "merge_config_file test-space: "
274
-rm -f test-space.conf
275
-merge_config_file test.conf test3 test-space.conf
276
-VAL=$(cat test-space.conf)
277
-# iniset adds a blank line if it creates the file...
278
-EXPECT_VAL="
279
-[DEFAULT]
280
-attribute = value"
281
-check_result "$VAL" "$EXPECT_VAL"
282
-
283
-echo -n "merge_config_file test-env: "
284
-rm -f test-env.conf
285
-FOO_BAR_BAZ="foo bar baz"
286
-merge_config_file test.conf test-env test-env.conf
287
-VAL=$(cat test-env.conf)
288
-EXPECT_VAL='
289
-[foo]
290
-foo = foo bar baz'
291
-check_result "$VAL" "$EXPECT_VAL"
292
-unset FOO_BAR_BAZ
293
-
294
-echo -n "merge_config_group test4 variable filename: "
295
-setup_test4
296
-merge_config_group test.conf test4
297
-VAL=$(cat test-etc/test4.conf)
298
-EXPECT_VAL="[fff]
299
-# original comment
300
-type=new"
301
-check_result "$VAL" "$EXPECT_VAL"
302
-
303
-echo -n "merge_config_group test4 variable filename (not exist): "
304
-setup_test4
305
-rm test-etc/test4.conf
306
-merge_config_group test.conf test4
307
-VAL=$(cat test-etc/test4.conf)
308
-EXPECT_VAL="
309
-[fff]
310
-type = new"
311
-check_result "$VAL" "$EXPECT_VAL"
312
-
313
-echo -n "merge_config_file test5 equals in value: "
314
-rm -f test-equals.conf
315
-merge_config_file test.conf test5 test-equals.conf
316
-VAL=$(cat test-equals.conf)
317
-# iniset adds a blank line if it creates the file...
318
-EXPECT_VAL="
319
-[DEFAULT]
320
-drivers = driver=python.import.path.Driver"
321
-check_result "$VAL" "$EXPECT_VAL"
322
-
323
-echo -n "merge_config_file test6 value stripped: "
324
-rm -f test-strip.conf
325
-merge_config_file test.conf test6 test-strip.conf
326
-VAL=$(cat test-strip.conf)
327
-# iniset adds a blank line if it creates the file...
328
-EXPECT_VAL="
329
-[DEFAULT]
330
-attr = strip_trailing_space"
331
-check_result "$VAL" "$EXPECT_VAL"
332
-
333
-echo -n "merge_config_file test7 colon in value: "
334
-rm -f test-colon.conf
335
-merge_config_file test.conf test7 test-colon.conf
336
-VAL=$(cat test-colon.conf)
337
-EXPECT_VAL="
338
-[DEFAULT]
339
-servers = 10.11.12.13:80"
340
-check_result "$VAL" "$EXPECT_VAL"
341
-
342
-rm -f test.conf test1c.conf test2a.conf \
343
-    test-space.conf test-equals.conf test-strip.conf \
344
-    test-colon.conf test-env.conf test-multiline.conf \
345
-    test-multi-sections.conf
346
-rm -rf test-etc
347 1
deleted file mode 100755
... ...
@@ -1,295 +0,0 @@
1
-#!/usr/bin/env bash
2
-
3
-# Tests for DevStack INI functions
4
-
5
-TOP=$(cd $(dirname "$0")/.. && pwd)
6
-
7
-# Import common functions
8
-source $TOP/functions
9
-
10
-
11
-echo "Testing INI functions"
12
-
13
-cat >test.ini <<EOF
14
-[default]
15
-# comment an option
16
-#log_file=./log.conf
17
-log_file=/etc/log.conf
18
-handlers=do not disturb
19
-
20
-[aaa]
21
-# the commented option should not change
22
-#handlers=cc,dd
23
-handlers = aa, bb
24
-
25
-[bbb]
26
-handlers=ee,ff
27
-
28
-[ ccc ]
29
-spaces  =  yes
30
-
31
-[ddd]
32
-empty =
33
-
34
-[eee]
35
-multi = foo1
36
-multi = foo2
37
-
38
-# inidelete(a)
39
-[del_separate_options]
40
-a=b
41
-b=c
42
-
43
-# inidelete(a)
44
-[del_same_option]
45
-a=b
46
-a=c
47
-
48
-# inidelete(a)
49
-[del_missing_option]
50
-b=c
51
-
52
-# inidelete(a)
53
-[del_missing_option_multi]
54
-b=c
55
-b=d
56
-
57
-# inidelete(a)
58
-[del_no_options]
59
-
60
-# inidelete(a)
61
-# no section - del_no_section
62
-
63
-EOF
64
-
65
-# Test with missing arguments
66
-
67
-BEFORE=$(cat test.ini)
68
-
69
-echo -n "iniset: test missing attribute argument: "
70
-iniset test.ini aaa
71
-NO_ATTRIBUTE=$(cat test.ini)
72
-if [[ "$BEFORE" == "$NO_ATTRIBUTE" ]]; then
73
-    echo "OK"
74
-else
75
-    echo "failed"
76
-fi
77
-
78
-echo -n "iniset: test missing section argument: "
79
-iniset test.ini
80
-NO_SECTION=$(cat test.ini)
81
-if [[ "$BEFORE" == "$NO_SECTION" ]]; then
82
-    echo "OK"
83
-else
84
-    echo "failed"
85
-fi
86
-
87
-# Test with spaces
88
-
89
-VAL=$(iniget test.ini aaa handlers)
90
-if [[ "$VAL" == "aa, bb" ]]; then
91
-    echo "OK: $VAL"
92
-else
93
-    echo "iniget failed: $VAL"
94
-fi
95
-
96
-iniset test.ini aaa handlers "11, 22"
97
-
98
-VAL=$(iniget test.ini aaa handlers)
99
-if [[ "$VAL" == "11, 22" ]]; then
100
-    echo "OK: $VAL"
101
-else
102
-    echo "iniget failed: $VAL"
103
-fi
104
-
105
-# Test with spaces in section header
106
-
107
-VAL=$(iniget test.ini " ccc " spaces)
108
-if [[ "$VAL" == "yes" ]]; then
109
-    echo "OK: $VAL"
110
-else
111
-    echo "iniget failed: $VAL"
112
-fi
113
-
114
-iniset test.ini "b b" opt_ion 42
115
-
116
-VAL=$(iniget test.ini "b b" opt_ion)
117
-if [[ "$VAL" == "42" ]]; then
118
-    echo "OK: $VAL"
119
-else
120
-    echo "iniget failed: $VAL"
121
-fi
122
-
123
-# Test without spaces, end of file
124
-
125
-VAL=$(iniget test.ini bbb handlers)
126
-if [[ "$VAL" == "ee,ff" ]]; then
127
-    echo "OK: $VAL"
128
-else
129
-    echo "iniget failed: $VAL"
130
-fi
131
-
132
-iniset test.ini bbb handlers "33,44"
133
-
134
-VAL=$(iniget test.ini bbb handlers)
135
-if [[ "$VAL" == "33,44" ]]; then
136
-    echo "OK: $VAL"
137
-else
138
-    echo "iniget failed: $VAL"
139
-fi
140
-
141
-# test empty option
142
-if ini_has_option test.ini ddd empty; then
143
-    echo "OK: ddd.empty present"
144
-else
145
-    echo "ini_has_option failed: ddd.empty not found"
146
-fi
147
-
148
-# test non-empty option
149
-if ini_has_option test.ini bbb handlers; then
150
-    echo "OK: bbb.handlers present"
151
-else
152
-    echo "ini_has_option failed: bbb.handlers not found"
153
-fi
154
-
155
-# test changing empty option
156
-iniset test.ini ddd empty "42"
157
-
158
-VAL=$(iniget test.ini ddd empty)
159
-if [[ "$VAL" == "42" ]]; then
160
-    echo "OK: $VAL"
161
-else
162
-    echo "iniget failed: $VAL"
163
-fi
164
-
165
-# test pipe in option
166
-iniset test.ini aaa handlers "a|b"
167
-
168
-VAL=$(iniget test.ini aaa handlers)
169
-if [[ "$VAL" == "a|b" ]]; then
170
-    echo "OK: $VAL"
171
-else
172
-    echo "iniget failed: $VAL"
173
-fi
174
-
175
-# test space in option
176
-iniset test.ini aaa handlers "a b"
177
-
178
-VAL="$(iniget test.ini aaa handlers)"
179
-if [[ "$VAL" == "a b" ]]; then
180
-    echo "OK: $VAL"
181
-else
182
-    echo "iniget failed: $VAL"
183
-fi
184
-
185
-# Test section not exist
186
-
187
-VAL=$(iniget test.ini zzz handlers)
188
-if [[ -z "$VAL" ]]; then
189
-    echo "OK: zzz not present"
190
-else
191
-    echo "iniget failed: $VAL"
192
-fi
193
-
194
-iniset test.ini zzz handlers "999"
195
-
196
-VAL=$(iniget test.ini zzz handlers)
197
-if [[ -n "$VAL" ]]; then
198
-    echo "OK: zzz not present"
199
-else
200
-    echo "iniget failed: $VAL"
201
-fi
202
-
203
-# Test option not exist
204
-
205
-VAL=$(iniget test.ini aaa debug)
206
-if [[ -z "$VAL" ]]; then
207
-    echo "OK aaa.debug not present"
208
-else
209
-    echo "iniget failed: $VAL"
210
-fi
211
-
212
-if ! ini_has_option test.ini aaa debug; then
213
-    echo "OK aaa.debug not present"
214
-else
215
-    echo "ini_has_option failed: aaa.debug"
216
-fi
217
-
218
-iniset test.ini aaa debug "999"
219
-
220
-VAL=$(iniget test.ini aaa debug)
221
-if [[ -n "$VAL" ]]; then
222
-    echo "OK aaa.debug present"
223
-else
224
-    echo "iniget failed: $VAL"
225
-fi
226
-
227
-# Test comments
228
-
229
-inicomment test.ini aaa handlers
230
-
231
-VAL=$(iniget test.ini aaa handlers)
232
-if [[ -z "$VAL" ]]; then
233
-    echo "OK"
234
-else
235
-    echo "inicomment failed: $VAL"
236
-fi
237
-
238
-# Test multiple line iniset/iniget
239
-iniset_multiline test.ini eee multi bar1 bar2
240
-
241
-VAL=$(iniget_multiline test.ini eee multi)
242
-if [[ "$VAL" == "bar1 bar2" ]]; then
243
-    echo "OK: iniset_multiline"
244
-else
245
-    echo "iniset_multiline failed: $VAL"
246
-fi
247
-
248
-# Test iniadd with exiting values
249
-iniadd test.ini eee multi bar3
250
-VAL=$(iniget_multiline test.ini eee multi)
251
-if [[ "$VAL" == "bar1 bar2 bar3" ]]; then
252
-    echo "OK: iniadd"
253
-else
254
-    echo "iniadd failed: $VAL"
255
-fi
256
-
257
-# Test iniadd with non-exiting values
258
-iniadd test.ini eee non-multi foobar1 foobar2
259
-VAL=$(iniget_multiline test.ini eee non-multi)
260
-if [[ "$VAL" == "foobar1 foobar2" ]]; then
261
-    echo "OK: iniadd with non-exiting value"
262
-else
263
-    echo "iniadd with non-exsting failed: $VAL"
264
-fi
265
-
266
-# Test inidelete
267
-del_cases="
268
-    del_separate_options
269
-    del_same_option
270
-    del_missing_option
271
-    del_missing_option_multi
272
-    del_no_options
273
-    del_no_section"
274
-
275
-for x in $del_cases; do
276
-    inidelete test.ini $x a
277
-    VAL=$(iniget_multiline test.ini $x a)
278
-    if [ -z "$VAL" ]; then
279
-        echo "OK: inidelete $x"
280
-    else
281
-        echo "inidelete $x failed: $VAL"
282
-    fi
283
-    if [ "$x" = "del_separate_options" -o \
284
-        "$x" = "del_missing_option" -o \
285
-        "$x" = "del_missing_option_multi" ]; then
286
-        VAL=$(iniget_multiline test.ini $x b)
287
-        if [ "$VAL" = "c" -o "$VAL" = "c d" ]; then
288
-            echo "OK: inidelete other_options $x"
289
-        else
290
-            echo "inidelete other_option $x failed: $VAL"
291
-        fi
292
-    fi
293
-done
294
-
295
-rm test.ini
296 1
new file mode 100755
... ...
@@ -0,0 +1,295 @@
0
+#!/usr/bin/env bash
1
+
2
+# Tests for DevStack INI functions
3
+
4
+TOP=$(cd $(dirname "$0")/.. && pwd)
5
+
6
+# Import config functions
7
+source $TOP/inc/ini-config
8
+
9
+
10
+echo "Testing INI functions"
11
+
12
+cat >test.ini <<EOF
13
+[default]
14
+# comment an option
15
+#log_file=./log.conf
16
+log_file=/etc/log.conf
17
+handlers=do not disturb
18
+
19
+[aaa]
20
+# the commented option should not change
21
+#handlers=cc,dd
22
+handlers = aa, bb
23
+
24
+[bbb]
25
+handlers=ee,ff
26
+
27
+[ ccc ]
28
+spaces  =  yes
29
+
30
+[ddd]
31
+empty =
32
+
33
+[eee]
34
+multi = foo1
35
+multi = foo2
36
+
37
+# inidelete(a)
38
+[del_separate_options]
39
+a=b
40
+b=c
41
+
42
+# inidelete(a)
43
+[del_same_option]
44
+a=b
45
+a=c
46
+
47
+# inidelete(a)
48
+[del_missing_option]
49
+b=c
50
+
51
+# inidelete(a)
52
+[del_missing_option_multi]
53
+b=c
54
+b=d
55
+
56
+# inidelete(a)
57
+[del_no_options]
58
+
59
+# inidelete(a)
60
+# no section - del_no_section
61
+
62
+EOF
63
+
64
+# Test with missing arguments
65
+
66
+BEFORE=$(cat test.ini)
67
+
68
+echo -n "iniset: test missing attribute argument: "
69
+iniset test.ini aaa
70
+NO_ATTRIBUTE=$(cat test.ini)
71
+if [[ "$BEFORE" == "$NO_ATTRIBUTE" ]]; then
72
+    echo "OK"
73
+else
74
+    echo "failed"
75
+fi
76
+
77
+echo -n "iniset: test missing section argument: "
78
+iniset test.ini
79
+NO_SECTION=$(cat test.ini)
80
+if [[ "$BEFORE" == "$NO_SECTION" ]]; then
81
+    echo "OK"
82
+else
83
+    echo "failed"
84
+fi
85
+
86
+# Test with spaces
87
+
88
+VAL=$(iniget test.ini aaa handlers)
89
+if [[ "$VAL" == "aa, bb" ]]; then
90
+    echo "OK: $VAL"
91
+else
92
+    echo "iniget failed: $VAL"
93
+fi
94
+
95
+iniset test.ini aaa handlers "11, 22"
96
+
97
+VAL=$(iniget test.ini aaa handlers)
98
+if [[ "$VAL" == "11, 22" ]]; then
99
+    echo "OK: $VAL"
100
+else
101
+    echo "iniget failed: $VAL"
102
+fi
103
+
104
+# Test with spaces in section header
105
+
106
+VAL=$(iniget test.ini " ccc " spaces)
107
+if [[ "$VAL" == "yes" ]]; then
108
+    echo "OK: $VAL"
109
+else
110
+    echo "iniget failed: $VAL"
111
+fi
112
+
113
+iniset test.ini "b b" opt_ion 42
114
+
115
+VAL=$(iniget test.ini "b b" opt_ion)
116
+if [[ "$VAL" == "42" ]]; then
117
+    echo "OK: $VAL"
118
+else
119
+    echo "iniget failed: $VAL"
120
+fi
121
+
122
+# Test without spaces, end of file
123
+
124
+VAL=$(iniget test.ini bbb handlers)
125
+if [[ "$VAL" == "ee,ff" ]]; then
126
+    echo "OK: $VAL"
127
+else
128
+    echo "iniget failed: $VAL"
129
+fi
130
+
131
+iniset test.ini bbb handlers "33,44"
132
+
133
+VAL=$(iniget test.ini bbb handlers)
134
+if [[ "$VAL" == "33,44" ]]; then
135
+    echo "OK: $VAL"
136
+else
137
+    echo "iniget failed: $VAL"
138
+fi
139
+
140
+# test empty option
141
+if ini_has_option test.ini ddd empty; then
142
+    echo "OK: ddd.empty present"
143
+else
144
+    echo "ini_has_option failed: ddd.empty not found"
145
+fi
146
+
147
+# test non-empty option
148
+if ini_has_option test.ini bbb handlers; then
149
+    echo "OK: bbb.handlers present"
150
+else
151
+    echo "ini_has_option failed: bbb.handlers not found"
152
+fi
153
+
154
+# test changing empty option
155
+iniset test.ini ddd empty "42"
156
+
157
+VAL=$(iniget test.ini ddd empty)
158
+if [[ "$VAL" == "42" ]]; then
159
+    echo "OK: $VAL"
160
+else
161
+    echo "iniget failed: $VAL"
162
+fi
163
+
164
+# test pipe in option
165
+iniset test.ini aaa handlers "a|b"
166
+
167
+VAL=$(iniget test.ini aaa handlers)
168
+if [[ "$VAL" == "a|b" ]]; then
169
+    echo "OK: $VAL"
170
+else
171
+    echo "iniget failed: $VAL"
172
+fi
173
+
174
+# test space in option
175
+iniset test.ini aaa handlers "a b"
176
+
177
+VAL="$(iniget test.ini aaa handlers)"
178
+if [[ "$VAL" == "a b" ]]; then
179
+    echo "OK: $VAL"
180
+else
181
+    echo "iniget failed: $VAL"
182
+fi
183
+
184
+# Test section not exist
185
+
186
+VAL=$(iniget test.ini zzz handlers)
187
+if [[ -z "$VAL" ]]; then
188
+    echo "OK: zzz not present"
189
+else
190
+    echo "iniget failed: $VAL"
191
+fi
192
+
193
+iniset test.ini zzz handlers "999"
194
+
195
+VAL=$(iniget test.ini zzz handlers)
196
+if [[ -n "$VAL" ]]; then
197
+    echo "OK: zzz not present"
198
+else
199
+    echo "iniget failed: $VAL"
200
+fi
201
+
202
+# Test option not exist
203
+
204
+VAL=$(iniget test.ini aaa debug)
205
+if [[ -z "$VAL" ]]; then
206
+    echo "OK aaa.debug not present"
207
+else
208
+    echo "iniget failed: $VAL"
209
+fi
210
+
211
+if ! ini_has_option test.ini aaa debug; then
212
+    echo "OK aaa.debug not present"
213
+else
214
+    echo "ini_has_option failed: aaa.debug"
215
+fi
216
+
217
+iniset test.ini aaa debug "999"
218
+
219
+VAL=$(iniget test.ini aaa debug)
220
+if [[ -n "$VAL" ]]; then
221
+    echo "OK aaa.debug present"
222
+else
223
+    echo "iniget failed: $VAL"
224
+fi
225
+
226
+# Test comments
227
+
228
+inicomment test.ini aaa handlers
229
+
230
+VAL=$(iniget test.ini aaa handlers)
231
+if [[ -z "$VAL" ]]; then
232
+    echo "OK"
233
+else
234
+    echo "inicomment failed: $VAL"
235
+fi
236
+
237
+# Test multiple line iniset/iniget
238
+iniset_multiline test.ini eee multi bar1 bar2
239
+
240
+VAL=$(iniget_multiline test.ini eee multi)
241
+if [[ "$VAL" == "bar1 bar2" ]]; then
242
+    echo "OK: iniset_multiline"
243
+else
244
+    echo "iniset_multiline failed: $VAL"
245
+fi
246
+
247
+# Test iniadd with exiting values
248
+iniadd test.ini eee multi bar3
249
+VAL=$(iniget_multiline test.ini eee multi)
250
+if [[ "$VAL" == "bar1 bar2 bar3" ]]; then
251
+    echo "OK: iniadd"
252
+else
253
+    echo "iniadd failed: $VAL"
254
+fi
255
+
256
+# Test iniadd with non-exiting values
257
+iniadd test.ini eee non-multi foobar1 foobar2
258
+VAL=$(iniget_multiline test.ini eee non-multi)
259
+if [[ "$VAL" == "foobar1 foobar2" ]]; then
260
+    echo "OK: iniadd with non-exiting value"
261
+else
262
+    echo "iniadd with non-exsting failed: $VAL"
263
+fi
264
+
265
+# Test inidelete
266
+del_cases="
267
+    del_separate_options
268
+    del_same_option
269
+    del_missing_option
270
+    del_missing_option_multi
271
+    del_no_options
272
+    del_no_section"
273
+
274
+for x in $del_cases; do
275
+    inidelete test.ini $x a
276
+    VAL=$(iniget_multiline test.ini $x a)
277
+    if [ -z "$VAL" ]; then
278
+        echo "OK: inidelete $x"
279
+    else
280
+        echo "inidelete $x failed: $VAL"
281
+    fi
282
+    if [ "$x" = "del_separate_options" -o \
283
+        "$x" = "del_missing_option" -o \
284
+        "$x" = "del_missing_option_multi" ]; then
285
+        VAL=$(iniget_multiline test.ini $x b)
286
+        if [ "$VAL" = "c" -o "$VAL" = "c d" ]; then
287
+            echo "OK: inidelete other_options $x"
288
+        else
289
+            echo "inidelete other_option $x failed: $VAL"
290
+        fi
291
+    fi
292
+done
293
+
294
+rm test.ini
0 295
new file mode 100755
... ...
@@ -0,0 +1,344 @@
0
+#!/usr/bin/env bash
1
+
2
+# Tests for DevStack meta-config functions
3
+
4
+TOP=$(cd $(dirname "$0")/.. && pwd)
5
+
6
+# Import config functions
7
+source $TOP/inc/ini-config
8
+source $TOP/inc/meta-config
9
+
10
+# check_result() tests and reports the result values
11
+# check_result "actual" "expected"
12
+function check_result {
13
+    local actual=$1
14
+    local expected=$2
15
+    if [[ "$actual" == "$expected" ]]; then
16
+        echo "OK"
17
+    else
18
+        echo -e "failed: $actual != $expected\n"
19
+    fi
20
+}
21
+
22
+TEST_1C_ADD="[eee]
23
+type=new
24
+multi = foo2"
25
+
26
+function create_test1c {
27
+    cat >test1c.conf <<EOF
28
+[eee]
29
+# original comment
30
+type=original
31
+EOF
32
+}
33
+
34
+function create_test2a {
35
+    cat >test2a.conf <<EOF
36
+[ddd]
37
+# original comment
38
+type=original
39
+EOF
40
+}
41
+
42
+function setup_test4 {
43
+    mkdir -p test-etc
44
+    cat >test-etc/test4.conf <<EOF
45
+[fff]
46
+# original comment
47
+type=original
48
+EOF
49
+    TEST4_DIR="test-etc"
50
+    TEST4_FILE="test4.conf"
51
+}
52
+
53
+cat >test.conf <<EOF
54
+[[test1|test1a.conf]]
55
+[default]
56
+# comment an option
57
+#log_file=./log.conf
58
+log_file=/etc/log.conf
59
+handlers=do not disturb
60
+
61
+[aaa]
62
+# the commented option should not change
63
+#handlers=cc,dd
64
+handlers = aa, bb
65
+
66
+[[test1|test1b.conf]]
67
+[bbb]
68
+handlers=ee,ff
69
+
70
+[ ccc ]
71
+spaces  =  yes
72
+
73
+[[test2|test2a.conf]]
74
+[ddd]
75
+# new comment
76
+type=new
77
+additional=true
78
+
79
+[[test1|test1c.conf]]
80
+$TEST_1C_ADD
81
+
82
+[[test3|test-space.conf]]
83
+[DEFAULT]
84
+attribute=value
85
+ 
86
+# the above line has a single space
87
+
88
+[[test4|\$TEST4_DIR/\$TEST4_FILE]]
89
+[fff]
90
+type=new
91
+
92
+[[test-env|test-env.conf]]
93
+[foo]
94
+foo=\${FOO_BAR_BAZ}
95
+
96
+[[test5|test-equals.conf]]
97
+[DEFAULT]
98
+drivers = driver=python.import.path.Driver
99
+
100
+[[test6|test-strip.conf]]
101
+[DEFAULT]
102
+# next line has trailing space
103
+attr = strip_trailing_space
104
+
105
+[[test7|test-colon.conf]]
106
+[DEFAULT]
107
+servers=10.11.12.13:80
108
+
109
+[[test-multi-sections|test-multi-sections.conf]]
110
+[sec-1]
111
+cfg_item1 = abcd
112
+cfg_item2 = efgh
113
+
114
+[sec-2]
115
+cfg_item1 = abcd
116
+cfg_item3 = /1/2/3/4:5
117
+cfg_item4 = end
118
+
119
+[sec-3]
120
+cfg_item5 = 5555
121
+cfg_item6 = 6666
122
+cfg_item5 = 5555another
123
+
124
+[[test-multiline|test-multiline.conf]]
125
+[multi]
126
+cfg_item1 = ab:cd:ef:gh
127
+cfg_item1 = abcd
128
+cfg_item2 = efgh
129
+cfg_item2 = \${FOO_BAR_BAZ}
130
+
131
+EOF
132
+
133
+echo -n "get_meta_section_files: test0 doesn't exist: "
134
+VAL=$(get_meta_section_files test.conf test0)
135
+check_result "$VAL" ""
136
+
137
+echo -n "get_meta_section_files: test1 3 files: "
138
+VAL=$(get_meta_section_files test.conf test1)
139
+EXPECT_VAL="test1a.conf
140
+test1b.conf
141
+test1c.conf"
142
+check_result "$VAL" "$EXPECT_VAL"
143
+
144
+echo -n "get_meta_section_files: test2 1 file: "
145
+VAL=$(get_meta_section_files test.conf test2)
146
+EXPECT_VAL="test2a.conf"
147
+check_result "$VAL" "$EXPECT_VAL"
148
+
149
+
150
+# Get a section from a group that doesn't exist
151
+echo -n "get_meta_section: test0 doesn't exist: "
152
+VAL=$(get_meta_section test.conf test0 test0.conf)
153
+check_result "$VAL" ""
154
+
155
+# Get a single section from a group with multiple files
156
+echo -n "get_meta_section: test1c single section: "
157
+VAL=$(get_meta_section test.conf test1 test1c.conf)
158
+check_result "$VAL" "$TEST_1C_ADD"
159
+
160
+# Get a single section from a group with a single file
161
+echo -n "get_meta_section: test2a single section: "
162
+VAL=$(get_meta_section test.conf test2 test2a.conf)
163
+EXPECT_VAL="[ddd]
164
+# new comment
165
+type=new
166
+additional=true"
167
+check_result "$VAL" "$EXPECT_VAL"
168
+
169
+# Get a single section that doesn't exist from a group
170
+echo -n "get_meta_section: test2z.conf not in test2: "
171
+VAL=$(get_meta_section test.conf test2 test2z.conf)
172
+check_result "$VAL" ""
173
+
174
+# Get a section from a conf file that doesn't exist
175
+echo -n "get_meta_section: nofile doesn't exist: "
176
+VAL=$(get_meta_section nofile.ini test1)
177
+check_result "$VAL" ""
178
+
179
+echo -n "get_meta_section: nofile doesn't exist: "
180
+VAL=$(get_meta_section nofile.ini test0 test0.conf)
181
+check_result "$VAL" ""
182
+
183
+echo -n "merge_config_file test1c exists: "
184
+create_test1c
185
+merge_config_file test.conf test1 test1c.conf
186
+VAL=$(cat test1c.conf)
187
+# iniset adds values immediately under the section header
188
+EXPECT_VAL="[eee]
189
+multi = foo2
190
+# original comment
191
+type=new"
192
+check_result "$VAL" "$EXPECT_VAL"
193
+
194
+echo -n "merge_config_file test2a exists: "
195
+create_test2a
196
+merge_config_file test.conf test2 test2a.conf
197
+VAL=$(cat test2a.conf)
198
+# iniset adds values immediately under the section header
199
+EXPECT_VAL="[ddd]
200
+additional = true
201
+# original comment
202
+type=new"
203
+check_result "$VAL" "$EXPECT_VAL"
204
+
205
+echo -n "merge_config_file test2a not exist: "
206
+rm test2a.conf
207
+merge_config_file test.conf test2 test2a.conf
208
+VAL=$(cat test2a.conf)
209
+# iniset adds a blank line if it creates the file...
210
+EXPECT_VAL="
211
+[ddd]
212
+type = new
213
+additional = true"
214
+check_result "$VAL" "$EXPECT_VAL"
215
+
216
+echo -n "merge_config_file test-multi-sections: "
217
+rm -f test-multi-sections.conf
218
+merge_config_file test.conf test-multi-sections test-multi-sections.conf
219
+VAL=$(cat test-multi-sections.conf)
220
+EXPECT_VAL='
221
+[sec-1]
222
+cfg_item1 = abcd
223
+cfg_item2 = efgh
224
+
225
+[sec-2]
226
+cfg_item1 = abcd
227
+cfg_item3 = /1/2/3/4:5
228
+cfg_item4 = end
229
+
230
+[sec-3]
231
+cfg_item5 = 5555
232
+cfg_item5 = 5555another
233
+cfg_item6 = 6666'
234
+check_result "$VAL" "$EXPECT_VAL"
235
+
236
+echo -n "merge_config_file test-multiline: "
237
+rm -f test-multiline.conf
238
+FOO_BAR_BAZ="foo bar baz"
239
+merge_config_file test.conf test-multiline test-multiline.conf
240
+VAL=$(cat test-multiline.conf)
241
+EXPECT_VAL='
242
+[multi]
243
+cfg_item1 = ab:cd:ef:gh
244
+cfg_item1 = abcd
245
+cfg_item2 = efgh
246
+cfg_item2 = foo bar baz'
247
+check_result "$VAL" "$EXPECT_VAL"
248
+unset FOO_BAR_BAZ
249
+
250
+echo -n "merge_config_group test2: "
251
+rm test2a.conf
252
+merge_config_group test.conf test2
253
+VAL=$(cat test2a.conf)
254
+# iniset adds a blank line if it creates the file...
255
+EXPECT_VAL="
256
+[ddd]
257
+type = new
258
+additional = true"
259
+check_result "$VAL" "$EXPECT_VAL"
260
+
261
+echo -n "merge_config_group test2 no conf file: "
262
+rm test2a.conf
263
+merge_config_group x-test.conf test2
264
+if [[ ! -r test2a.conf ]]; then
265
+    echo "OK"
266
+else
267
+    echo "failed: $VAL != $EXPECT_VAL"
268
+fi
269
+
270
+echo -n "merge_config_file test-space: "
271
+rm -f test-space.conf
272
+merge_config_file test.conf test3 test-space.conf
273
+VAL=$(cat test-space.conf)
274
+# iniset adds a blank line if it creates the file...
275
+EXPECT_VAL="
276
+[DEFAULT]
277
+attribute = value"
278
+check_result "$VAL" "$EXPECT_VAL"
279
+
280
+echo -n "merge_config_file test-env: "
281
+rm -f test-env.conf
282
+FOO_BAR_BAZ="foo bar baz"
283
+merge_config_file test.conf test-env test-env.conf
284
+VAL=$(cat test-env.conf)
285
+EXPECT_VAL='
286
+[foo]
287
+foo = foo bar baz'
288
+check_result "$VAL" "$EXPECT_VAL"
289
+unset FOO_BAR_BAZ
290
+
291
+echo -n "merge_config_group test4 variable filename: "
292
+setup_test4
293
+merge_config_group test.conf test4
294
+VAL=$(cat test-etc/test4.conf)
295
+EXPECT_VAL="[fff]
296
+# original comment
297
+type=new"
298
+check_result "$VAL" "$EXPECT_VAL"
299
+
300
+echo -n "merge_config_group test4 variable filename (not exist): "
301
+setup_test4
302
+rm test-etc/test4.conf
303
+merge_config_group test.conf test4
304
+VAL=$(cat test-etc/test4.conf)
305
+EXPECT_VAL="
306
+[fff]
307
+type = new"
308
+check_result "$VAL" "$EXPECT_VAL"
309
+
310
+echo -n "merge_config_file test5 equals in value: "
311
+rm -f test-equals.conf
312
+merge_config_file test.conf test5 test-equals.conf
313
+VAL=$(cat test-equals.conf)
314
+# iniset adds a blank line if it creates the file...
315
+EXPECT_VAL="
316
+[DEFAULT]
317
+drivers = driver=python.import.path.Driver"
318
+check_result "$VAL" "$EXPECT_VAL"
319
+
320
+echo -n "merge_config_file test6 value stripped: "
321
+rm -f test-strip.conf
322
+merge_config_file test.conf test6 test-strip.conf
323
+VAL=$(cat test-strip.conf)
324
+# iniset adds a blank line if it creates the file...
325
+EXPECT_VAL="
326
+[DEFAULT]
327
+attr = strip_trailing_space"
328
+check_result "$VAL" "$EXPECT_VAL"
329
+
330
+echo -n "merge_config_file test7 colon in value: "
331
+rm -f test-colon.conf
332
+merge_config_file test.conf test7 test-colon.conf
333
+VAL=$(cat test-colon.conf)
334
+EXPECT_VAL="
335
+[DEFAULT]
336
+servers = 10.11.12.13:80"
337
+check_result "$VAL" "$EXPECT_VAL"
338
+
339
+rm -f test.conf test1c.conf test2a.conf \
340
+    test-space.conf test-equals.conf test-strip.conf \
341
+    test-colon.conf test-env.conf test-multiline.conf \
342
+    test-multi-sections.conf
343
+rm -rf test-etc
... ...
@@ -81,7 +81,7 @@ for f in $(find . -name .git -prune -o \( -type f -name \*.sh -not -path \*shocc
81 81
     mkdir -p $FQ_HTML_BUILD/`dirname $f`;
82 82
     $SHOCCO $f > $FQ_HTML_BUILD/$f.html
83 83
 done
84
-for f in $(find functions functions-common lib samples -type f -name \*); do
84
+for f in $(find functions functions-common inc lib pkg samples -type f -name \*); do
85 85
     echo $f
86 86
     FILES+="$f "
87 87
     mkdir -p $FQ_HTML_BUILD/`dirname $f`;
... ...
@@ -20,6 +20,7 @@ commands = bash -c "find {toxinidir}          \
20 20
           -name \*.sh -or                     \
21 21
           -name \*rc -or                      \
22 22
           -name functions\* -or               \
23
+          -wholename \*/inc/\*                \ # /inc files and
23 24
           -wholename \*/lib/\*                \ # /lib files are shell, but
24 25
          \)                                   \ #   have no extension
25 26
          -print0 | xargs -0 bashate -v"