[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#538265: Add disable netcfg preseed option



On Fri, Jul 24, 2009 at 11:37 AM, Otavio Salvador wrote:
> Please use netcfg/enable

Done

> Please change it to be a preseed only template. It avoid useless work
> for translators and also keep the templates smaller since noone is
> going to be asked about it.

And done. Please let me know if I messed anything up!

I also found that certain packages like postgresql really don't like systems without loopback interfaces and hosts files, so I modified the patch to write out basic stub files using netcfg_write_common() before exiting.

Thanks for the fast response!

T
diff -urN netcfg-1.46.orig/debian/netcfg-common.templates netcfg-1.46.nosvn/debian/netcfg-common.templates
--- netcfg-1.46.orig/debian/netcfg-common.templates	2008-08-09 19:34:13.000000000 +0000
+++ netcfg-1.46.nosvn/debian/netcfg-common.templates	2009-07-25 13:46:17.000000000 +0000
@@ -1,3 +1,9 @@
+Template: netcfg/enable
+Type: boolean
+Default: true
+Description: for internal use; can be preseeded
+ Set to false to disable netcfg entirely via preseed.
+
 Template: netcfg/use_dhcp
 Type: boolean
 Default: true
diff -urN netcfg-1.46.orig/netcfg.c netcfg-1.46.nosvn/netcfg.c
--- netcfg-1.46.orig/netcfg.c	2008-08-09 19:34:15.000000000 +0000
+++ netcfg-1.46.nosvn/netcfg.c	2009-07-25 13:46:17.000000000 +0000
@@ -78,6 +78,19 @@
     /* initialize debconf */
     client = debconfclient_new();
     debconf_capb(client, "backup");
+
+    /* Check to see if netcfg should be run at all */
+    debconf_get(client, "netcfg/enable");
+    if ( strcmp(client->value, "false") == 0 ) {
+        struct in_addr null_ipaddress;
+        char *hostname = NULL;
+
+        null_ipaddress.s_addr = 0;
+        netcfg_get_hostname(client, "netcfg/dhcp_hostname", &hostname, 0);
+
+        netcfg_write_common(null_ipaddress, hostname, NULL);
+        return 0;
+    }
     
     /* always always always default back to DHCP, unless you've specified
      * disable_dhcp on the command line. */

Reply to: