head	1.1;
access;
symbols
	RELEASE_8_3_0:1.1
	RELEASE_9_0_0:1.1
	RELEASE_7_4_0:1.1
	RELEASE_8_2_0:1.1
	RELEASE_6_EOL:1.1
	RELEASE_8_1_0:1.1
	RELEASE_7_3_0:1.1
	RELEASE_8_0_0:1.1
	RELEASE_7_2_0:1.1
	RELEASE_7_1_0:1.1
	RELEASE_6_4_0:1.1
	RELEASE_5_EOL:1.1
	RELEASE_7_0_0:1.1
	RELEASE_6_3_0:1.1;
locks; strict;
comment	@# @;


1.1
date	2007.06.12.20.05.41;	author itetcu;	state Exp;
branches;
next	;


desc
@@


1.1
log
@- upgrade to version 1.0
- the port is no longer interactive, it uses the default blocking backend (hosts)
- for pf and ipfw see the new ports sshguard-[pf|ipfw]

PR:		ports/112749
Submitted by:	Mij (maintainer)
Reviewed by:	leeym@@
@
text
@#!/bin/sh

# If:
#   1) syslog.conf exists
#   2) it doesn't already contain some (uncommented) sshguard directive
# then add $SSHGUARDCONFLINE (commented) right at the end of the header
# comments section in syslog.conf

# real syslog.conf configuration file path
SYSLOGCONF=/etc/syslog.conf
# configuration line to add
SSHGUARDCONFLINE="auth.info;authpriv.info     |exec $PKG_PREFIX/sbin/sshguard"

case "$2" in
    "POST-INSTALL")
        if test "x$SSHGUARDFW" = xhosts
        then
            touch /etc/hosts.allow
        fi
        if (test -f "$SYSLOGCONF" && ! grep -q sshguard "$SYSLOGCONF")
        then
            # append default sshguard entry in syslog.conf (first line after comments header)
	    TMPFILE=`mktemp -q /tmp/syslogcXX`
	    # make sure our file has the same permissions as the original, since we mv it back
	    cp -p $SYSLOGCONF ${TMPFILE}
	    echo > ${TMPFILE}
            inheader=1
            cat "$SYSLOGCONF" | while read cline ;
            do
                if (test $inheader -eq 1 && !(echo "$cline" | grep -q "^[[:space:]]*#"))
                then
                    # got off of header comments
                    inheader=0
                    echo "#$SSHGUARDCONFLINE" >> $TMPFILE
                fi
                echo "$cline" >> $TMPFILE
            done
            mv $TMPFILE "$SYSLOGCONF"
        fi
;;
esac
@
