diff --git a/src/bin/initdb/initdb.c b/src/bin/initdb/initdb.c
index f40ad87..4855f99 100644
*** a/src/bin/initdb/initdb.c
--- b/src/bin/initdb/initdb.c
*************** static char infoversion[100];
*** 111,116 ****
--- 111,117 ----
  static bool caught_signal = false;
  static bool output_failed = false;
  static int	output_errno = 0;
+ static char **append_config_buffer;
  
  /* defaults */
  static int	n_connections = 10;
*************** xstrdup(const char *s)
*** 271,276 ****
--- 272,298 ----
  	return result;
  }
  
+ /* like xstrdup, but appends a newline to the duplicated string*/
+ static char *
+ xstrdupln(const char *s)
+ {
+ 	char	   *result;
+     int        len = strlen(s);
+ 
+ 	result = (char*)malloc(len+2);
+ 	if (!result)
+ 	{
+ 		fprintf(stderr, _("%s: out of memory\n"), progname);
+ 		exit(1);
+ 	}
+     memcpy(result,s,len);
+ 
+     result[len]   = '\n';
+     result[len+1] = 0;
+ 
+ 	return result;
+ }
+ 
  /*
   * make a copy of the array of lines, with token replaced by replacement
   * the first time it occurs on each line.
*************** readfile(const char *path)
*** 417,422 ****
--- 439,517 ----
  }
  
  /*
+  * return a char** created by appending the source** with the dest**
+  *
+  * adds newlines to the end of any line which are missing one. 
+  */
+ static char **
+ append_lines(char **src, char **lines)
+ {
+     char **buf;
+     int i;
+     int src_lines = 0;
+     int app_lines = 0;
+ 
+     for (i=0; src[i]; i++)
+         src_lines++;
+     for (i=0; lines[i]; i++)
+         app_lines++;
+ 
+     buf = (char**) pg_malloc((src_lines + app_lines + 1) * (sizeof(char *)));
+ 
+     memcpy(buf,src,(sizeof(char *))*src_lines);
+ 
+     for (i=0; i<app_lines; i++)
+         buf[src_lines+i] = xstrdup(lines[i]);
+     buf[src_lines + app_lines] = 0; // fill in the last slot
+ 
+     return buf;
+ }
+ 
+ /*
+  * append a single line to the char** buffer.  adds a trailing newline if one does not exist.
+  */
+ static char **
+ append_line(char **src, char *line)
+ {
+     char **buf;
+     int i;
+     int src_lines = 0;
+ 
+     if (!line)
+         return src;
+ 
+     for (i=0; src[i]; i++)
+         src_lines++;
+ 
+     /* we assume that anything existing in the buffer already has been
+      * xstrdup'd, and so only xstrdup new lines
+      */
+     buf = (char**) pg_malloc((src_lines + 2) * (sizeof(char *)));
+     memcpy(buf,src,(sizeof(char *))*src_lines);
+ 
+     buf[src_lines] = xstrdupln(line);
+     buf[src_lines+1] = 0;
+ 
+     return buf;
+ }
+ 
+ /*
+  * append a configuration line to the config buffer.  If not already set, add a standard header as the initial contents.
+  */
+ static void
+ append_config_line(char *line)
+ {
+     if (!append_config_buffer)
+     {
+         append_config_buffer = (char**)pg_malloc(sizeof(char*)*2);
+         append_config_buffer[0] = xstrdupln("\n## initdb -C customizations start here");
+         append_config_buffer[1] = 0;
+     }
+ 
+     append_config_buffer = append_line(append_config_buffer,line);
+ }
+ 
+ /*
   * write an array of lines to a file
   *
   * This is only used to write text files.  Use fopen "w" not PG_BINARY_W
*************** setup_config(void)
*** 1163,1171 ****
--- 1258,1272 ----
  						 "#default_text_search_config = 'pg_catalog.simple'",
  							  repltok);
  
+     if (append_config_buffer)
+     {
+         conflines = append_lines(conflines, append_config_buffer);
+     }
+ 
  	snprintf(path, sizeof(path), "%s/postgresql.conf", pg_data);
  
  	writefile(path, conflines);
+ 
  	chmod(path, 0600);
  
  	free(conflines);
*************** usage(const char *progname)
*** 2396,2401 ****
--- 2497,2504 ----
  	printf(_("  -X, --xlogdir=XLOGDIR     location for the transaction log directory\n"));
  	printf(_("\nLess commonly used options:\n"));
  	printf(_("  -d, --debug               generate lots of debugging output\n"));
+ 	printf(_("  -C, --append-config=LINE  append the provided line to the postgresql.conf file\n"
+              "                            (can be used multiple times)\n"));
  	printf(_("  -L DIRECTORY              where to find the input files\n"));
  	printf(_("  -n, --noclean             do not clean up after errors\n"));
  	printf(_("  -s, --show                show internal settings\n"));
*************** main(int argc, char *argv[])
*** 2436,2441 ****
--- 2539,2545 ----
  		{"show", no_argument, NULL, 's'},
  		{"noclean", no_argument, NULL, 'n'},
  		{"xlogdir", required_argument, NULL, 'X'},
+ 		{"append-config", required_argument, NULL, 'C'},
  		{NULL, 0, NULL, 0}
  	};
  
*************** main(int argc, char *argv[])
*** 2488,2494 ****
  
  	/* process command-line options */
  
! 	while ((c = getopt_long(argc, argv, "dD:E:L:nU:WA:sT:X:", long_options, &option_index)) != -1)
  	{
  		switch (c)
  		{
--- 2592,2598 ----
  
  	/* process command-line options */
  
! 	while ((c = getopt_long(argc, argv, "C:dD:E:L:nU:WA:sT:X:", long_options, &option_index)) != -1)
  	{
  		switch (c)
  		{
*************** main(int argc, char *argv[])
*** 2554,2559 ****
--- 2658,2666 ----
  			case 'X':
  				xlog_dir = xstrdup(optarg);
  				break;
+             case 'C':
+                 append_config_line(optarg);
+                 break;
  			default:
  				/* getopt_long already emitted a complaint */
  				fprintf(stderr, _("Try \"%s --help\" for more information.\n"),
