Control: tags -1 + patch

[Ludovic Drolez]
> Yes proper auto-configuration of this package is a nightmare, maybe the
> better is to drop all auto-config and suggest people to manually
> configure it.

Probably not.  Here is a draft patch (untested) which make sure the
atftpd.config script load the current settings from /etc/ before
asking during installation and upgrades, to ensure the current
settings on disk do not change.

I'm a but unsure how robust the inetd option loading is, but suspect it
should work.  I disabled the rewrite of /etc/logrotate.d/atftpd, as I am not
quite sure how to do that best.  It might be good to print a warning if the
log file name is changed.

-- 
Happy hacking
Petter Reinholdtsen
diff --git a/debian/atftpd.config b/debian/atftpd.config
index 46acf03..b19ae22 100644
--- a/debian/atftpd.config
+++ b/debian/atftpd.config
@@ -3,6 +3,46 @@
 . /usr/share/debconf/confmodule
 db_version 2.0
 
+opts2debconf() {
+    while "$1" ; do
+	case "$opt" in
+	    --daemon) ;;
+	    --port)          db_set atftpd/port "$2"; shift ;;
+	    --tftpd-timeout) db_set atftpd/tftpd-timeout "$2"; shift ;;
+            --retry-timeout) db_set atftpd/retry-timeout "$2"; shift ;;
+            --maxthread)     db_set atftpd/maxthread "$2"; shift ;;
+	    --no-timeout)    db_set atftpd/timeout "false"; shift ;;
+	    --no-tsize)      db_set atftpd/tsize "false"; shift ;;
+	    --no-blksize)    db_set atftpd/blksize "false"; shift ;;
+	    --no-multicast)  db_set atftpd/multicast "false"; shift ;;
+	    --mcast-port)    db_set atftpd/mcast_port "$2"; shift ;;
+	    --mcast-addr)    db_set atftpd/mcast_addr "$2"; shift ;;
+	    --mcast-ttl)     db_set atftpd/ttl "$2"; shift ;;
+	    --verbose=*)
+		db_set atftpd/verbosity $(echo "$1" | cut -d= -f2-)
+		;;
+	    --logfile)
+		db_set atftpd/logtofile true
+		db_set atftpd/logfile "$2"
+		;;
+	    /*) db_set atftpd/basedir "$1" ;;
+	esac
+	shift
+    done
+}
+
+# Load current settings from file
+if [ -f /etc/default/atftpd ]; then
+    . /etc/default/atftpd
+    db_set atftpd/use_inetd "$USE_INETD"
+    if [ "$USE_INETD" = "false" ]; then
+	opts2debconf $OPTIONS
+    else
+	# FIXME should work with xinetd too
+	INETOPTS="$(grep /usr/sbin/in.tftpd /etc/inetd.conf | sed 's%.*/usr/sbin/in.tftpd %%')"
+	opts2debconf $INETOPTS
+    fi
+fi
 # Do not ask if you need to configure atftp (Bug#266329)
 
 #db_beginblock
diff --git a/debian/atftpd.postinst b/debian/atftpd.postinst
index 6a8d0cc..c07dbc6 100644
--- a/debian/atftpd.postinst
+++ b/debian/atftpd.postinst
@@ -94,8 +94,9 @@ db_version 2.0
 		chown nobody:nogroup $RET
 		chmod 640 $RET
 	    fi
-	    # modify the logrotate file
-	    cat >/etc/logrotate.d/atftpd <<EOF
+	    # create the logrotate file
+	    if [ ! -f /etc/logrotate.d/atftpd ] ; then
+		cat >/etc/logrotate.d/atftpd <<EOF
 $RET {
     daily
     rotate 5
@@ -104,6 +105,7 @@ $RET {
     missingok
 }
 EOF
+		fi
 	fi
     else
 	LOGFILE=""

Reply via email to