generated from nhcarrigan/template
24 lines
627 B
Bash
Executable File
24 lines
627 B
Bash
Executable File
#!/bin/bash
|
|
|
|
CONF="configs/prod.conf"
|
|
|
|
# Extract server_name values in order, ignoring commented lines
|
|
mapfile -t domains < <(grep -oP '^\s*server_name\s+\K[^;]+' "$CONF")
|
|
|
|
sorted=($(printf "%s\n" "${domains[@]}" | sort))
|
|
|
|
# Print the sorted list for debugging
|
|
echo "Auditing servers:"
|
|
printf "%s " "${sorted[@]}"
|
|
echo ""
|
|
|
|
for i in "${!domains[@]}"; do
|
|
if [[ "${domains[$i]}" != "${sorted[$i]}" ]]; then
|
|
echo "Domain list is not sorted alphabetically."
|
|
echo "First out-of-order entry: '${domains[$i]}' (should be '${sorted[$i]}')"
|
|
exit 1
|
|
fi
|
|
done
|
|
|
|
echo "All server_name entries are sorted alphabetically."
|
|
exit 0 |