|
26 | 26 | # |
27 | 27 | # |
28 | 28 | # IDENTIFICATION |
29 | | -# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.67 1999/12/17 01:16:03 momjian Exp $ |
30 | | -# |
31 | | -#------------------------------------------------------------------------- |
32 | | - |
33 | | -# ---------------- |
34 | | -# The OPT_..._PARAM gets set when the script is built (with make) |
35 | | -# from parameters set in the make file. |
36 | | -# |
37 | | -# ---------------- |
38 | | - |
39 | | -CMDNAME=`basename$0` |
40 | | -MULTIBYTEID=0 |
41 | | - |
42 | | -MULTIBYTE=__MULTIBYTE__ |
43 | | -if [-n"$MULTIBYTE" ];then |
44 | | -MULTIBYTEID=`pg_encoding$MULTIBYTE` |
45 | | -fi |
46 | | - |
47 | | -# Find the default PGLIB directory (the directory that contains miscellaneous |
48 | | -# files that are part of Postgres). The user-written program postconfig |
49 | | -# outputs variable settings like "PGLIB=/usr/lib/whatever". If it doesn't |
50 | | -# output a PGLIB value, then there is no default and the user must |
51 | | -# specify the pglib option. Postconfig may validly not exist, in which case |
52 | | -# our invocation of it silently fails. |
53 | | - |
54 | | -# The 2>/dev/null is to swallow the "postconfig: not found" message if there |
55 | | -# is no postconfig. |
56 | | - |
57 | | -postconfig_result="`sh -c postconfig2>/dev/null`" |
58 | | -if [!-z"$postconfig_result" ];then |
59 | | -set -a# Make the following variable assignment exported to environment |
60 | | -eval"$postconfig_result" |
61 | | -set +a# back to normal |
62 | | -fi |
63 | | - |
64 | | -# Set defaults: |
65 | | -debug=0 |
66 | | -noclean=0 |
67 | | -template_only=0 |
68 | | -POSTGRES_SUPERUSERNAME=$USER |
69 | | - |
70 | | -while ["$#"-gt 0 ] |
71 | | -do |
72 | | -# ${ARG#--username=} is not reliable or available on all platforms |
73 | | - |
74 | | -case"$1"in |
75 | | - --debug|-d) |
76 | | - debug=1 |
77 | | -echo"Running with debug mode on." |
78 | | - ;; |
79 | | - --noclean|-n) |
80 | | - noclean=1 |
81 | | -echo"Running with noclean mode on." |
82 | | -"Mistakes will not be cleaned up." |
83 | | - ;; |
84 | | - --template|-t) |
85 | | - template_only=1 |
86 | | -echo"updating template1 database only." |
87 | | - ;; |
88 | | - --username=*) |
89 | | - POSTGRES_SUPERUSERNAME="`echo$1| sed's/^--username=//'`" |
90 | | - ;; |
91 | | - -u) |
92 | | -shift |
93 | | - POSTGRES_SUPERUSERNAME="$1" |
94 | | - ;; |
95 | | - -u*) |
96 | | - POSTGRES_SUPERUSERNAME="`echo$1| sed's/^-u//'`" |
97 | | - ;; |
98 | | - --pgdata=*) |
99 | | - PGDATA="`echo$1| sed's/^--pgdata=//'`" |
100 | | - ;; |
101 | | - -r) |
102 | | -shift |
103 | | - PGDATA="$1" |
104 | | - ;; |
105 | | - -r*) |
106 | | - PGDATA="`echo$1| sed's/^-r//'`" |
107 | | - ;; |
108 | | - --pglib=*) |
109 | | - PGLIB="`echo$1| sed's/^--pglib=//'`" |
110 | | - ;; |
111 | | - -l) |
112 | | -shift |
113 | | - PGLIB="$1" |
114 | | - ;; |
115 | | - -l*) |
116 | | - PGLIB="`echo$1| sed's/^-l//'`" |
117 | | - ;; |
118 | | - |
119 | | - --pgencoding=*) |
120 | | -if [-z"$MULTIBYTE" ];then |
121 | | -echo"MULTIBYTE support seems to be disabled" |
122 | | -exit 100 |
123 | | -fi |
124 | | - mb="`echo$1| sed's/^--pgencoding=//'`" |
125 | | -MULTIBYTEID=`pg_encoding$mb` |
126 | | -if [-z"$MULTIBYTEID" ];then |
127 | | -echo"$mb is not a valid encoding name" |
128 | | -exit 100 |
129 | | -fi |
130 | | - ;; |
131 | | - -e) |
132 | | -if [-z"$MULTIBYTE" ];then |
133 | | -echo"MULTIBYTE support seems to be disabled" |
134 | | -exit 100 |
135 | | -fi |
136 | | -shift |
137 | | -MULTIBYTEID=`pg_encoding$1` |
138 | | -if [-z"$MULTIBYTEID" ];then |
139 | | -echo"$1 is not a valid encoding name" |
140 | | -exit 100 |
141 | | -fi |
142 | | - ;; |
143 | | - -e*) |
144 | | -if [-z"$MULTIBYTE" ];then |
145 | | -echo"MULTIBYTE support seems to be disabled" |
146 | | -exit 100 |
147 | | -fi |
148 | | - mb="`echo$1| sed's/^-e//'`" |
149 | | -MULTIBYTEID=`pg_encoding$mb` |
150 | | -if [-z"$MULTIBYTEID" ];then |
151 | | -echo"$mb is not a valid encoding name" |
152 | | -exit 100 |
153 | | -fi |
154 | | - ;; |
155 | | -*) |
156 | | -echo"Unrecognized option '$1'. Syntax is:" |
157 | | -if [-z"$MULTIBYTE" ];then |
158 | | -echo"initdb [-t | --template] [-d | --debug]" \ |
159 | | -"[-n | --noclean]" \ |
160 | | -"[-u SUPERUSER | --username=SUPERUSER]" \ |
161 | | -"[-r DATADIR | --pgdata=DATADIR]" \ |
162 | | -"[-l LIBDIR | --pglib=LIBDIR]" |
163 | | -else |
164 | | -echo"initdb [-t | --template] [-d | --debug]" \ |
165 | | -"[-n | --noclean]" \ |
166 | | -"[-u SUPERUSER | --username=SUPERUSER]" \ |
167 | | -"[-r DATADIR | --pgdata=DATADIR]" \ |
168 | | -"[-l LIBDIR | --pglib=LIBDIR]" \ |
169 | | -"[-e ENCODING | --pgencoding=ENCODING]" |
170 | | -fi |
171 | | -exit 100 |
172 | | -esac |
173 | | -shift |
174 | | -done |
175 | | - |
176 | | -#------------------------------------------------------------------------- |
177 | | -# Make sure he told us where to find the Postgres files. |
178 | | -#------------------------------------------------------------------------- |
179 | | -if [-z"$PGLIB" ];then |
180 | | -echo"$CMDNAME does not know where to find the files that make up" |
181 | | -echo"Postgres (the PGLIB directory). You must identify the PGLIB" |
182 | | -echo"directory either with a --pglib invocation option, or by" |
183 | | -echo"setting the PGLIB environment variable, or by having a program" |
184 | | -echo"called 'postconfig' in your search path that outputs an asignment" |
185 | | -echo"for PGLIB." |
186 | | -exit 20 |
187 | | -fi |
188 | | - |
189 | | -#------------------------------------------------------------------------- |
190 | | -# Make sure he told us where to build the database system |
191 | | -#------------------------------------------------------------------------- |
192 | | - |
193 | | -if [-z"$PGDATA" ];then |
194 | | -echo"$CMDNAME: You must identify the PGDATA directory, where the data" |
195 | | -echo"for this database system will reside. Do this with either a" |
196 | | -echo"--pgdata invocation option or a PGDATA environment variable." |
197 | | -echo |
198 | | -exit 20 |
199 | | -fi |
200 | | - |
201 | | -TEMPLATE=$PGLIB/local1_template1.bki.source |
202 | | -GLOBAL=$PGLIB/global1.bki.source |
203 | | -TEMPLATE_DESCR=$PGLIB/local1_template1.description |
204 | | -GLOBAL_DESCR=$PGLIB/global1.description |
205 | | -PG_HBA_SAMPLE=$PGLIB/pg_hba.conf.sample |
206 | | -PG_GEQO_SAMPLE=$PGLIB/pg_geqo.sample |
207 | | - |
208 | | - |
209 | | -#------------------------------------------------------------------------- |
210 | | -# Find the input files |
211 | | -#------------------------------------------------------------------------- |
212 | | - |
213 | | -forPREREQ_FILEin$TEMPLATE$GLOBAL$PG_HBA_SAMPLE;do |
214 | | -if [!-f$PREREQ_FILE ];then |
215 | | -echo"$CMDNAME does not find the file '$PREREQ_FILE'." |
216 | | -echo"This means you have identified an invalid PGLIB directory." |
217 | | -echo"You specify a PGLIB directory with a --pglib invocation" |
218 | | -echo"option, a PGLIB environment variable, or a postconfig program." |
219 | | -exit 1 |
220 | | -fi |
221 | | -done |
222 | | - |
223 | | -["$debug"-ne 0 ]&&echo"$CMDNAME: using$TEMPLATE as input to create the template database." |
224 | | -if [$template_only-eq 0 ];then |
225 | | - ["$debug"-ne 0 ]&&echo"$CMDNAME: using$GLOBAL as input to create the global classes." |
226 | | - ["$debug"-ne 0 ]&&echo"$CMDNAME: using$PG_HBA_SAMPLE as the host-based authentication" \ |
227 | | -"control file." |
228 | | -echo |
229 | | -fi |
230 | | - |
231 | | -#--------------------------------------------------------------------------- |
232 | | -# Figure out who the Postgres superuser for the new database system will be. |
233 | | -#--------------------------------------------------------------------------- |
234 | | - |
235 | | -if [-z"$POSTGRES_SUPERUSERNAME" ];then |
236 | | -echo"Can't tell what username to use. You don't have the USER" |
237 | | -echo"environment variable set to your username and didn't specify the" |
238 | | -echo"--username option" |
239 | | -exit 1 |
240 | | -fi |
241 | | - |
242 | | -POSTGRES_SUPERUID=`pg_id$POSTGRES_SUPERUSERNAME` |
243 | | - |
244 | | -if [${POSTGRES_SUPERUID:=-1}-eq -1 ];then |
245 | | -echo"Unable to determine a valid username. If you are running" |
246 | | -echo"initdb without an explicit username specified, then there" |
247 | | -echo"may be a problem with finding the Postgres shared library" |
248 | | -echo"and/or the pg_id utility." |
249 | | -exit 10 |
250 | | -fi |
251 | | - |
252 | | -if [$POSTGRES_SUPERUID= NOUSER ];then |
253 | | -echo"Valid username not given. You must specify the username for" |
254 | | -echo"the Postgres superuser for the database system you are" |
255 | | -echo"initializing, either with the --username option or by default" |
256 | | -echo"to the USER environment variable." |
257 | | -exit 10 |
258 | | -fi |
259 | | - |
260 | | -if [$POSTGRES_SUPERUID-ne`pg_id`-a`pg_id`-ne 0 ];then |
261 | | -echo"Only the unix superuser may initialize a database with a different" |
262 | | -echo"Postgres superuser. (You must be able to create files that belong" |
263 | | -echo"to the specified unix user)." |
264 | | -exit 2 |
265 | | -fi |
266 | | - |
267 | | -echo"We are initializing the database system with username" \ |
268 | | -"$POSTGRES_SUPERUSERNAME (uid=$POSTGRES_SUPERUID)." |
269 | | -echo"This user will own all the files and must also own the server process." |
270 | | -echo |
271 | | - |
272 | | -# ----------------------------------------------------------------------- |
273 | | -# Create the data directory if necessary |
274 | | -- 26,318 ---- |
275 | | -# |
276 | | -# |
277 | | -# IDENTIFICATION |
278 | | -# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.67 1999/12/17 01:16:03 momjian Exp $ |
| 29 | +# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.68 1999/12/17 03:46:33 momjian Exp $ |
279 | 30 | # |
280 | 31 | #------------------------------------------------------------------------- |
281 | 32 |
|
|