301
|
1 #!/bin/sh
|
324
|
2 # $Id: config 459 2003-02-22 21:54:34Z godisch $
|
301
|
3
|
|
4 set -e
|
|
5
|
|
6 server_config=/etc/news/noffle.conf
|
|
7 debian_config=/etc/default/noffle
|
|
8
|
|
9 # for backward compatibility = 1.1.2-1, since postinst is not run yet
|
|
10 if [ ! -e $server_config -a -e /etc/noffle.conf ]; then
|
|
11 server_config=/etc/noffle.conf
|
|
12 fi
|
|
13 # for backward compatibility < 1.1.2-1
|
|
14 if [ ! -e $server_config -a ! -e $debian_config -a -e /etc/noffle/conf ]; then
|
|
15 server_config=/etc/noffle/conf
|
|
16 debian_config=/etc/noffle/conf.debian
|
|
17 fi
|
|
18
|
324
|
19 . /usr/share/debconf/confmodule
|
|
20 db_version 2.0
|
|
21
|
301
|
22 # are we using debconf?
|
|
23 db_input high noffle/debconf && db_go || :
|
|
24 db_get noffle/debconf || RET=""
|
|
25 [ "$RET" = false ] && exit 0
|
|
26
|
|
27 # read server port value from inetd.conf
|
310
|
28 port="`grep '[[:space:]]/usr/bin/noffle[[:space:]]' /etc/inetd.conf | head -n 1 | sed 's/^#<off># //;s/[[:space:]].*//' 2> /dev/null`" || :
|
301
|
29 if [ "$port" ]; then
|
|
30 # read port value from debconf db
|
|
31 db_get noffle/port || RET=""
|
|
32 # for upgrading from < 1.1.2
|
|
33 [ "$RET" = 119 ] && RET=nntp
|
|
34 # we need confirmation, if they differ
|
|
35 [ "$port" = "$RET" ] || db_fset noffle/port seen false || :
|
|
36 # write current port from inetd.conf into debconf db
|
|
37 [ "$port" = "${port#\#}" ] && db_set noffle/port "$port" || :
|
|
38 fi
|
|
39
|
|
40 # read server, username, password, maxfetch, default-expire from $server_config
|
|
41 if [ -s "$server_config" ]; then
|
|
42 db_get noffle/server || RET=""
|
310
|
43 server="`grep '^server' $server_config | head -n 1 | sed 's/^server[[:space:]]*//;s/[[:space:]].*//' 2> /dev/null`" || :
|
301
|
44 [ "$server" = "$RET" ] || db_fset noffle/server seen false || :
|
|
45 [ "$server" ] && db_set noffle/server "$server" || :
|
|
46
|
|
47 db_get noffle/username || RET=""
|
310
|
48 server="`grep '^server' $server_config | head -n 1 | sed 's/^server[[:space:]]*//;s/[^[:space:]]*[[:space:]]*//;s/[[:space:]].*//' 2> /dev/null`" || :
|
301
|
49 [ "$username" = "$RET" ] || db_fset noffle/username seen false || :
|
|
50 [ "$username" ] && db_set noffle/username "$username" || :
|
|
51
|
|
52 db_get noffle/password || RET=""
|
310
|
53 server="`grep '^server' $server_config | head -n 1 | sed 's/^server[[:space:]]*//;s/[^[:space:]]*[[:space:]]*//;s/[^[:space:]]*[[:space:]]*//;s/[[:space:]].*//' 2> /dev/null`" || :
|
301
|
54 [ "$password" = "$RET" ] || db_fset noffle/password seen false || :
|
|
55 [ "$password" ] && db_set noffle/password "$password" || :
|
|
56
|
|
57 db_get noffle/maxfetch || RET=""
|
310
|
58 maxfetch="`grep '^max-fetch' $server_config | head -n 1 | sed 's/^max-fetch[[:space:]]*//' 2> /dev/null`" || :
|
301
|
59 [ "$maxfetch" = "$RET" ] || db_fset noffle/maxfetch seen false || :
|
|
60 [ "$maxfetch" ] && db_set noffle/maxfetch "$maxfetch" || :
|
|
61
|
|
62 db_get noffle/default-expire || RET=""
|
310
|
63 defexpire="`grep '^default-expire' $server_config | head -n 1 | sed 's/^default-expire[[:space:]]*//' 2> /dev/null`" || :
|
301
|
64 [ "$defexpire" = "$RET" ] || db_fset noffle/defexpire seen false || :
|
|
65 [ "$defexpire" ] && db_set noffle/default-expire "$defexpire" || :
|
|
66 fi
|
|
67
|
324
|
68 # for backward compatibility < 1.1.2-1
|
301
|
69 if dpkg --compare-versions "$2" lt-nl 1.1.2; then
|
|
70 db_get noffle/fetchmode || RET=""
|
|
71 case "$RET" in
|
|
72 'via dialup') db_set noffle/fetchmode ppp || :;;
|
|
73 'via permanent connection') db_set noffle/fetchmode cron || :;;
|
|
74 esac
|
|
75 fi
|
|
76
|
|
77 # read NOFFLE_FETCHMODE from $debian_config
|
|
78 [ -s "$debian_config" ] && . $debian_config
|
|
79 [ "$NOFFLE_FETCHMODE" != ppp -a "$NOFFLE_FETCHMODE" != cron ] && \
|
|
80 if [ -x /usr/sbin/pppd ]; then
|
|
81 NOFFLE_FETCHMODE=ppp
|
|
82 else
|
|
83 NOFFLE_FETCHMODE=cron
|
|
84 fi
|
|
85 # do we need confirmation?
|
|
86 db_get noffle/fetchmode || RET=""
|
|
87 [ "$NOFFLE_FETCHMODE" = "$RET" ] || db_fset noffle/fetchmode seen false || :
|
|
88
|
|
89 # input server port, parent server, username, password, fetchmode, maxfetch, default-expire
|
|
90 db_input low noffle/port && db_go || :
|
|
91 db_input high noffle/server && db_go || :
|
324
|
92 db_input medium noffle/username && db_go || :
|
|
93 db_input medium noffle/password && db_go || :
|
301
|
94 db_input medium noffle/fetchmode && db_go || :
|
324
|
95 db_input medium noffle/maxfetch && db_go || :
|
301
|
96 db_input low noffle/default-expire && db_go || :
|
|
97
|
|
98 exit 0
|