view debian/postinst @ 390:2ad4c1c97734 noffle

[svn] * src/client.c: Return correct status from Client_postArt() and add function comment detailing what return code should be, because it's not obvious that the return code should report success when the posting failed for reasons other than connection problems. This should fix problem with failing posting stopping fetches. Thanks to Dan Jacobson for spotting this. * src/client.c: Fix problemette with filter discards not updating remote group article count and so the overview being refetched until and article appears that doesn't fall foul of the filter and thus does update the remove group 'next article' marker. Thanks to Dan Jacobson for spotting this. * src/content.c: Don't be fooled into thinking a filename starting ".." is just "..". * src/outgoing.c: Don't assume "." and ".." are the first files returned from readdir(). Thanks to Andreas Happe for spotting this. * src/noffle.c: Update online help to include 'm' group posting status. * src/server.c: Move incorrect updating of server.grp in doGrp() which was causing doGrp() to not retrieve remote article details when in online mode. Thanks to Miernik and Andreas Happe for reporting the problem.
author bears
date Thu, 22 May 2003 10:04:38 +0100
parents a23b37308063
children 056d5fcb7f4b
line wrap: on
line source

#!/bin/sh
# $Id: postinst 499 2003-03-29 06:57:20Z godisch $

set -e

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

. /usr/share/debconf/confmodule
db_version 2.0

server_config=/etc/news/noffle.conf
debian_config=/etc/default/noffle

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 $server_config, /etc/noffle/conf.debian"
	echo "moved to $debian_config. /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 $server_config || :
	mv -f /etc/noffle/conf.debian $debian_config || :
	mv -f /etc/noffle/conf.old $server_config.old 2> /dev/null || :
	mv -f /etc/noffle/conf.debian.old $debian_config.old 2> /dev/null || :
	rmdir /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 $server_config || :
	mv -f /etc/noffle.conf.old $server_config.old 2> /dev/null || :
fi

db_get noffle/debconf
if [ "$RET" != false ]; then
	db_get noffle/port
	port="$RET"
	[ -z "$port" -o "$port" = 119 ] && port=nntp || :
	# maybe disabled only, e.g. dpkg -r noffle
	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"
	# try to be idempotent
	if [ ! -e $server_config.new -a ! -e $debian_config.new ]; then
		# make some backup files
		cmp -s $server_config $server_config.old || \
			cp -pf $server_config $server_config.old 2> /dev/null || :
		cmp -s $debian_config $debian_config.old || \
			cp -pf $debian_config $debian_config.old 2> /dev/null || :
	fi
	# $server_config may contain sensitive information for NNTP authentication
	umask 027
	# we need to use sed instead of Perl to avoid another package dependency
	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/" \
		> $server_config.new
	chgrp news $server_config.new
	umask 022
	cat /usr/share/noffle/conf.debian | \
		sed "s/^NOFFLE_FETCHMODE=.*/NOFFLE_FETCHMODE=$fetchmode/" \
		> $debian_config.new
	mv -f $server_config.new $server_config
	mv -f $debian_config.new $debian_config
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

db_stop
exit 0