comparison debian/postinst @ 324:5ec39beae9c5 noffle

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