From: Russ Allbery Date: Fri, 13 Feb 2009 02:02:30 +0000 (-0800) Subject: General improvements to debconf configuration handling X-Git-Tag: debian/1.4.8.dfsg1-1~12 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=2dd14260dabd285a7cc26179386709a78ee20ce1;p=packages%2Fo%2Fopenafs.git General improvements to debconf configuration handling * General improvements to debconf configuration handling. - Do not abort the config script if we have no default realm and dnsdomainname fails. (LP: #274886, #318132) - Do not abort postinst if we can't resolve any host name for the cell. Just continue in that case, omitting any configuration for the local cell. (LP: #322054) - Correctly set the default for AFS_CRYPT from the existing config. - The cache size is high, not critical, since we have a default. - Don't create the client ThisCell if no local cell was specified. - Improve the leading comment in afs.conf.client. Users can edit it, but any changes other than the setting values will be lost. - Remove the openafs-fileserver/bosconfig_moved template, which would only be shown on upgrades from pre-1.2.0 versions. - Standardize coding style and always quote strings. --- diff --git a/debian/changelog b/debian/changelog index 8b17f710d..efde5d0c9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -36,6 +36,20 @@ openafs (1.4.8.dfsg1-1) UNRELEASED; urgency=low Kaseorg and Lutz Goehring for suggestions. (LP: #295897) * Allow time-daemon to satisfy the openafs-fileserver recommends in addition to ntp, allowing for openntpd. (Closes: #508258) + * General improvements to debconf configuration handling. + - Do not abort the config script if we have no default realm and + dnsdomainname fails. (LP: #274886, #318132) + - Do not abort postinst if we can't resolve any host name for the + cell. Just continue in that case, omitting any configuration for + the local cell. (LP: #322054) + - Correctly set the default for AFS_CRYPT from the existing config. + - The cache size is high, not critical, since we have a default. + - Don't create the client ThisCell if no local cell was specified. + - Improve the leading comment in afs.conf.client. Users can edit it, + but any changes other than the setting values will be lost. + - Remove the openafs-fileserver/bosconfig_moved template, which would + only be shown on upgrades from pre-1.2.0 versions. + - Standardize coding style and always quote strings. * Update to debhelper compatibility level V7. - Use dh where possible in debian/rules. - Use dh_lintian to install Lintian overrides. diff --git a/debian/openafs-client.config b/debian/openafs-client.config index 759bbb2f0..c5db27e7c 100644 --- a/debian/openafs-client.config +++ b/debian/openafs-client.config @@ -4,40 +4,55 @@ set -e . /usr/share/debconf/confmodule db_version 2.0 + +# Configure the client cell. Default to the current ThisCell file and, +# failing that, the lowercased local domain name, if available. Ignore errors +# on read, since it may fail if there's no newline in the file. if [ -r /etc/openafs/ThisCell ] ; then - read cell /dev/null || true` + if [ -n "$domain" ] ; then + db_set openafs-client/thiscell `echo "$domain" | tr 'A-Z' 'a-z'` fi -db_input high openafs-client/thiscell ||true -db_input critical openafs-client/cachesize ||true +fi +db_input high openafs-client/thiscell || true + +# Configure the cache size. Default to the current value in the cacheinfo +# configuration file. +if [ -r /etc/openafs/cacheinfo ] ; then + IFS=: read mountpoint cachedir cachesize < /etc/openafs/cacheinfo + db_set openafs-client/cachesize "$cachesize" +fi +db_input high openafs-client/cachesize || true db_go -test -f /etc/openafs/afs.conf &&. /etc/openafs/afs.conf + +# Configure the AFS client parameters set in /etc/openafs/afs.conf, taking +# defaults from the current file. +test -f /etc/openafs/afs.conf && . /etc/openafs/afs.conf if [ "x$AFS_CLIENT" != "x" ] ; then - db_set openafs-client/run-client $AFS_CLIENT - fi + db_set openafs-client/run-client "$AFS_CLIENT" +fi db_input low openafs-client/run-client || true -if [ "x$AFS_AFSDB" != "x" ] ;then - db_set openafs-client/afsdb $AFS_AFSDB - fi +if [ "x$AFS_AFSDB" != "x" ] ; then + db_set openafs-client/afsdb "$AFS_AFSDB" +fi +if [ "x$AFS_CRYPT" != "x" ] ; then + db_set openafs-client/crypt "$AFS_CRYPT" +fi if [ "x$AFS_DYNROOT" != "x" ] ; then - db_set openafs-client/dynroot $AFS_DYNROOT - fi -if [ x$AFS_FAKESTAT != "x" ] ; then - db_set openafs-client/fakestat $AFS_FAKESTAT + db_set openafs-client/dynroot "$AFS_DYNROOT" +fi +if [ "x$AFS_FAKESTAT" != "x" ] ; then + db_set openafs-client/fakestat "$AFS_FAKESTAT" fi - db_beginblock -db_input low openafs-client/afsdb ||true +db_input low openafs-client/afsdb || true db_input low openafs-client/crypt || true db_input medium openafs-client/dynroot || true -db_input low openafs-client/fakestat ||true +db_input low openafs-client/fakestat || true db_endblock db_go diff --git a/debian/openafs-client.postinst b/debian/openafs-client.postinst index b83816486..ca3fdf4e5 100644 --- a/debian/openafs-client.postinst +++ b/debian/openafs-client.postinst @@ -18,21 +18,20 @@ if [ "$1" = configure ] || [ "$1" = reconfigure ] ; then db_version 2.0 db_get openafs-client/thiscell - echo $RET >/etc/openafs/ThisCell - THISCELL=$RET + THISCELL="$RET" + if [ -n "$THISCELL" ] ; then + echo "$THISCELL" > /etc/openafs/ThisCell + fi - if test -f /etc/openafs/CellServDB ; then - : - else + if [ ! -f /etc/openafs/CellServDB ] ; then cp /usr/share/openafs/CellServDB /etc/openafs fi # If ThisCell is not in CellServDB, we have to prompt the user for the # VLDB servers. Unfortunately, we can't do this in config because we - # need the CellServDB file, which is part of the package. We have to - # override a lintian warning for this since prompts at installation time - # are frowned upon. - if grep -q -F "$RET" /etc/openafs/CellServDB && [ "x$RET" != "x" ] ; then + # need the CellServDB file, which is part of the package. + if grep -q -F "$THISCELL" /etc/openafs/CellServDB \ + && [ "x$THISCELL" != "x" ] ; then : else db_input critical openafs-client/cell-info || true @@ -40,7 +39,7 @@ if [ "$1" = configure ] || [ "$1" = reconfigure ] ; then db_go db_get openafs-client/cell-info if [ "x$RET" != "x" ] ; then - echo \>$THISCELL > /etc/openafs/CellServDB.new + echo ">$THISCELL" > /etc/openafs/CellServDB.new perl -MSocket -e 'foreach (@ARGV) {' \ -e '@a=gethostbyname($_) and ' \ -e 'printf("%s\t\t# %s\n",inet_ntoa($a[4]),$a[0]) }' $RET \ @@ -48,12 +47,13 @@ if [ "$1" = configure ] || [ "$1" = reconfigure ] ; then if [ `wc -l &1 db_reset openafs-client/cell-info || true - exit 1 + rm /etc/openafs/CellServDB.new + else + cat /etc/openafs/CellServDB.new /etc/openafs/CellServDB \ + > /etc/openafs/CellServDB.tmp + mv /etc/openafs/CellServDB.tmp /etc/openafs/CellServDB + rm /etc/openafs/CellServDB.new fi - cat /etc/openafs/CellServDB.new /etc/openafs/CellServDB \ - >/etc/openafs/CellServDB.tmp - mv /etc/openafs/CellServDB.tmp /etc/openafs/CellServDB - rm /etc/openafs/CellServDB.new fi fi @@ -61,21 +61,23 @@ if [ "$1" = configure ] || [ "$1" = reconfigure ] ; then echo /afs:/var/cache/openafs:$RET >/etc/openafs/cacheinfo echo <<'EOF' > /etc/openafs/afs.conf.client -# This file is managed by debconf. Do not edit directly. To modify these -# settings, run dpkg-reconfigure openafs-client. +# This file is managed by debconf. You may change the parameters set below, +# but any additional lines or comments will be lost when the package is +# upgraded or reconfigured. Local modifications other than setting the +# following parameters should be made in /etc/openafs/afs.conf instead. EOF db_get openafs-client/run-client - echo AFS_CLIENT=$RET >/etc/openafs/afs.conf.client + echo AFS_CLIENT="$RET" > /etc/openafs/afs.conf.client db_get openafs-client/afsdb - echo AFS_AFSDB=$RET >>/etc/openafs/afs.conf.client + echo AFS_AFSDB="$RET" >> /etc/openafs/afs.conf.client db_get openafs-client/crypt - echo AFS_CRYPT=$RET >>/etc/openafs/afs.conf.client + echo AFS_CRYPT="$RET" >> /etc/openafs/afs.conf.client db_get openafs-client/dynroot - echo AFS_DYNROOT=$RET >>/etc/openafs/afs.conf.client + echo AFS_DYNROOT="$RET" >> /etc/openafs/afs.conf.client db_get openafs-client/fakestat - echo AFS_FAKESTAT=$RET >>/etc/openafs/afs.conf.client + echo AFS_FAKESTAT="$RET" >> /etc/openafs/afs.conf.client fi #DEBHELPER# diff --git a/debian/openafs-fileserver.config b/debian/openafs-fileserver.config index 04e326008..c333f4784 100644 --- a/debian/openafs-fileserver.config +++ b/debian/openafs-fileserver.config @@ -5,35 +5,23 @@ set -e db_version 2.0 +# Warn anyone who's trying to run the file server on alpha. arch=`dpkg --print-installation-architecture` -case $arch in - alpha) - db_input high openafs-fileserver/alpha-broken ||true -;; -esac +if [ "$arch" = "alpha" ] ; then + db_input high openafs-fileserver/alpha-broken || true +fi +# Configure the local cell. Ignore errors on read since it may fail if +# there's no newline in the file. Default to the server ThisCell file and, if +# that fails, the configured client cell. if [ -r /etc/openafs/server/ThisCell ] ; then - read cell