summaryrefslogtreecommitdiff
blob: d22a67df84fedbcd0e5817369f306966e90585b7 (plain)
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-db/pgcluster/files/pgcluster.init-1.3.0b,v 1.1 2005/02/27 07:20:28 nakano Exp $

opts="${opts} reload"

depend() {
	use net
}

checkconfig() {
	if [ ! -d $PGDATA ]; then
		eerror "directory not found: $PGDATA"
		eerror "You should create PGDATA directory first."
		return 1
	fi
}

start_recover() {
	ebegin "Starting PGCluster"
	if [ -f $PGDATA/postmaster.pid ]; then
		rm $PGDATA/postmaster.pid
	fi

	su - $PGUSER -c "/usr/bin/pg_ctl start -D '$PGDATA' -s -l '$PGLOG' -o '$PGOPTS -R'"

	while :
	do
		cnt=$(($cnt + 1))
		if [ -f "$PGDATA/postmaster.pid" ]; then
			ret=0
			break
		fi

		if [ $cnt -eq 30 ]; then
			eerror "Please see log file: $PGLOG"
			ret=1
			break
		fi
		sleep 1
	done
	eend $ret

}

start() {
	checkconfig || return 1

	ebegin "Starting PGCluster"
	if [ -f $PGDATA/postmaster.pid ]; then
		rm $PGDATA/postmaster.pid
	fi
	su - $PGUSER -c "/usr/bin/pg_ctl start -D '$PGDATA' -s -l '$PGLOG' -o '$PGOPTS'"

	while :
	do
		cnt=$(($cnt + 1))
		if [ -f "$PGDATA/postmaster.pid" ]; then
			ret=0
			break
		fi

		if [ $cnt -eq 30 ]; then
			eerror "Please see log file: $PGLOG"
			ret=1
			break
		fi
		sleep 1
	done
	eend $ret
}

stop() {
	ebegin "Stopping PGCluster"
	su - $PGUSER -c "/usr/bin/pg_ctl stop -D '$PGDATA' -s -m fast"
	eend $?
}

svc_restart() {
	ebegin "Restarting PGCluster"
	su - $PGUSER -c "/usr/bin/pg_ctl restart -D '$PGDATA' -s -m fast -l '$PGLOG' -o '$PGOPTS'"
	eend $?
}

reload() {
	ebegin "Reloading PGCluster configuration"
	su - $PGUSER -c "/usr/bin/pg_ctl reload -D '$PGDATA' -s"
	eend $?
}