blob: 7c422f2d88fb5c18bceae51223e1c120216a1cdf (
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
|
#!/bin/sh
#
# $NetBSD: pgsql.sh,v 1.4 2001/05/14 21:19:42 jlam Exp $
#
# PostgreSQL database rc.d control script
#
# PROVIDE: pgsql
# REQUIRE: DAEMON
# KEYWORD: shutdown
PGHOME=@PGHOME@
name="pgsql"
rcvar=$name
pgsql_user="@PGUSER@"
command="@PREFIX@/bin/pg_ctl"
command_args="-s -D ${PGHOME}/data -l ${PGHOME}/errlog"
# pgsql_flags contains options for the PostgreSQL postmaster.
# See postmaster(1) for possible options.
#
#pgsql_flags="-i" # allows TCP/IP connections
#pgsql_flags="-i -l" # enables SSL connections (TCP/IP required)
# set defaults
if [ -r /etc/rc.conf ]
then
. /etc/rc.conf
else
eval ${rcvar}=YES
fi
# $flags from environment overrides $pgsql_flags
if [ -n "${flags}" ]
then
eval ${rcvar}_flags="${flags}"
fi
pgsql_doit()
{
action=$1
if [ -n "${pgsql_flags}" ]
then
command_args="${command_args} -o \"${pgsql_flags}\""
fi
case ${action} in
start) pgsql_start_precmd; echo "Starting ${name}." ;;
stop) echo "Stopping ${name}." ;;
restart) echo "Restarting ${name}." ;;
esac
@SU@ -m ${pgsql_user} -c "${command} ${command_args} ${action}"
}
pgsql_start_precmd()
{
if [ ! -f ${PGHOME}/data/base/1/PG_VERSION ]
then
$0 forceinitdb
fi
}
pgsql_initdb()
{
if [ -f ${PGHOME}/data/base/1/PG_VERSION ]
then
echo "The PostgreSQL template databases have already been initialized."
echo "Skipping database initialization."
else
echo "Initializing PostgreSQL databases."
@SU@ -m ${pgsql_user} -c "@PREFIX@/bin/initdb -D ${PGHOME}/data $flags"
fi
}
checkyesno()
{
eval _value=\$${1}
case $_value in
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0 ;;
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1 ;;
*)
echo "\$${1} is not set properly."
return 1
;;
esac
}
# force commands are always executed
cmd=${1:-start}
case ${cmd} in
force*)
cmd=${cmd#force}
eval ${rcvar}=YES
;;
esac
if checkyesno ${rcvar}
then
if [ -x ${command} ]
then
case ${cmd} in
initdb)
${rcvar}_${cmd}
;;
restart|start|stop|status)
${rcvar}_doit ${cmd}
;;
*)
echo 1>&2 "Usage: $0 [initdb|restart|start|stop|status]"
exit 1
;;
esac
fi
fi
|