aboutsummaryrefslogtreecommitdiff
path: root/databases/postgresql73-server/files
diff options
context:
space:
mode:
authorPalle Girgensohn <girgen@FreeBSD.org>2005-03-19 03:51:45 +0000
committerPalle Girgensohn <girgen@FreeBSD.org>2005-03-19 03:51:45 +0000
commit75063741266f3fd43477a6ac526b36c2899c0108 (patch)
treebbf005f0ba4c3ce6942d024cc979f482ee22311a /databases/postgresql73-server/files
parenteaf383b08ae8074f7db4b61913c4c19234a6637f (diff)
Notes
Diffstat (limited to 'databases/postgresql73-server/files')
-rw-r--r--databases/postgresql73-server/files/pgsql.sh.tmpl84
1 files changed, 47 insertions, 37 deletions
diff --git a/databases/postgresql73-server/files/pgsql.sh.tmpl b/databases/postgresql73-server/files/pgsql.sh.tmpl
index 0d85d6fba25d..8d975d54303c 100644
--- a/databases/postgresql73-server/files/pgsql.sh.tmpl
+++ b/databases/postgresql73-server/files/pgsql.sh.tmpl
@@ -2,48 +2,58 @@
# $FreeBSD$
#
-# For postmaster startup options, edit $PGDATA/postgresql.conf
+# PROVIDE: postgresql
+# REQUIRE: LOGIN
+# KEYWORD: FreeBSD shutdown
#
-# Note that PGDATA is set in ~pgsql/.profile, don't try to manipulate it here!
+# Add the following line to /etc/rc.conf to enable PostgreSQL:
#
+# postgresql_enable="YES"
+# # optional
+# postgresql_data="%%PREFIX%%/pgsql/data"
+# postgresql_flags="-w -s -m fast"
+#
+# This scripts takes one of the following commands:
+#
+# start stop restart reload status initdb
+#
+# For postmaster startup options, edit ${postgresql_data}/postgresql.conf
+
+prefix=%%PREFIX%%
+
+. %%RC_SUBR%%
+
+load_rc_config postgresql
-PREFIX=%%PREFIX%%
-PGBIN=${PREFIX}/bin
-logfile=/var/log/pgsql
+# set defaults
+postgresql_enable=${postgresql_enable:-"NO"}
+postgresql_flags=${postgresql_flags:-"-w -s -m fast"}
+postgresql_user=pgsql
+eval postgresql_data=${postgresql_data:-"~${postgresql_user}/data"}
+postgresql_class=${postgresql_class:-"default"}
-case $1 in
-start)
- touch ${logfile}
- chmod 600 ${logfile}
- chown pgsql:pgsql ${logfile}
- [ -x ${PGBIN}/pg_ctl ] && {
- su -l pgsql -c \
- "[ -d \${PGDATA} ] && exec ${PREFIX}/bin/pg_ctl start -s -w -l ${logfile}"
- echo -n ' pgsql'
- }
- ;;
+name=postgresql
+rcvar=`set_rcvar`
+command=${prefix}/bin/pg_ctl
+command_args="-D ${postgresql_data} ${postgresql_flags} $1"
+extra_commands="reload initdb"
-stop)
- [ -x ${PGBIN}/pg_ctl ] && {
- su -l pgsql -c "exec ${PREFIX}/bin/pg_ctl stop -s -m fast"
- echo -n ' pgsql'
- }
- ;;
+start_cmd="postgresql_command start"
+stop_cmd="postgresql_command stop"
+restart_cmd="postgresql_command restart"
+reload_cmd="postgresql_command reload"
+status_cmd="postgresql_command status"
-restart)
- [ -x ${PGBIN}/pg_ctl ] && {
- exec su -l pgsql -c "exec ${PREFIX}/bin/pg_ctl restart -s -m fast -l ${logfile}"
- }
- ;;
+initdb_cmd="postgresql_initdb"
-status)
- [ -x ${PGBIN}/pg_ctl ] && {
- exec su -l pgsql -c "exec ${PREFIX}/bin/pg_ctl status"
- }
- ;;
+postgresql_command()
+{
+ su -l ${postgresql_user} -c "exec ${command} ${command_args}"
+}
+
+postgresql_initdb()
+{
+ su -l -c ${postgresql_class} ${postgresql_user} -c "exec ${prefix}/bin/initdb -D ${postgresql_data}"
+}
-*)
- echo "usage: `basename $0` {start|stop|restart|status}" >&2
- exit 64
- ;;
-esac
+run_rc_command "$1"