Mercurial > noffle
diff debian/postinst @ 395:056d5fcb7f4b noffle
[svn] updated deb'configuration
author | godisch |
---|---|
date | Thu, 29 May 2003 15:44:56 +0100 |
parents | a23b37308063 |
children | 71801bfc07c2 |
line wrap: on
line diff
--- a/debian/postinst Sat May 24 19:48:30 2003 +0100 +++ b/debian/postinst Thu May 29 15:44:56 2003 +0100 @@ -1,13 +1,10 @@ #!/bin/sh -# $Id: postinst 499 2003-03-29 06:57:20Z godisch $ +# $Id: postinst 537 2003-05-29 14:44:56Z 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 @@ -35,57 +32,75 @@ 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 +if [ -e /usr/share/debconf/confmodule ]; then + . /usr/share/debconf/confmodule + db_version 2.0 + db_get noffle/debconf + if [ "$RET" = true ]; 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 - 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 || : + db_stop +else + # no debconf available + if [ ! -e $server_config ]; then + umask 027 + cp -f /usr/share/noffle/noffle.conf $server_config.new + chgrp news $server_config.new + mv -fb $server_config.new $server_config 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 + if [ ! -e $debian_config ]; then + umask 022 + cp -f /usr/share/noffle/conf.debian $debian_config.new + mv -fb $debian_config.new $debian_config + fi fi # sanity checks @@ -110,5 +125,4 @@ sleep 2 fi -db_stop exit 0