#!/bin/sh
#
# This script is called when ppp connects to the network.
# Slrn uses it for refreshing newsgroup descriptions
#
# Use dpkg --reconfigure slrn to configure whether this is used.
#
# Written By Joey Hess <joeyh@debian.org>

# First, test to see if the description file is a week old.
# I put this test here so I don't always use debconf, to save some CPU.
if [ ! -e /var/lib/slrn/newsgroups.dsc \
     -o "`find /var/lib/slrn/newsgroups.dsc -mtime +6 2>/dev/null`" ]
then
	DEBIAN_FRONTEND=noninteractive
	export DEBIAN_FRONTEND

	# Use debconf.
	. /usr/share/debconf/confmodule
	db_get slrn/getdescs
	if [ "$RET" = "ip-up" ]; then
		# If term is not set to something sane, slrn gets upset.
		TERM=vt100
		export TERM

		# Make sure the umask is sane as well.
		umask 022

		# Do it.
		/usr/sbin/slrn_getdescs & >/dev/null
	fi
fi
