8
8
#
9
9
#
10
10
# IDENTIFICATION
11
- # $Header: /cvsroot/pgsql/src/bin/pg_ctl/Attic/pg_ctl.sh,v 1.21 2001/07/11 04:57:34 momjian Exp $
11
+ # $Header: /cvsroot/pgsql/src/bin/pg_ctl/Attic/pg_ctl.sh,v 1.22 2001/07/11 16:16:52 momjian Exp $
12
12
#
13
13
# -------------------------------------------------------------------------
14
14
79
79
if echo " $0 " | grep ' /' > /dev/null 2>&1
80
80
then
81
81
# explicit dir name given
82
- self_path=` echo $0 | sed ' s,/[^/]*$,,' ` # (dirname command is not portable)
82
+ self_path=` echo " $0 " | sed ' s,/[^/]*$,,' ` # (dirname command is not portable)
83
83
else
84
84
# look for it in PATH ('which' command is not portable)
85
85
for dir in ` echo " $PATH " | sed ' s/:/ /g' `
@@ -116,7 +116,7 @@ shutdown_mode=smart
116
116
117
117
while [ " $# " -gt 0 ]
118
118
do
119
- case $1 in
119
+ case " $1 " in
120
120
-h|--help|-\? )
121
121
echo " $help "
122
122
exit 0
127
127
;;
128
128
-D)
129
129
shift
130
- PGDATA=" $1 "
130
+ # pass environment into new postmaster
131
+ export PGDATA=" $1 "
131
132
;;
132
133
-l)
133
- logfile=$2
134
+ logfile=" $2 "
134
135
shift ;;
135
136
-l* )
136
137
logfile=` echo " $1 " | sed ' s/^-l//' `
137
138
;;
138
139
-m)
139
- shutdown_mode=$2
140
+ shutdown_mode=" $2 "
140
141
shift ;;
141
142
-m* )
142
143
shutdown_mode=` echo " $1 " | sed ' s/^-m//' `
@@ -197,15 +198,15 @@ if [ -z "$PGDATA" ];then
197
198
fi
198
199
199
200
if [ -z " $wait " ]; then
200
- case $op in
201
+ case " $op " in
201
202
start) wait=no;;
202
203
stop) wait=yes;;
203
204
restart) wait=no;; # must wait on shutdown anyhow
204
205
esac
205
206
fi
206
207
207
208
208
- case $shutdown_mode in
209
+ case " $shutdown_mode " in
209
210
s|smart)
210
211
sig=" -TERM"
211
212
;;
@@ -227,7 +228,7 @@ DEFPOSTOPTS=$PGDATA/postmaster.opts.default
227
228
POSTOPTSFILE=$PGDATA /postmaster.opts
228
229
PIDFILE=$PGDATA /postmaster.pid
229
230
230
- if [ $op = " status" ]; then
231
+ if [ " $op " = " status" ]; then
231
232
if [ -f $PIDFILE ]; then
232
233
PID=` sed -n 1p $PIDFILE `
233
234
if [ $PID -lt 0 ]; then
@@ -245,7 +246,7 @@ if [ $op = "status" ];then
245
246
fi
246
247
fi
247
248
248
- if [ $op = " stop" -o $op = " restart" ]; then
249
+ if [ " $op " = " stop" -o " $op " = " restart" ]; then
249
250
if [ -f $PIDFILE ]; then
250
251
PID=` sed -n 1p $PIDFILE `
251
252
if [ $PID -lt 0 ]; then
@@ -255,7 +256,7 @@ if [ $op = "stop" -o $op = "restart" ];then
255
256
exit 1
256
257
fi
257
258
258
- kill $sig $PID
259
+ kill " $sig " $PID
259
260
260
261
# wait for postmaster to shut down
261
262
if [ " $wait " = yes -o " $op " = restart ]; then
@@ -284,15 +285,15 @@ if [ $op = "stop" -o $op = "restart" ];then
284
285
else # ! -f $PIDFILE
285
286
echo " $CMDNAME : cannot find $PIDFILE " 1>&2
286
287
echo " Is postmaster running?" 1>&2
287
- if [ $op = " restart" ]; then
288
+ if [ " $op " = " restart" ]; then
288
289
echo " starting postmaster anyway" 1>&2
289
290
else
290
291
exit 1
291
292
fi
292
293
fi
293
294
fi # stop or restart
294
295
295
- if [ $op = " start" -o $op = " restart" ]; then
296
+ if [ " $op " = " start" -o " $op " = " restart" ]; then
296
297
oldpid=" "
297
298
if [ -f $PIDFILE ]; then
298
299
echo " $CMDNAME : Another postmaster may be running. Trying to start postmaster anyway." 1>&2
@@ -301,24 +302,21 @@ if [ $op = "start" -o $op = "restart" ];then
301
302
302
303
# no -o given
303
304
if [ -z " $POSTOPTS " ]; then
304
- if [ $op = " start" ]; then
305
+ if [ " $op " = " start" ]; then
305
306
# if we are in start mode, then look for postmaster.opts.default
306
307
if [ -f $DEFPOSTOPTS ]; then
307
308
eval set X " ` cat $DEFPOSTOPTS ` " ; shift
308
309
fi
309
310
else
310
311
# if we are in restart mode, then look for postmaster.opts
311
312
eval set X " ` cat $POSTOPTSFILE ` " ; shift
312
- po_path=$1
313
+ po_path=" $1 "
313
314
shift
314
315
fi
315
316
else # -o given
316
317
eval set X " $POSTOPTS " ; shift
317
318
fi
318
319
319
- # pass environment into new postmaster
320
- export PGDATA
321
-
322
320
if [ -n " $logfile " ]; then
323
321
" $po_path " " $@ " < /dev/null >> $logfile 2>&1 &
324
322
else
0 commit comments