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