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