Initial commit
This commit is contained in:
commit
465796fa7f
5
example/dummy.conf
Normal file
5
example/dummy.conf
Normal file
|
@ -0,0 +1,5 @@
|
|||
# Include /comment
|
||||
Include /spaces
|
||||
Include /none
|
||||
Include /tabs
|
||||
# Include /spaces/comment
|
51
inventaire.sh
Executable file
51
inventaire.sh
Executable file
|
@ -0,0 +1,51 @@
|
|||
#/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
apache_dir=/etc/apache2
|
||||
apache_conf=$apache_dir/apache2.conf
|
||||
|
||||
tmp_dir=$(mktemp -d /tmp/apache-require.XXXX)
|
||||
conf_files=$tmp_dir/conf_files
|
||||
|
||||
module_loaded() {
|
||||
apache2ctl -D DUMP_MODULES | grep -q access_compat_module
|
||||
}
|
||||
|
||||
# Get all config files included the
|
||||
get_conf_files() {
|
||||
# Initialize le the list of configuration files with the default conf
|
||||
printf "%s\\n" $apache_conf > "$conf_files"
|
||||
|
||||
# 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
|
||||
# XXX: Expand the filenames
|
||||
for glob in $(awk '/^[[:space:]]*Include/ {print $2}' "$conf_file"); do
|
||||
realpath $glob >> "$conf_files"
|
||||
done
|
||||
done
|
||||
sort "$conf_files" | uniq > "$conf_files"_tmp && mv "$conf_files"_tmp "$conf_files"
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
count_directives() {
|
||||
directives="Allow Order Deny Satisfy"
|
||||
|
||||
for directive in $directives; do
|
||||
export "$directive"="$(grep -Ec "^[[:blank:]]*$directive\\s" "$1")"
|
||||
done
|
||||
# shellcheck disable=SC2154
|
||||
printf "%s %d %d %d %d\\n" "$1" "$Allow" "$Order" "$Deny" "$Satisfy"
|
||||
}
|
||||
|
||||
# Display the result
|
||||
for file in $(cat $conf_files); do
|
||||
count_directives "$file"
|
||||
done
|
||||
|
||||
|
||||
# TODO Find .htacces from ServerHome
|
Loading…
Reference in a new issue