#! /bin/sh

set -e

if [ -z "`ls /dev/xconsole 2> /dev/null`" ]; then
  mknod -m 644 /dev/xconsole p
fi

if [ ! -d /var/log/news \
       -a `grep '^news:' /etc/passwd |wc -l` -gt 0 \
       -a `grep '^news:' /etc/group |wc -l` -gt 0 ]; then
    mkdir /var/log/news
    chmod 2755 /var/log/news
    chown news.news /var/log/news
fi

if [ "$1" = "upgrade" ]
then
    case $2 in
	1.2-*)
cat<<EOT
The default behaviour of syslogd has altered from 1.2 to 1.3.  By default
*no* messages from the UDP port are accepted.

Read the documentation in /usr/doc/sysklogd carefully.  Some important
things have been changed!

Press [Enter] to continue
EOT
	read xyz
	;;
  esac
fi

if [ "$1" = "configure" ]
then
    test -f /etc/init.d/sysklogd && sh /etc/init.d/sysklogd stop

    update-rc.d sysklogd defaults 10 90 >/dev/null

    if `grep -q /var/log/auth.log /etc/syslog.conf` ; then
	if [ ! -f /var/log/auth.log ]; then
	    touch /var/log/auth.log
	    chown root.adm /var/log/auth.log
	    chmod o-rwx /var/log/auth.log
	fi
    fi

    # Tidying up some old stuff
    #
    rm -f /etc/rc?.d/[SK]*.syslogd

    # restarting daemon
    #
    if [ -x /etc/init.d/sysklogd ]; then
	  /etc/init.d/sysklogd start
    fi
fi

exit 0
