#!/bin/sh -e init_inn_files() { PATHDB=$(/usr/lib/news/bin/innconfval pathdb) if [ -z "$PATHDB" ]; then echo "Cannot determine the database path, aborting." exit 1 fi cd $PATHDB local package='inn2' if [ -e /usr/share/doc/inn2-lfs/ ]; then package='inn2-lfs' fi for file in active newsgroups; do if [ ! -f $file ]; then echo "Installing initial content for $PATHDB/$file" install -m 644 -o news -g news \ /usr/share/doc/$package/examples/$file . fi done if [ ! -f history.dir ]; then echo -n "Building history database in $PATHDB... " if ! /usr/lib/news/bin/makehistory; then echo "failed!" return fi if ! /usr/lib/news/bin/makedbz -i -o -s 300000; then echo "failed!" return fi chown news:news history* chmod 664 history* echo "done." fi if [ ! -f active.times ]; then touch active.times chown news:news active.times chmod 644 active.times fi # squelch initial noise in email if this isn't present if [ ! -f .news.daily ]; then touch .news.daily chown news:news .news.daily fi # make sure typical log files exist, and can be rotated if [ ! -d /var/log/news ]; then install -d -m 775 -o news -g news /var/log/news fi cd /var/log/news [ -f news.notice ] || touch news.crit news.err news.notice chown news:news . OLD path news.crit news.err news.notice if [ -x /etc/init.d/inn2 ]; then update-rc.d inn2 defaults > /dev/null fi } check_usenet_alias() { # must have an alias for user usenet, point it to root by default if [ -f /etc/aliases ] && ! grep -q '^usenet:' /etc/aliases \ && ! getent passwd usenet; then echo "Adding alias for pseudo-user usenet to /etc/aliases." echo "usenet: root" >> /etc/aliases [ -x /usr/bin/newaliases ] && /usr/bin/newaliases fi } upgrade_inn_conf() { cd /etc/news if [ "$2" ] && dpkg --compare-versions "$2" lt "2.3.999+20030125-1"; then /usr/lib/news/bin/innupgrade -f inn.conf fi } rebuild_history_index() { [ -f /var/lib/news/must-rebuild-history-index ] || return 0 cd /var/lib/news HLINES=$(tail -1 history.dir | awk '{ print $1 }') [ "$HLINES" ] || HLINES=1000000 echo "Rebuilding the history index for $HLINES lines, please wait..." rm history.hash history.index history.dir su news -c "/usr/lib/news/bin/makedbz -s $HLINES -f history" rm /var/lib/news/must-rebuild-history-index } rebuild_overview() { [ -f /var/lib/news/must-rebuild-overview ] || return 0 OVENABLED=$(/usr/lib/news/bin/innconfval enableoverview) if [ -z "$OVENABLED" ]; then echo "Cannot determine the overview method used, stopping." exit 1 fi if [ $OVENABLED = no -o $OVENABLED = false ]; then return 0 fi OVMETHOD=$(/usr/lib/news/bin/innconfval ovmethod) if [ -z "$OVMETHOD" ]; then echo "Cannot determine the overview method used, stopping." exit 1 elif [ $OVMETHOD = tradindexed -o $OVMETHOD = ovdb ]; then OVPATH=$(/usr/lib/news/bin/innconfval pathoverview) if [ -z "$OVPATH" ]; then echo "Cannot determine the overview path, aborting." exit 1 fi echo "Deleting the old overview database, please wait..." find $OVPATH -type f -not -name DB_CONFIG -print0 | xargs -0 -r rm -f elif [ $OVMETHOD = buffindexed ]; then echo "Deleting the old overview database, please wait..." awk -F : '/^[0-9]/ { print $2 }' < /etc/news/buffindexed.conf | \ while read name size; do dd if=/dev/zero of="$name" bs=1024 count="$size" done else echo "Unknown overview method '$OVMETHOD', aborting." exit 1 fi echo "Rebuilding the overview database, please wait..." su news -c "/usr/lib/news/bin/makehistory -F -O -x" rm /var/lib/news/must-rebuild-overview } start_innd() { # make sure we can determine the FQDN, since innd won't launch if we can't if hostname --fqdn > /dev/null 2>&1; then invoke-rc.d inn2 start || echo "Could not start INN!" else cat < /dev/null || true ctlinnd -t 20 xexec inndstart > /dev/null \ || echo "Could not restart INN!" fi ;; abort-upgrade|abort-remove|abort-deconfigure) ;; *) echo "postinst called with unknown argument '$1'" >&2 ;; esac #DEBHELPER# exit 0