Skip to content

Instantly share code, notes, and snippets.

@tkuchiki
Last active August 29, 2015 14:21
Show Gist options
  • Save tkuchiki/1ed58181127c8107b0b0 to your computer and use it in GitHub Desktop.
Save tkuchiki/1ed58181127c8107b0b0 to your computer and use it in GitHub Desktop.
apache の Directory ディレクティブの重複しているパスを出力する
grep -h -r '<Directory' /path/to/httpd/vhost/conf/dir | sed -e 's/"//g' | sed -e 's/<Directory \(.*\)>/\1/' | sed -e 's/ *//g' | sed -e 's/\/$//' | sort | uniq -c | awk 'BEGIN { status=0 } { if ($1 > 1) { print $2; status=1} } END { exit status }'
configtest)
$apachectl -t
DIR_PATHS=$(grep -h -r '<Directory' /path/to/httpd/vhost/conf/dir | sed -e 's/"//g' | sed -e 's/<Directory \(.*\)>/\1/' | sed -e 's/ *//g' | sed -e 's/\/$//' | sort | uniq -c | awk 'BEGIN { status=0 } { if ($1 > 1) { print $2; status=1} } END { exit status }')
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
echo "Duplicate Directory directive"
echo && echo $DIR_PATHS
fi
;;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment