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