#! /bin/sh

delnewsyslog() {
    tmp="/etc/#munin-node$$"
    sed -e '/^\/var\/log\/munin\/munin-node.log[ 	]/d' /etc/newsyslog.conf >${tmp}
    cat ${tmp} > /etc/newsyslog.conf
    rm ${tmp}
}

newsyslog() {
    ENTRY=`grep /var/log/munin/munin-node.log /etc/newsyslog.conf`
    DEFAULT='/var/log/munin/munin-node.log			644  7	   *	@T00  Z	/var/run/munin/munin-node.pid'
    if [ -z "$ENTRY" ]; then
	exit 0
    elif [ "$ENTRY" = "$DEFAULT" ]; then
	delnewsyslog
    else
    echo "You have changed the default munin-node entry in \"/etc/newsyslog.conf\"".
    echo "If you deinstall munin-node permanently, you have to manually remove it"
    fi
}


case $2 in
    DEINSTALL)
	if [ -z "${PACKAGE_BUILDING}" ]; then
		newsyslog
	fi
	;;
    POST-DEINSTALL)
	;;
esac
