annotate debian/postinst @ 395:056d5fcb7f4b noffle

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