rcNG-fy databases/postgresql7
Norikatsu Shigemura
nork at FreeBSD.org
Wed Apr 28 08:55:04 PDT 2004
Hi.
I made a patch which is rcNG-fy databases/postgresql.
I think this is very ugly. Anyone, please cleanup the rcNG script.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/databases/postgresql7/Makefile,v
retrieving revision 1.125
diff -u -r1.125 Makefile
--- Makefile 11 Mar 2004 14:45:42 -0000 1.125
+++ Makefile 24 Apr 2004 10:52:13 -0000
@@ -7,7 +7,7 @@
PORTNAME?= postgresql
PORTVERSION?= 7.4.2
-PORTREVISION?= 0
+PORTREVISION?= 1
CATEGORIES?= databases
MASTER_SITES= ${MASTER_SITE_PGSQL}
MASTER_SITE_SUBDIR= source/v${PORTVERSION}
@@ -76,6 +76,8 @@
PKGMSG= /dev/null
CONFLICTS= postgresql-7* postgresql-devel-*
.else
+USE_RC_SUBR= YES
+RC_SCRIPTS_SUB= PREFIX=${PREFIX} RC_SUBR=${RC_SUBR} PG_PREFIX=${PG_PREFIX}
PKGMESSAGE= ${FILESDIR}/pkg-message.server
PKGMSG= ${PKGMESSAGE}
CONFLICTS= postgresql-client-7* postgresql-devel-*
@@ -210,7 +212,7 @@
${CP} ${PREFIX}/share/postgresql/dot.$i.dist ~pgsql/.$i; \
fi
.endfor
- @ ${SED} -e "s|%%PREFIX%%|${PREFIX}|g; s|%%PG_PREFIX%%|${PG_PREFIX}|g" \
+ @ ${SED} ${RC_SCRIPTS_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
< ${FILESDIR}/pgsql.sh.tmpl \
> ${PREFIX}/etc/rc.d/010.pgsql.sh ;\
${CHMOD} 554 ${PREFIX}/etc/rc.d/010.pgsql.sh ;\
Index: files/dot.cshrc.in
===================================================================
RCS file: files/dot.cshrc.in
diff -N files/dot.cshrc.in
--- files/dot.cshrc.in 11 Apr 2002 04:58:10 -0000 1.2
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,13 +0,0 @@
-set path = ( %%PREFIX%%/bin $path )
-
-setenv PGLIB %%PREFIX%%/lib
-
-# note: PGDATA can be overridden by the -D startup option
-setenv PGDATA $HOME/data
-
-#You might want to set some locale stuff here
-#setenv PGDATESTYLE ISO
-#setenv LC_ALL sv_SE.ISO_8859-1
-
-# if you want to make regression tests use this TZ
-#setenv TZ PST8PDT
Index: files/dot.profile.in
===================================================================
RCS file: files/dot.profile.in
diff -N files/dot.profile.in
--- files/dot.profile.in 4 Jan 2003 01:10:14 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,25 +0,0 @@
-# both new and old layout's paths, but new path first...
-PATH=%%PREFIX%%/bin:${PATH}
-
-PGLIB=%%PREFIX%%/lib
-
-# note: PGDATA can be overridden by the -D startup option
-PGDATA=${HOME}/data
-
-export PATH PGLIB PGDATA
-
-# if you use the periodic script from share/postgresql/502.pgsql, you
-# can set these
-#PGDUMP_ARGS="-b -F c"
-#PGBACKUPDIR=${HOME}/backups
-#PGBACKUP_SAVE_DAYS=7
-#export PGBACKUPDIR PGDUMP_ARGS PGBACKUP_SAVE_DAYS
-
-#You might want to set some locale stuff here
-#PGDATESTYLE=ISO
-#LC_ALL=sv_SE.ISO_8859-1
-#export PGDATESTYLE LC_ALL
-
-# if you want to make regression tests use this TZ
-#TZ=PST8PDT
-#export TZ
Index: files/pgsql.sh.tmpl
===================================================================
RCS file: /home/ncvs/ports/databases/postgresql7/files/pgsql.sh.tmpl,v
retrieving revision 1.16
diff -u -r1.16 pgsql.sh.tmpl
--- files/pgsql.sh.tmpl 4 Dec 2003 12:00:49 -0000 1.16
+++ files/pgsql.sh.tmpl 28 Apr 2004 15:17:50 -0000
@@ -4,48 +4,85 @@
#
# For postmaster startup options, edit $PGDATA/postgresql.conf
#
-# Note that PGDATA is set in ~pgsql/.profile, don't try to manipulate it here!
-#
+
+# PROVIDE: pgsql
+# REQUIRE: DAEMON
+# BEFORE: LOGIN
+# KEYWORD: FreeBSD shutdown
PREFIX=%%PREFIX%%
PGBIN=${PREFIX}/bin
-case $1 in
-start)
- [ -x ${PGBIN}/pg_ctl ] && {
- echo -n ' pgsql'
- su -l pgsql -c \
- "[ -d \${PGDATA} ] && exec ${PREFIX}/bin/pg_ctl start -s -w"
- }
- ;;
-
-stop)
- [ -x ${PGBIN}/pg_ctl ] && {
- echo -n ' pgsql'
- su -l pgsql -c "exec ${PREFIX}/bin/pg_ctl stop -s -m fast"
- }
- ;;
-
-restart)
- [ -x ${PGBIN}/pg_ctl ] && {
- exec su -l pgsql -c "exec ${PREFIX}/bin/pg_ctl restart -s -m fast"
- }
- ;;
-
-reload)
- [ -x ${PGBIN}/pg_ctl ] && {
- exec su -l pgsql -c "exec ${PREFIX}/bin/pg_ctl reload"
- }
- ;;
-
-status)
- [ -x ${PGBIN}/pg_ctl ] && {
- exec su -l pgsql -c "exec ${PREFIX}/bin/pg_ctl status"
- }
- ;;
-
-*)
- echo "usage: `basename $0` {start|stop|restart|reload|status}" >&2
- exit 64
- ;;
-esac
+# Define these pgsql_* variables in one of these files:
+# /etc/rc.conf
+# /etc/rc.conf.local
+# /etc/rc.conf.d/smartd
+#
+# DO NOT CHANGE THESE DEFAULT VALUES HERE
+#
+pgsql_enable="NO"
+pgsql_flags_start="start -s -w"
+pgsql_flags_stop="stop -s -m fast"
+pgsql_flags_restart="restart -s -m fast"
+pgsql_flags_reload="reload"
+pgsql_flags_status="status"
+pgsql_user="pgsql"
+pgsql_datadir="${PREFIX}/pgsql/data"
+extra_commands="reload"
+
+. %%RC_SUBR%%
+
+name="pgsql"
+rcvar=`set_rcvar`
+command="${PGBIN}/pg_ctl"
+pgsql_flags="${pgsql_flags_start} -D ${pgsql_datadir}";
+procname="${PGBIN}/postmaster"
+pidfile="${pgsql_datadir}/postmaster.pid"
+required_files="${pgsql_datadir}/postgresql.conf"
+required_dirs="${pgsql_datadir}"
+stop_cmd="pgsql_stop"
+restart_cmd="pgsql_restart"
+reload_cmd="pgsql_reload"
+status_cmd="pgsql_status"
+
+pgsql_stop () {
+ if [ -z "$rc_pid" ]; then
+ echo "${name} not running? (check $pidfile)."
+ exit 1
+ fi
+ echo "Stopping ${name}."
+ eval "su -m $pgsql_user -c 'sh -c \"${command} ${pgsql_flags_stop} -D ${pgsql_datadir}\"'"
+ _return=$?
+ [ $_return -ne 0 ] && [ -z "$rc_force" ] && return 1
+ wait_for_pids $rc_pid
+}
+
+pgsql_restart () {
+ if [ -z "$rc_pid" ]; then
+ echo "${name} not running? (check $pidfile)."
+ exit 1
+ fi
+ eval "su -m $pgsql_user -c 'sh -c \"${command} ${pgsql_flags_restart} -D ${pgsql_datadir}\"'"
+ _return=$?
+}
+
+pgsql_reload () {
+ if [ -z "$rc_pid" ]; then
+ echo "${name} not running? (check $pidfile)."
+ exit 1
+ fi
+ eval "su -m $pgsql_user -c 'sh -c \"${command} ${pgsql_flags_reload} -D ${pgsql_datadir}\"'"
+ _return=$?
+}
+
+pgsql_status () {
+ if [ -z "$rc_pid" ]; then
+ echo "${name} not running? (check $pidfile)."
+ exit 1
+ fi
+ eval "su -m $pgsql_user -c 'sh -c \"${command} ${pgsql_flags_status} -D ${pgsql_datadir}\"'"
+ _return=$?
+}
+
+load_rc_config $name
+run_rc_command "$1"
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
More information about the freebsd-ports
mailing list