Mercurial > noffle
comparison debian/postinst @ 395:056d5fcb7f4b noffle
[svn] updated deb'configuration
author | godisch |
---|---|
date | Thu, 29 May 2003 15:44:56 +0100 |
parents | a23b37308063 |
children | 71801bfc07c2 |
comparison
equal
deleted
inserted
replaced
394:3d3a0dab6011 | 395:056d5fcb7f4b |
---|---|
1 #!/bin/sh | 1 #!/bin/sh |
2 # $Id: postinst 499 2003-03-29 06:57:20Z godisch $ | 2 # $Id: postinst 537 2003-05-29 14:44:56Z godisch $ |
3 | 3 |
4 set -e | 4 set -e |
5 | 5 |
6 [ "$1" = configure ] || exit 0 | 6 [ "$1" = configure ] || exit 0 |
7 | |
8 . /usr/share/debconf/confmodule | |
9 db_version 2.0 | |
10 | 7 |
11 server_config=/etc/news/noffle.conf | 8 server_config=/etc/news/noffle.conf |
12 debian_config=/etc/default/noffle | 9 debian_config=/etc/default/noffle |
13 | 10 |
14 maxfetch_default=300 | 11 maxfetch_default=300 |
33 # 1.1.2-1 was in unstable only, don't notify | 30 # 1.1.2-1 was in unstable only, don't notify |
34 mv -f /etc/noffle.conf $server_config || : | 31 mv -f /etc/noffle.conf $server_config || : |
35 mv -f /etc/noffle.conf.old $server_config.old 2> /dev/null || : | 32 mv -f /etc/noffle.conf.old $server_config.old 2> /dev/null || : |
36 fi | 33 fi |
37 | 34 |
38 db_get noffle/debconf | 35 if [ -e /usr/share/debconf/confmodule ]; then |
39 if [ "$RET" != false ]; then | 36 . /usr/share/debconf/confmodule |
40 db_get noffle/port | 37 db_version 2.0 |
41 port="$RET" | 38 db_get noffle/debconf |
42 [ -z "$port" -o "$port" = 119 ] && port=nntp || : | 39 if [ "$RET" = true ]; then |
43 # maybe disabled only, e.g. dpkg -r noffle | 40 db_get noffle/port |
44 update-inetd --remove "/usr/bin/noffle -r" || : | 41 port="$RET" |
45 update-inetd --group MAIL --add "$port\tstream\ttcp\tnowait\tnews\t/usr/sbin/tcpd /usr/bin/noffle -r" | 42 [ -z "$port" -o "$port" = 119 ] && port=nntp || : |
46 db_get noffle/server | 43 # maybe disabled only, e.g. dpkg -r noffle |
47 server="$RET" | 44 update-inetd --remove "/usr/bin/noffle -r" || : |
48 [ "$server" ] || server=news | 45 update-inetd --group MAIL --add "$port\tstream\ttcp\tnowait\tnews\t/usr/sbin/tcpd /usr/bin/noffle -r" |
49 db_get noffle/username | 46 db_get noffle/server |
50 username="$RET" | 47 server="$RET" |
51 db_get noffle/password | 48 [ "$server" ] || server=news |
52 password="$RET" | 49 db_get noffle/username |
53 db_get noffle/fetchmode | 50 username="$RET" |
54 fetchmode="$RET" | 51 db_get noffle/password |
55 [ "$fetchmode" ] || if [ -x /usr/sbin/pppd ]; then | 52 password="$RET" |
56 fetchmode=ppp | 53 db_get noffle/fetchmode |
57 else | 54 fetchmode="$RET" |
58 fetchmode=cron | 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 | |
59 fi | 89 fi |
60 db_get noffle/maxfetch | 90 db_stop |
61 maxfetch="$RET" | 91 else |
62 [ "$maxfetch" ] || maxfetch="$maxfetch_default" | 92 # no debconf available |
63 db_get noffle/default-expire | 93 if [ ! -e $server_config ]; then |
64 defexpire="$RET" | 94 umask 027 |
65 [ "$defexpire" ] || defexpire="$defexpire_default" | 95 cp -f /usr/share/noffle/noffle.conf $server_config.new |
66 # try to be idempotent | 96 chgrp news $server_config.new |
67 if [ ! -e $server_config.new -a ! -e $debian_config.new ]; then | 97 mv -fb $server_config.new $server_config |
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 | 98 fi |
74 # $server_config may contain sensitive information for NNTP authentication | 99 if [ ! -e $debian_config ]; then |
75 umask 027 | 100 umask 022 |
76 # we need to use sed instead of Perl to avoid another package dependency | 101 cp -f /usr/share/noffle/conf.debian $debian_config.new |
77 cat /usr/share/noffle/noffle.conf | \ | 102 mv -fb $debian_config.new $debian_config |
78 sed "s/^server[[:space:]].*/server $server $username $password/" | \ | 103 fi |
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 | |
89 fi | 104 fi |
90 | 105 |
91 # sanity checks | 106 # sanity checks |
92 chown -R news:news /var/lock/noffle /var/spool/noffle | 107 chown -R news:news /var/lock/noffle /var/spool/noffle |
93 chmod -R go-w /var/lock/noffle /var/spool/noffle | 108 chmod -R go-w /var/lock/noffle /var/spool/noffle |
108 echo "information how to do this." | 123 echo "information how to do this." |
109 echo "" | 124 echo "" |
110 sleep 2 | 125 sleep 2 |
111 fi | 126 fi |
112 | 127 |
113 db_stop | |
114 exit 0 | 128 exit 0 |