301
|
1 #!/bin/sh
|
362
|
2 # $Id: config 501 2003-03-29 07:14: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
|
362
|
97 0)
|
|
98 db_input high noffle/debconf || :
|
|
99 ;;
|
359
|
100 1)
|
362
|
101 db_input low noffle/port || :
|
361
|
102 ;;
|
|
103 2)
|
359
|
104 db_input high noffle/server || :
|
|
105 ;;
|
362
|
106 3)
|
359
|
107 db_input medium noffle/username || :
|
|
108 ;;
|
362
|
109 4)
|
359
|
110 db_get noffle/username
|
|
111 if [ "$RET" ]; then
|
|
112 db_input medium noffle/password || :
|
|
113 fi
|
|
114 ;;
|
362
|
115 5)
|
|
116 db_input medium noffle/fetchmode || :
|
|
117 ;;
|
361
|
118 6)
|
362
|
119 db_input medium noffle/maxfetch || :
|
359
|
120 ;;
|
361
|
121 7)
|
359
|
122 db_input low noffle/default-expire || :
|
|
123 ;;
|
|
124 esac
|
|
125 if db_go; then
|
362
|
126 if [ "$state" -eq 0 ]; then
|
361
|
127 db_get noffle/debconf
|
362
|
128 [ "$RET" = true ] || break
|
361
|
129 fi
|
359
|
130 state=$(($state + 1))
|
|
131 else
|
|
132 state=$(($state - 1))
|
|
133 fi
|
|
134 done
|
301
|
135
|
333
|
136 db_stop
|
301
|
137 exit 0
|