#!/bin/sh
#
# Copyright (c) 2005 Richard Gannon.  All Rights Reserved.
#
# Author: Rich Gannon <rich@richgannon.net>
#
# For questions, comments, and support, please visit:
# www.richgannon.net
#

MIRRORFILE="http://modsecrules.monkeydev.org/rules.php?safety=safe";
LOCALDIR="/usr/local/apache/conf";

WGET="/usr/bin/wget";
GREP="/bin/grep";

if [ -e $LOCALDIR/modsec.conf ]; then
        if [ "`$GREP modsec.dynamic.conf $LOCALDIR/modsec.conf`" = "Include \"/usr/local/apache/conf/modsec.user.conf\"" ]; then
                $WGET --output-document=$LOCALDIR/modsec.dynamic.conf $MIRRORFILE;
        else
                replace "</IfModule>" "Include \"$LOCALDIR/modsec.dynamic.conf\""$'\n'"</IfModule>" -- $LOCALDIR/modsec.conf;
                $WGET --output-document=$LOCALDIR/modsec.dynamic.conf $MIRRORFILE;
                /etc/rc.d/init.d/httpd restart;
        fi
else
        echo "Apache's mod_security NOT installed.";
fi

exit 0;

