3 # $FreeBSD: head/databases/postgresql95-server/files/postgresql.in 340872 2014-01-24 00:14:07Z mat $
9 # Add the following line to /etc/rc.conf to enable PostgreSQL:
11 # postgresql_enable="YES"
13 # postgresql_data="%%PREFIX%%/%%PG_USER%%/data"
14 # postgresql_flags="-w -s -m fast"
15 # postgresql_initdb_flags="--encoding=utf-8 --lc-collate=C"
16 # postgresql_class="default"
17 # postgresql_profiles=""
19 # See %%PREFIX%%/share/doc/postgresql/README-server for more info
21 # This scripts takes one of the following commands:
23 # start stop restart reload status initdb
25 # For postmaster startup options, edit ${postgresql_data}/postgresql.conf
27 command=%%PREFIX%%/bin/pg_ctl
31 load_rc_config postgresql
34 postgresql_enable=${postgresql_enable:-"NO"}
35 postgresql_flags=${postgresql_flags:-"-w -s -m fast"}
36 postgresql_user=${postgresql_user:-"%%PG_USER%%"}
37 eval postgresql_data=${postgresql_data:-"~${postgresql_user}/data"}
38 postgresql_class=${postgresql_class:-"default"}
39 postgresql_initdb_flags=${postgresql_initdb_flags:-"--encoding=utf-8 --lc-collate=C"}
42 rcvar=postgresql_enable
43 extra_commands="reload initdb"
45 start_cmd="postgresql_command start"
46 stop_cmd="postgresql_command stop"
47 restart_cmd="postgresql_command restart"
48 reload_cmd="postgresql_command reload"
49 status_cmd="postgresql_command status"
51 initdb_cmd="postgresql_initdb"
55 if [ "x${postgresql_profiles}" != "x" ]; then
56 eval postgresql_data="\${postgresql_${profile}_data:-}"
57 if [ "x${postgresql_data}" = "x" ]; then
58 echo "You must define a data directory (postgresql_${profile}_data)"
61 eval postgresql_enable="\${postgresql_${profile}_enable:-${postgresql_enable}}
62 eval postgresql_data="\${postgresql_${profile}_data:-${postgresql_data}}
63 eval postgresql_flags="\${postgresql_${profile}_flags:-${postgresql_flags}}"
64 eval postgresql_initdb_flags="\${postgresql_${profile}_initdb_flags:-${postgresql_initdb_flags}}"
67 if [ "x${postgresql_profiles}" != "x" -a "x$1" != "x" ]; then
68 for profile in ${postgresql_profiles}; do
69 eval _enable="\${postgresql_${profile}_enable}"
70 case "x${_enable:-${postgresql_enable}}" in
71 x|x[Nn][Oo]|x[Nn][Oo][Nn][Ee])
77 if test -z "$_enable"; then
78 _var=postgresql_enable
80 _var=postgresql_"${profile}"_enable
83 "'${_enable:-${postgresql_enable}}'" \
85 "Profile ${profile} skipped."
89 echo "===> postgresql profile: ${profile}"
90 %%PREFIX%%/etc/rc.d/postgresql $1 ${profile}
92 if [ "0${retcode}" -ne 0 ]; then
93 failed="${profile} (${retcode}) ${failed:-}"
95 success="${profile} ${success:-}"
102 command_args="-D ${postgresql_data} ${postgresql_flags}"
106 su -l ${postgresql_user} -c "exec ${command} ${command_args} ${rc_arg}"
111 su -l -c ${postgresql_class} ${postgresql_user} -c "exec %%PREFIX%%/bin/initdb ${postgresql_initdb_flags} -D ${postgresql_data}"