Rename conf_files to confs
This commit is contained in:
parent
340041420e
commit
4594f96547
22
inventory.sh
22
inventory.sh
|
@ -11,7 +11,7 @@ apache_dir=/etc/apache2
|
|||
apache_conf=$apache_dir/apache2.conf
|
||||
|
||||
tmp_dir=/tmp/apache-require
|
||||
conf_files=$tmp_dir/conf_files
|
||||
confs=$tmp_dir/confs
|
||||
files_with_directives=$tmp_dir/files_with_directives
|
||||
mkdir -p "$tmp_dir"
|
||||
|
||||
|
@ -20,22 +20,22 @@ module_loaded() {
|
|||
}
|
||||
|
||||
# Get all config files included the
|
||||
get_conf_files() {
|
||||
get_confs() {
|
||||
# Initialize le the list of configuration files with the default conf
|
||||
test ! -e "$conf_files" && printf "%s\\n" $apache_conf > "$conf_files"
|
||||
test ! -e "$confs" && printf "%s\\n" $apache_conf > "$confs"
|
||||
|
||||
cd "$apache_dir"
|
||||
# TODO: Refactor this mess
|
||||
conf_files_size=0
|
||||
while [ "$conf_files_size" -lt "$(stat -c %s "$conf_files")" ]; do
|
||||
conf_files_size=$(stat -c %s "$conf_files")
|
||||
for conf_file in $(cat "$conf_files"); do
|
||||
confs_size=0
|
||||
while [ "$confs_size" -lt "$(stat -c %s "$confs")" ]; do
|
||||
confs_size=$(stat -c %s "$confs")
|
||||
for conf_file in $(cat "$confs"); do
|
||||
# XXX: Expand the filenames
|
||||
for glob in $(awk '/^[[:space:]]*Include/ {print $2}' "$conf_file"); do
|
||||
realpath $glob >> "$conf_files"
|
||||
realpath $glob >> "$confs"
|
||||
done
|
||||
done
|
||||
sort "$conf_files" | uniq > "$conf_files"_tmp && mv "$conf_files"_tmp "$conf_files"
|
||||
sort "$confs" | uniq > "$confs"_tmp && mv "$confs"_tmp "$confs"
|
||||
done
|
||||
cd - 1>/dev/null
|
||||
}
|
||||
|
@ -59,10 +59,10 @@ display_results() {
|
|||
|
||||
printf 'File\tAllow\tOrder\tDeny\tSatsify\n' >&2
|
||||
# TODO make shellcheck happy
|
||||
for file in $(cat $conf_files); do
|
||||
for file in $(cat $confs); do
|
||||
count_directives "$file" | tee -a "$files_with_directives"
|
||||
done
|
||||
}
|
||||
|
||||
get_conf_files
|
||||
get_confs
|
||||
display_results
|
||||
|
|
Loading…
Reference in a new issue