annotate debian/config @ 359:d1007cf6a49c noffle

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