301
|
1 #!/bin/sh
|
|
2 # $Id: postinst 434 2003-02-14 13:54:32Z godisch $
|
|
3
|
|
4 set -e
|
|
5 . /usr/share/debconf/confmodule
|
|
6 db_version 2.0
|
|
7
|
|
8 server_config=/etc/news/noffle.conf
|
|
9 debian_config=/etc/default/noffle
|
|
10
|
|
11 maxfetch_default=300
|
|
12 defexpire_default=14
|
|
13
|
|
14 case "$1" in
|
|
15 configure)
|
|
16 if dpkg --compare-versions "$2" lt-nl 1.1.2-1; then
|
|
17 echo ""
|
|
18 echo "/etc/noffle/conf moved to $server_config, /etc/noffle/conf.debian"
|
|
19 echo "moved to $debian_config. /etc/noffle and /var/log/noffle are not"
|
|
20 echo "used any longer, you may remove them. noffle expiration logs are"
|
|
21 echo "still available through syslog."
|
|
22 echo ""
|
|
23 sleep 2
|
|
24 mv -f /etc/noffle/conf $server_config || :
|
|
25 mv -f /etc/noffle/conf.debian $debian_config || :
|
|
26 mv -f /etc/noffle/conf.old $server_config.old 2> /dev/null || :
|
|
27 mv -f /etc/noffle/conf.debian.old $debian_config.old 2> /dev/null || :
|
|
28 rmdir /etc/noffle || :
|
|
29 fi
|
|
30 if dpkg --compare-versions "$2" eq 1.1.2-1; then
|
|
31 # 1.1.2-1 was in unstable only, don't notify
|
|
32 mv -f /etc/noffle.conf $server_config || :
|
|
33 mv -f /etc/noffle.conf.old $server_config.old 2> /dev/null || :
|
|
34 fi
|
|
35 # if we are allowed to overwrite $server_config and $debian_config...
|
|
36 db_get noffle/debconf || RET=""
|
|
37 if [ "$RET" != false ]; then
|
|
38 db_get noffle/port || RET=""
|
|
39 port="$RET"
|
|
40 [ -z "$port" -o "$port" = 119 ] && port=nntp
|
|
41 # maybe disabled only, e.g. dpkg -r noffle
|
|
42 update-inetd --remove "/usr/bin/noffle -r" || :
|
|
43 update-inetd --group MAIL --add "$port\tstream\ttcp\tnowait\tnews\t/usr/sbin/tcpd /usr/bin/noffle -r"
|
|
44 db_get noffle/server || RET=""
|
|
45 server="$RET"
|
|
46 [ "$server" ] || server=news
|
|
47 db_get noffle/username || RET=""
|
|
48 username="$RET"
|
|
49 db_get noffle/password || RET=""
|
|
50 password="$RET"
|
|
51 db_get noffle/fetchmode || RET=""
|
|
52 fetchmode="$RET"
|
|
53 [ "$fetchmode" ] || if [ -x /usr/sbin/pppd ]; then
|
|
54 fetchmode=ppp
|
|
55 else
|
|
56 fetchmode=cron
|
|
57 fi
|
|
58 db_get noffle/maxfetch || RET=""
|
|
59 maxfetch="$RET"
|
|
60 [ "$maxfetch" ] || maxfetch="$maxfetch_default"
|
|
61 db_get noffle/default-expire || RET=""
|
|
62 defexpire="$RET"
|
|
63 [ "$defexpire" ] || defexpire="$defexpire_default"
|
|
64 # try to be idempotent
|
|
65 if [ ! -e $server_config.new -a ! -e $debian_config.new ]; then
|
|
66 # make some backup files
|
|
67 cmp -s $server_config $server_config.old || \
|
|
68 cp -pf $server_config $server_config.old 2> /dev/null || :
|
|
69 cmp -s $debian_config $debian_config.old || \
|
|
70 cp -pf $debian_config $debian_config.old 2> /dev/null || :
|
|
71 fi
|
|
72 # $server_config may contain sensitive information for NNTP authentication
|
|
73 umask 027
|
|
74 # we need to use sed instead of Perl to avoid another package dependency
|
|
75 cat /usr/share/noffle/noffle.conf | \
|
|
76 sed "s/^server[[:space:]].*/server $server $username $password/" | \
|
|
77 sed "s/^max-fetch[[:space:]].*/max-fetch $maxfetch/" | \
|
|
78 sed "s/^default-expire[[:space:]].*/default-expire $defexpire/" \
|
|
79 > $server_config.new
|
|
80 chgrp news $server_config.new
|
|
81 umask 022
|
|
82 cat /usr/share/noffle/conf.debian | \
|
|
83 sed "s/^NOFFLE_FETCHMODE=.*/NOFFLE_FETCHMODE=$fetchmode/" \
|
|
84 > $debian_config.new
|
|
85 mv -f $server_config.new $server_config
|
|
86 mv -f $debian_config.new $debian_config
|
|
87 fi
|
|
88 # sanity checks
|
|
89 chown -R news:news /var/lock/noffle /var/spool/noffle
|
|
90 chmod -R go-w /var/lock/noffle /var/spool/noffle
|
|
91 find /var/lock/noffle /var/spool/noffle -type d -print0 | xargs -0 chmod g+s
|
|
92 if [ -z "$2" ]; then
|
|
93 echo ""
|
|
94 echo "You need to query your parent NNTP server manually for a group overview"
|
|
95 echo "and descriptions. Have a look at /usr/share/doc/noffle/README.Debian for"
|
|
96 echo "information how to do this."
|
|
97 echo ""
|
|
98 sleep 2
|
|
99 fi
|
|
100 ;;
|
|
101 abort-upgrade|abort-remove|abort-deconfigure)
|
|
102 ;;
|
|
103 *)
|
|
104 echo "postinst called with unknown argument '$1'" >&2
|
|
105 exit 1
|
|
106 ;;
|
|
107 esac
|
|
108
|
|
109 if [ -x /etc/init.d/noffle ]; then
|
|
110 update-rc.d noffle defaults > /dev/null
|
|
111 invoke-rc.d noffle start || :
|
|
112 fi
|
|
113
|
|
114 exit 0
|