-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapache_vhost_audit.sh
More file actions
executable file
·50 lines (41 loc) · 1.11 KB
/
Copy pathapache_vhost_audit.sh
File metadata and controls
executable file
·50 lines (41 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
set -euo pipefail
# apache_vhost_audit.sh
# Audits Apache vhost setup and syntax status.
usage() {
cat <<'EOF'
Usage: ./apache_vhost_audit.sh [options]
Options:
--apachectl PATH apachectl path (default: apachectl)
--httpd PATH fallback binary for syntax check
-h, --help Show help
EOF
}
APACHECTL_BIN="apachectl"
HTTPD_BIN=""
while [[ $# -gt 0 ]]; do
case "$1" in
--apachectl) APACHECTL_BIN="$2"; shift 2 ;;
--httpd) HTTPD_BIN="$2"; shift 2 ;;
-h|--help) usage; exit 0 ;;
*) echo "Unknown option: $1"; usage; exit 1 ;;
esac
done
if command -v "$APACHECTL_BIN" >/dev/null 2>&1; then
echo "Apache syntax test:"
sudo "$APACHECTL_BIN" configtest
echo
echo "Apache virtual hosts:"
sudo "$APACHECTL_BIN" -S || true
elif [[ -n "$HTTPD_BIN" && -x "$HTTPD_BIN" ]]; then
echo "Apache syntax test via httpd binary:"
sudo "$HTTPD_BIN" -t
else
echo "apachectl not found; provide --apachectl or --httpd"
exit 1
fi
if [[ -d /etc/apache2/sites-enabled ]]; then
echo
echo "Enabled Apache site files:"
ls -1 /etc/apache2/sites-enabled | cat
fi