annotate debian/postinst @ 302:4f4c233374ca noffle

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