summaryrefslogtreecommitdiff
path: root/databases/postgresql/files/pgsql.sh
blob: 4d021c1b963a36d26bb638ac2187d2517a4ad003 (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
#!/bin/sh
#
# $NetBSD: pgsql.sh,v 1.2 2001/02/12 20:11:56 jlam Exp $
#
# PostgreSQL database rc.d control script
#
# PROVIDE: pgsql
# REQUIRE: DAEMON
# KEYWORD: shutdown

name="postgres"
ctl_command="@PREFIX@/bin/pg_ctl"
command="@PREFIX@/bin/postmaster"
command_args="-S -o -F"			# start in silent mode and disable
					#   automatic fsync after each
					#   transaction
#command_args="-S -i -o -F"		# as above, but also allows TCP/IP
					#   connections

USER="@PGUSER@"
PGHOME="@PREFIX@/${USER}"
SU="@SU@"

cmd=${1:-start}

if [ -x ${ctl_command} -a -x ${command} ]
then
	case ${cmd} in
	restart)
		echo "Restarting ${name}."
		echo "exec ${ctl_command} restart >> ${PGHOME}/errlog" \
			| ${SU} -l ${USER}
		;;

	start)
		echo "Starting ${name}."
		echo "exec ${ctl_command} \
			-p ${command} -o \"${command_args}\" start" \
			| ${SU} -l ${USER}
		;;

	stop)
		echo "Stopping ${name}."
		echo "exec ${ctl_command} stop >> ${PGHOME}/errlog" \
			| ${SU} -l ${USER}
		;;

	status)
		echo "exec ${ctl_command} status" \
			| ${SU} -l ${USER}
		;;

	*)
		echo 1>&2 "Usage: $0 [restart|start|stop|status]"
		exit 1
		;;
	esac
fi