view debian/postinst @ 425:c2fd00030991 noffle

[svn] added preliminary ucf support
author godisch
date Fri, 20 Jun 2003 17:48:28 +0100
parents e5bd838e0c27
children 011e51924b23
line wrap: on
line source

#!/bin/sh
# $Id: postinst 568 2003-06-20 16:48:28Z godisch $

set -e

[ "$1" = configure ] || exit 0

maxfetch_default=300
defexpire_default=14

if dpkg --compare-versions "$2" lt-nl 1.1.2-1; then
	echo
	echo "/etc/noffle/conf moved to /etc/news/noffle.conf, /etc/noffle/conf.debian"
	echo "moved to /etc/default/noffle. /etc/noffle and /var/log/noffle are not"
	echo "used any longer, you may remove them. noffle expiration logs are"
	echo "still available through syslog."
	echo
	sleep 2
	mv -f /etc/noffle/conf /etc/news/noffle.conf || :
	mv -f /etc/noffle/conf.debian /etc/default/noffle || :
	mv -f /etc/noffle/conf.old /etc/news/noffle.conf.old 2> /dev/null || :
	mv -f /etc/noffle/conf.debian.old /etc/default/noffle.old 2> /dev/null || :
	rmdir --ignore-fail-on-non-empty /etc/noffle
fi

if dpkg --compare-versions "$2" eq 1.1.2-1; then
	# 1.1.2-1 was in unstable only, don't notify
	mv -f /etc/noffle.conf /etc/news/noffle.conf || :
	mv -f /etc/noffle.conf.old /etc/news/noffle.conf.old 2> /dev/null || :
fi

if [ -e /usr/share/debconf/confmodule ]; then
	. /usr/share/debconf/confmodule
	db_version 2.0

	db_get noffle/port
	port="$RET"
	if [ -z "$port" -o "$port" = 119 ]; then
		port=nntp
	fi
	update-inetd --remove "/usr/bin/noffle -r" || :
	update-inetd --group MAIL --add "$port\tstream\ttcp\tnowait\tnews\t/usr/sbin/tcpd /usr/bin/noffle -r"

	db_get noffle/server
	server="$RET"
	[ "$server" ] || server=news
	db_get noffle/username
	username="$RET"
	db_get noffle/password
	password="$RET"
	db_get noffle/fetchmode
	fetchmode="$RET"
	[ "$fetchmode" ] || if [ -x /usr/sbin/pppd ]; then
		fetchmode=ppp
	else
		fetchmode=cron
	fi
	db_get noffle/maxfetch
	maxfetch="$RET"
	[ "$maxfetch" ] || maxfetch="$maxfetch_default"
	db_get noffle/default-expire
	defexpire="$RET"
	[ "$defexpire" ] || defexpire="$defexpire_default"

	# /etc/news/noffle.conf may contain sensitive information for NNTP authentication
	umask 027
	cat /usr/share/noffle/noffle.conf | \
		sed "s/^server[[:space:]].*/server $server $username $password/" | \
		sed "s/^max-fetch[[:space:]].*/max-fetch $maxfetch/" | \
		sed "s/^default-expire[[:space:]].*/default-expire $defexpire/" \
		> /etc/news/noffle.conf.new
	chgrp news /etc/news/noffle.conf.new
	ucf --three-way /etc/news/noffle.conf.new /etc/news/noffle.conf < /dev/tty
	rm -f /etc/news/noffle.conf.new

	umask 022
	cat /usr/share/noffle/conf.debian | \
		sed "s/^NOFFLE_FETCHMODE=.*/NOFFLE_FETCHMODE=$fetchmode/" \
		> /etc/default/noffle.new
	ucf --three-way /etc/default/noffle.new /etc/default/noffle < /dev/tty
	rm -f /etc/default/noffle.new

	db_stop
else
	# no debconf available
	ucf --three-way /usr/share/noffle/noffle.conf /etc/news/noffle.conf < /dev/tty
	ucf --three-way /usr/share/noffle/conf.debian /etc/default/noffle < /dev/tty
	if ! grep -q "/usr/bin/noffle -r" /etc/inetd.conf; then
		# just an example, the user needs to activate it himself
		# update-inetd will silently fail if nntp is already occupied
		update-inetd --group MAIL --add "nntp\tstream\ttcp\tnowait\tnews\t/usr/sbin/tcpd /usr/bin/noffle -r"
		if grep -q "^nntp.*/usr/bin/noffle -r"; then
			update-inetd --disable nntp
		fi
		echo
		echo "You need to active noffle manually in /etc/inetd.conf."
		echo
		sleep 2
	fi
fi

# sanity checks
chown -R news:news /var/lock/noffle /var/spool/noffle
chmod -R go-w      /var/lock/noffle /var/spool/noffle
find /var/lock/noffle /var/spool/noffle -type d -print0 | xargs -0 chmod g+s

# init.d startup
update-rc.d noffle defaults > /dev/null
if [ -x /usr/sbin/invoke-rc.d ]; then
	invoke-rc.d noffle start
elif [ -x /etc/init.d/noffle ]; then
	/etc/init.d/noffle start
fi

if [ -z "$2" ]; then
	echo
	echo "You need to query your parent NNTP server manually for a group overview"
	echo "and descriptions. Have a look at /usr/share/doc/noffle/README.Debian for"
	echo "information how to do this."
	echo
	sleep 2
fi

exit 0