-
Notifications
You must be signed in to change notification settings - Fork 2
/
pgstart.sh
executable file
·74 lines (62 loc) · 1.28 KB
/
pgstart.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh
. pgcommon.sh
OPT=
INITDB_OPT=
RENAMECONF="FALSE"
MAXWAIT=3600
usage ()
{
cat <<EOF
$PROGNAME starts PostgreSQL server.
Usage:
$PROGNAME [OPTIONS] [PGDATA]
Options:
-a enables WAL archiving if initializing PGDATA
-k uses data page checksums if initializing PGDATA
-r renames recovery.done to .conf before the start
-t SECS seconds to wait when using -w option (default: 3600s)
-w waits for the start to complete
-X uses external XLOG directory if initializing PGDATA
--no-tune does NOT use auto tuning
EOF
}
while [ $# -gt 0 ]; do
case "$1" in
"-?"|--help)
usage
exit 0;;
-a)
INITDB_OPT="-a $INITDB_OPT";;
-k)
INITDB_OPT="-k $INITDB_OPT";;
-r)
RENAMECONF="TRUE";;
-t)
MAXWAIT=$2
shift;;
-w)
OPT="-w $OPT";;
-X)
INITDB_OPT="-X $INITDB_OPT";;
--no-tune)
INITDB_OPT="--no-tune $INITDB_OPT";;
-*)
elog "invalid option: $1";;
*)
update_pgdata "$1";;
esac
shift
done
here_is_installation
if [ ! -d $PGDATA ]; then
pginitdb.sh $INITDB_OPT $PGDATA
exit_on_error
fi
pgsql_is_dead
if [ $PGMAJOR -ge 83 ]; then
OPT="-c $OPT"
fi
if [ "$RENAMECONF" = "TRUE" -a -f $RECOVERYDONE ]; then
mv $RECOVERYDONE $RECOVERYCONF
fi
$PGBIN/pg_ctl $OPT -D $PGDATA -t $MAXWAIT start