Find pieces of apache configuration elsewhere that the default location
This commit is contained in:
parent
7ba2130393
commit
58c6db8185
20
inventory.sh
20
inventory.sh
|
@ -1,7 +1,5 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
# TODO find pieces of apache conf in /etc
|
|
||||||
# TODO Handle /sur/share/scripts/vhost...
|
|
||||||
# TODO total by host: vhost, htaccess, conf, cgi
|
# TODO total by host: vhost, htaccess, conf, cgi
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
@ -15,6 +13,7 @@ confs=$tmp_dir/confs
|
||||||
confs_vhost=$tmp_dir/confs_vhost
|
confs_vhost=$tmp_dir/confs_vhost
|
||||||
confs_system=$tmp_dir/confs_system
|
confs_system=$tmp_dir/confs_system
|
||||||
confs_htaccess=$tmp_dir/confs_htaccess
|
confs_htaccess=$tmp_dir/confs_htaccess
|
||||||
|
confs_template=$tmp_dir/confs_template
|
||||||
result=$tmp_dir/result
|
result=$tmp_dir/result
|
||||||
summary=$tmp_dir/summary
|
summary=$tmp_dir/summary
|
||||||
|
|
||||||
|
@ -52,8 +51,18 @@ get_htaccess() {
|
||||||
| xargs -I _ find _ -type f -name .htaccess || true
|
| xargs -I _ find _ -type f -name .htaccess || true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Find directives in non apache location. It can be configuration for
|
||||||
|
# phpmyadmin or the default vhost template for example.
|
||||||
|
get_template() {
|
||||||
|
template_dirs="/etc /usr/share/scripts"
|
||||||
|
grep -RE '^[[:space:]]*(Order|Allow|Deny|Satisfy)[[:space:]]' \
|
||||||
|
--exclude-dir=apache2 --exclude-dir=squid3 "$template_dirs" \
|
||||||
|
2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
# Put different type of configs in different files
|
# Put different type of configs in different files
|
||||||
categorize_confs() {
|
categorize_confs() {
|
||||||
|
get_template > "$confs_template"
|
||||||
get_htaccess > "$confs_htaccess"
|
get_htaccess > "$confs_htaccess"
|
||||||
grep -E "^${apache_dir}/sites-enabled/.*\\.conf" "$confs" > "$confs_vhost"
|
grep -E "^${apache_dir}/sites-enabled/.*\\.conf" "$confs" > "$confs_vhost"
|
||||||
grep -Ev "^${apache_dir}/sites-enabled/.*\\.conf" "$confs" > "$confs_system"
|
grep -Ev "^${apache_dir}/sites-enabled/.*\\.conf" "$confs" > "$confs_system"
|
||||||
|
@ -81,8 +90,8 @@ count_directives() {
|
||||||
display_results() {
|
display_results() {
|
||||||
mv -b "$result" "$result".bak || true
|
mv -b "$result" "$result".bak || true
|
||||||
|
|
||||||
# Types: Vhost, System, Htaccess
|
# Types: Vhost, System, Htaccess, Template
|
||||||
printf 'File\tAllow\tOrder\tDeny\tSatsify\tTotal (directives)\tCGI\tType (V|S|H)\n' >&2
|
printf 'File\tAllow\tOrder\tDeny\tSatsify\tTotal (directives)\tCGI\tType (V|S|H|T)\n' >&2
|
||||||
while IFS= read -r file; do
|
while IFS= read -r file; do
|
||||||
count_directives "$file" V | tee -a "$result"
|
count_directives "$file" V | tee -a "$result"
|
||||||
done < "$confs_vhost"
|
done < "$confs_vhost"
|
||||||
|
@ -92,6 +101,9 @@ display_results() {
|
||||||
while IFS= read -r file; do
|
while IFS= read -r file; do
|
||||||
count_directives "$file" H | tee -a "$result"
|
count_directives "$file" H | tee -a "$result"
|
||||||
done < "$confs_htaccess"
|
done < "$confs_htaccess"
|
||||||
|
while IFS= read -r file; do
|
||||||
|
count_directives "$file" T | tee -a "$result"
|
||||||
|
done < "$confs_template"
|
||||||
}
|
}
|
||||||
|
|
||||||
# One line machine summary of the results
|
# One line machine summary of the results
|
||||||
|
|
Loading…
Reference in a new issue