annotate debian/postinst @ 360:a23b37308063 noffle

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