Re: use and abuse of debconf
Joey Hess <joeyh@debian.org> writes:
[...]
>
> Each time the package is upgraded or dpkg-reconfigured, /etc/foo is
> wiped out. Any changes the admin may have made are destroyed.
>
> Now an example of a package that does it right. Its config script:
>
> #!/bin/sh -e
> . /usr/share/debconf/confmodule
> if [ -e /etc/foo ]; then
> . /etc/foo || true
> if [ "$QUESTION" ]; then
> db_set foo/question $QUESTION
> fi
> fi
> db_input medium foo/question || true
> db_go || true
For multiple variables I'm using the following:
if [ -e /etc/iptables/init.cfg ]; then
# Read current state from configuration file
. /etc/iptables/init.cfg || true
for token in BACKDOOR ICMPDIAG IFOUT DMZ IPOUT LOCALIFS LOCALNET LOGNETBIOS MODENAME PASSOUT REJECTLOCAL SERVICES SERVICES_UNCOMMON; do
tokvar=`echo '$'$token`
tokval=`eval echo $tokvar`
if [ "$tokval" ]; then
db_set iptables/`echo $token | tr [A-Z] [a-z]` $tokval
fi
done
fi
Any comments ?
Bye
Racke
--
LinuXia Systems && Cobolt NetServices, eCommerce and more
Shop- und Datenbanklösungen mit MiniVend, Firewalls auf Debian-Basis
http://www.linuxia.de - http://www.cobolt.net
--> Junior Officer of the MiniVend/Interchange Bug Patrol <---
Reply to: