301
|
1 #!/bin/sh
|
395
|
2 # $Id: postinst 537 2003-05-29 14:44:56Z 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
|
|
15 echo ""
|
|
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."
|
|
20 echo ""
|
|
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 || :
|
|
26 rmdir /etc/noffle || :
|
|
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"
|
|
42 [ -z "$port" -o "$port" = 119 ] && port=nntp || :
|
|
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"
|
|
46 db_get noffle/server
|
|
47 server="$RET"
|
|
48 [ "$server" ] || server=news
|
|
49 db_get noffle/username
|
|
50 username="$RET"
|
|
51 db_get noffle/password
|
|
52 password="$RET"
|
|
53 db_get noffle/fetchmode
|
|
54 fetchmode="$RET"
|
|
55 [ "$fetchmode" ] || if [ -x /usr/sbin/pppd ]; then
|
|
56 fetchmode=ppp
|
|
57 else
|
|
58 fetchmode=cron
|
|
59 fi
|
|
60 db_get noffle/maxfetch
|
|
61 maxfetch="$RET"
|
|
62 [ "$maxfetch" ] || maxfetch="$maxfetch_default"
|
|
63 db_get noffle/default-expire
|
|
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 || :
|
|
73 fi
|
|
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
|
301
|
89 fi
|
395
|
90 db_stop
|
|
91 else
|
|
92 # no debconf available
|
|
93 if [ ! -e $server_config ]; then
|
|
94 umask 027
|
|
95 cp -f /usr/share/noffle/noffle.conf $server_config.new
|
|
96 chgrp news $server_config.new
|
|
97 mv -fb $server_config.new $server_config
|
301
|
98 fi
|
395
|
99 if [ ! -e $debian_config ]; then
|
|
100 umask 022
|
|
101 cp -f /usr/share/noffle/conf.debian $debian_config.new
|
|
102 mv -fb $debian_config.new $debian_config
|
|
103 fi
|
324
|
104 fi
|
301
|
105
|
324
|
106 # sanity checks
|
|
107 chown -R news:news /var/lock/noffle /var/spool/noffle
|
|
108 chmod -R go-w /var/lock/noffle /var/spool/noffle
|
|
109 find /var/lock/noffle /var/spool/noffle -type d -print0 | xargs -0 chmod g+s
|
|
110
|
|
111 # init.d startup
|
|
112 update-rc.d noffle defaults > /dev/null
|
|
113 if [ -x /usr/sbin/invoke-rc.d ]; then
|
|
114 invoke-rc.d noffle start
|
|
115 elif [ -x /etc/init.d/noffle ]; then
|
|
116 /etc/init.d/noffle start
|
|
117 fi
|
|
118
|
|
119 if [ -z "$2" ]; then
|
|
120 echo ""
|
|
121 echo "You need to query your parent NNTP server manually for a group overview"
|
|
122 echo "and descriptions. Have a look at /usr/share/doc/noffle/README.Debian for"
|
|
123 echo "information how to do this."
|
|
124 echo ""
|
|
125 sleep 2
|
301
|
126 fi
|
|
127
|
|
128 exit 0
|