On Tuesday 01 July 2003 05:39, Peter Eisentraut wrote:
> Josh Berkus writes:
> > initdb.patch, written by Shridhar, patches initdb so that the LC_*
> > localization variables are inserted into postgresql.conf at the point
> > commented "#LC VARS GO HERE!"
>
> It's pretty pointless to use
>
> cat $file | sed 's/.../'
>
> because sed can open files perfectly well:
>
> sed 's/.../' $file
>
> You should clean up the temp files in exit_nicely(), because if someone or
> something aborts initdb in the middle, then the trap will at least have a
> better chance to remove the files.

Argh. That was me who did that patch and it was not good.

Anyway attached is the patch

 * Which uses sed correctly
 * and get rid of temp files at all.

Hopefully this will be good enough.

 Shridhar
*** initdb.orig	Wed Jun 25 19:50:20 2003
--- initdb	Tue Jul  1 14:59:27 2003
***************
*** 586,602 ****
  cp "$PG_HBA_SAMPLE" "$PGDATA"/pg_hba.conf              || exit_nicely
  cp "$PG_IDENT_SAMPLE" "$PGDATA"/pg_ident.conf          || exit_nicely
  (
!   cat "$POSTGRESQL_CONF_SAMPLE"
!   echo
!   echo
!   echo "#"
!   echo "#	Locale settings"
!   echo "#"
!   echo "# (initialized by initdb -- may be changed)"
    for cat in MESSAGES MONETARY NUMERIC TIME; do
!     echo "LC_$cat = '`pg_getlocale $cat`'"
    done
! ) > "$PGDATA"/postgresql.conf || exit_nicely
  
  chmod 0600 "$PGDATA"/pg_hba.conf "$PGDATA"/pg_ident.conf \
  	"$PGDATA"/postgresql.conf
--- 586,600 ----
  cp "$PG_HBA_SAMPLE" "$PGDATA"/pg_hba.conf              || exit_nicely
  cp "$PG_IDENT_SAMPLE" "$PGDATA"/pg_ident.conf          || exit_nicely
  (
!   var='\n#\n#\n#       Locale settings\n#\n# (initialized by initdb -- may be changed)\n#\n'
! 
    for cat in MESSAGES MONETARY NUMERIC TIME; do
!     var1="LC_$cat='`pg_getlocale $cat`'"
!     var="$var\n$var1";
    done
!   sed s/'#LC VARIABLES GO HERE!'/"$var"/ "$POSTGRESQL_CONF_SAMPLE" >"$PGDATA"/postgresql.conf
! ) || exit_nicely
!   
  
  chmod 0600 "$PGDATA"/pg_hba.conf "$PGDATA"/pg_ident.conf \
  	"$PGDATA"/postgresql.conf
---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster

Reply via email to