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