diff options
author | jlam <jlam@pkgsrc.org> | 2001-05-14 20:38:56 +0000 |
---|---|---|
committer | jlam <jlam@pkgsrc.org> | 2001-05-14 20:38:56 +0000 |
commit | aac27413ec9487c2473bffe4497f509af486473e (patch) | |
tree | 947e79808556e8c973a4b642c02c676e7b228339 /databases/postgresql-server | |
parent | b12aeeeef06380c5fd6fd5d0f01faf4ea51a6e72 (diff) | |
download | pkgsrc-aac27413ec9487c2473bffe4497f509af486473e.tar.gz |
Move database initialization step from the INSTALL script to a
start_precmd in the pgsql rc.d script. This is more correct, since if
postgresql-server is installed but never used, then no database really
needs to be initialized. As a side-effect, the bulk-builds of postgresql
should now leave less crud in the aftermath of deinstalling postgresql.
Diffstat (limited to 'databases/postgresql-server')
-rw-r--r-- | databases/postgresql-server/files/pgsql.sh | 61 | ||||
-rw-r--r-- | databases/postgresql-server/pkg/INSTALL | 8 |
2 files changed, 51 insertions, 18 deletions
diff --git a/databases/postgresql-server/files/pgsql.sh b/databases/postgresql-server/files/pgsql.sh index cfd658176c7..77c83eea2b4 100644 --- a/databases/postgresql-server/files/pgsql.sh +++ b/databases/postgresql-server/files/pgsql.sh @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: pgsql.sh,v 1.1.1.1 2001/05/14 14:50:26 jlam Exp $ +# $NetBSD: pgsql.sh,v 1.2 2001/05/14 20:38:56 jlam Exp $ # # PostgreSQL database rc.d control script # @@ -8,11 +8,13 @@ # 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" +command_args="-s -D ${PGHOME}/data -l ${PGHOME}/errlog" # pgsql_flags contains options for the PostgreSQL postmaster. # See postmaster(1) for possible options. @@ -20,6 +22,20 @@ command_args="-s -D @PGHOME@/data -l @PGHOME@/errlog" #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 + pgsql_flags="${flags}" +fi + pgsql_doit() { action=$1 @@ -29,7 +45,7 @@ pgsql_doit() fi case ${action} in - start) echo "Starting ${name}." ;; + start) pgsql_start_precmd; echo "Starting ${name}." ;; stop) echo "Stopping ${name}." ;; restart) echo "Restarting ${name}." ;; esac @@ -37,6 +53,26 @@ pgsql_doit() @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} @@ -50,25 +86,28 @@ checkyesno() esac } -if [ -r /etc/rc.conf ] -then - . /etc/rc.conf -else +# force commands are always executed +cmd=${1:-start} +case ${cmd} in +force*) + cmd=${cmd#force} eval ${rcvar}=YES -fi + ;; +esac if checkyesno ${rcvar} then - cmd=${1:-start} - if [ -x ${command} ] then case ${cmd} in + initdb) + ${rcvar}_${cmd} + ;; restart|start|stop|status) ${rcvar}_doit ${cmd} ;; *) - echo 1>&2 "Usage: $0 [restart|start|stop|status]" + echo 1>&2 "Usage: $0 [initdb|restart|start|stop|status]" exit 1 ;; esac diff --git a/databases/postgresql-server/pkg/INSTALL b/databases/postgresql-server/pkg/INSTALL index 0b6dd0b213e..a5d813f679b 100644 --- a/databases/postgresql-server/pkg/INSTALL +++ b/databases/postgresql-server/pkg/INSTALL @@ -1,6 +1,6 @@ #!/bin/sh # -# $NetBSD: INSTALL,v 1.1.1.1 2001/05/14 14:50:25 jlam Exp $ +# $NetBSD: INSTALL,v 1.2 2001/05/14 20:38:56 jlam Exp $ PKGNAME=$1 STAGE=$2 @@ -65,12 +65,6 @@ EOF ;; POST-INSTALL) - ${CAT} << EOF ------------------------------------------------------------------- -Initializing PostgreSQL Databases - this may take a few minutes... ------------------------------------------------------------------- -EOF - ${SU} -m ${USER} -c "${PKG_PREFIX}/bin/initdb -D ${PGHOME}/data" ;; *) |