From: Bruce Momjian Date: Fri, 17 Dec 1999 03:46:33 +0000 (+0000) Subject: ANother initdb cleanup X-Git-Tag: REL7_0~1013 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4f73187bb70bf52212aad48066193f3cc343a273;p=postgresql ANother initdb cleanup --- diff --git a/src/bin/initdb/initdb.sh b/src/bin/initdb/initdb.sh index 3847c8a119..90b0036c8c 100644 --- a/src/bin/initdb/initdb.sh +++ b/src/bin/initdb/initdb.sh @@ -26,256 +26,7 @@ # # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.67 1999/12/17 01:16:03 momjian Exp $ -# -#------------------------------------------------------------------------- - -# ---------------- -# The OPT_..._PARAM gets set when the script is built (with make) -# from parameters set in the make file. -# -# ---------------- - -CMDNAME=`basename $0` -MULTIBYTEID=0 - -MULTIBYTE=__MULTIBYTE__ -if [ -n "$MULTIBYTE" ];then - MULTIBYTEID=`pg_encoding $MULTIBYTE` -fi - -# Find the default PGLIB directory (the directory that contains miscellaneous -# files that are part of Postgres). The user-written program postconfig -# outputs variable settings like "PGLIB=/usr/lib/whatever". If it doesn't -# output a PGLIB value, then there is no default and the user must -# specify the pglib option. Postconfig may validly not exist, in which case -# our invocation of it silently fails. - -# The 2>/dev/null is to swallow the "postconfig: not found" message if there -# is no postconfig. - -postconfig_result="`sh -c postconfig 2>/dev/null`" -if [ ! -z "$postconfig_result" ]; then - set -a # Make the following variable assignment exported to environment - eval "$postconfig_result" - set +a # back to normal -fi - -# Set defaults: -debug=0 -noclean=0 -template_only=0 -POSTGRES_SUPERUSERNAME=$USER - -while [ "$#" -gt 0 ] -do -# ${ARG#--username=} is not reliable or available on all platforms - - case "$1" in - --debug|-d) - debug=1 - echo "Running with debug mode on." - ;; - --noclean|-n) - noclean=1 - echo "Running with noclean mode on. " - "Mistakes will not be cleaned up." - ;; - --template|-t) - template_only=1 - echo "updating template1 database only." - ;; - --username=*) - POSTGRES_SUPERUSERNAME="`echo $1 | sed 's/^--username=//'`" - ;; - -u) - shift - POSTGRES_SUPERUSERNAME="$1" - ;; - -u*) - POSTGRES_SUPERUSERNAME="`echo $1 | sed 's/^-u//'`" - ;; - --pgdata=*) - PGDATA="`echo $1 | sed 's/^--pgdata=//'`" - ;; - -r) - shift - PGDATA="$1" - ;; - -r*) - PGDATA="`echo $1 | sed 's/^-r//'`" - ;; - --pglib=*) - PGLIB="`echo $1 | sed 's/^--pglib=//'`" - ;; - -l) - shift - PGLIB="$1" - ;; - -l*) - PGLIB="`echo $1 | sed 's/^-l//'`" - ;; - - --pgencoding=*) - if [ -z "$MULTIBYTE" ];then - echo "MULTIBYTE support seems to be disabled" - exit 100 - fi - mb="`echo $1 | sed 's/^--pgencoding=//'`" - MULTIBYTEID=`pg_encoding $mb` - if [ -z "$MULTIBYTEID" ];then - echo "$mb is not a valid encoding name" - exit 100 - fi - ;; - -e) - if [ -z "$MULTIBYTE" ];then - echo "MULTIBYTE support seems to be disabled" - exit 100 - fi - shift - MULTIBYTEID=`pg_encoding $1` - if [ -z "$MULTIBYTEID" ];then - echo "$1 is not a valid encoding name" - exit 100 - fi - ;; - -e*) - if [ -z "$MULTIBYTE" ];then - echo "MULTIBYTE support seems to be disabled" - exit 100 - fi - mb="`echo $1 | sed 's/^-e//'`" - MULTIBYTEID=`pg_encoding $mb` - if [ -z "$MULTIBYTEID" ];then - echo "$mb is not a valid encoding name" - exit 100 - fi - ;; - *) - echo "Unrecognized option '$1'. Syntax is:" - if [ -z "$MULTIBYTE" ];then - echo "initdb [-t | --template] [-d | --debug]" \ - "[-n | --noclean]" \ - "[-u SUPERUSER | --username=SUPERUSER]" \ - "[-r DATADIR | --pgdata=DATADIR]" \ - "[-l LIBDIR | --pglib=LIBDIR]" - else - echo "initdb [-t | --template] [-d | --debug]" \ - "[-n | --noclean]" \ - "[-u SUPERUSER | --username=SUPERUSER]" \ - "[-r DATADIR | --pgdata=DATADIR]" \ - "[-l LIBDIR | --pglib=LIBDIR]" \ - "[-e ENCODING | --pgencoding=ENCODING]" - fi - exit 100 - esac - shift -done - -#------------------------------------------------------------------------- -# Make sure he told us where to find the Postgres files. -#------------------------------------------------------------------------- -if [ -z "$PGLIB" ]; then - echo "$CMDNAME does not know where to find the files that make up " - echo "Postgres (the PGLIB directory). You must identify the PGLIB " - echo "directory either with a --pglib invocation option, or by " - echo "setting the PGLIB environment variable, or by having a program " - echo "called 'postconfig' in your search path that outputs an asignment " - echo "for PGLIB." - exit 20 -fi - -#------------------------------------------------------------------------- -# Make sure he told us where to build the database system -#------------------------------------------------------------------------- - -if [ -z "$PGDATA" ]; then - echo "$CMDNAME: You must identify the PGDATA directory, where the data" - echo "for this database system will reside. Do this with either a" - echo "--pgdata invocation option or a PGDATA environment variable." - echo - exit 20 -fi - -TEMPLATE=$PGLIB/local1_template1.bki.source -GLOBAL=$PGLIB/global1.bki.source -TEMPLATE_DESCR=$PGLIB/local1_template1.description -GLOBAL_DESCR=$PGLIB/global1.description -PG_HBA_SAMPLE=$PGLIB/pg_hba.conf.sample -PG_GEQO_SAMPLE=$PGLIB/pg_geqo.sample - - -#------------------------------------------------------------------------- -# Find the input files -#------------------------------------------------------------------------- - -for PREREQ_FILE in $TEMPLATE $GLOBAL $PG_HBA_SAMPLE; do - if [ ! -f $PREREQ_FILE ]; then - echo "$CMDNAME does not find the file '$PREREQ_FILE'." - echo "This means you have identified an invalid PGLIB directory." - echo "You specify a PGLIB directory with a --pglib invocation " - echo "option, a PGLIB environment variable, or a postconfig program." - exit 1 - fi -done - -[ "$debug" -ne 0 ] && echo "$CMDNAME: using $TEMPLATE as input to create the template database." -if [ $template_only -eq 0 ]; then - [ "$debug" -ne 0 ] && echo "$CMDNAME: using $GLOBAL as input to create the global classes." - [ "$debug" -ne 0 ] && echo "$CMDNAME: using $PG_HBA_SAMPLE as the host-based authentication" \ - "control file." - echo -fi - -#--------------------------------------------------------------------------- -# Figure out who the Postgres superuser for the new database system will be. -#--------------------------------------------------------------------------- - -if [ -z "$POSTGRES_SUPERUSERNAME" ]; then - echo "Can't tell what username to use. You don't have the USER" - echo "environment variable set to your username and didn't specify the " - echo "--username option" - exit 1 -fi - -POSTGRES_SUPERUID=`pg_id $POSTGRES_SUPERUSERNAME` - -if [ ${POSTGRES_SUPERUID:=-1} -eq -1 ]; then - echo "Unable to determine a valid username. If you are running" - echo "initdb without an explicit username specified, then there" - echo "may be a problem with finding the Postgres shared library" - echo "and/or the pg_id utility." - exit 10 -fi - -if [ $POSTGRES_SUPERUID = NOUSER ]; then - echo "Valid username not given. You must specify the username for " - echo "the Postgres superuser for the database system you are " - echo "initializing, either with the --username option or by default " - echo "to the USER environment variable." - exit 10 -fi - -if [ $POSTGRES_SUPERUID -ne `pg_id` -a `pg_id` -ne 0 ]; then - echo "Only the unix superuser may initialize a database with a different" - echo "Postgres superuser. (You must be able to create files that belong" - echo "to the specified unix user)." - exit 2 -fi - -echo "We are initializing the database system with username" \ - "$POSTGRES_SUPERUSERNAME (uid=$POSTGRES_SUPERUID)." -echo "This user will own all the files and must also own the server process." -echo - -# ----------------------------------------------------------------------- -# Create the data directory if necessary -- 26,318 ---- -# -# -# IDENTIFICATION -# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.67 1999/12/17 01:16:03 momjian Exp $ +# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.68 1999/12/17 03:46:33 momjian Exp $ # #-------------------------------------------------------------------------