# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup deprecated 1.0

# Final release was on 2020-02-10
deprecated.upstream_support no

name			postgresql94-server
version			9.4.26
categories		databases
platforms		{darwin any}
maintainers		{jwa @jyrkiwahlstedt}
license			Permissive

set rname       postgresql94
description		run ${rname} as server
long_description	{*}${description}
distfiles       

homepage		https://www.postgresql.org/
master_sites		postgresql

depends_run		port:${rname}

supported_archs     noarch

use_configure	no
build	{}

set libdir		${prefix}/lib/${rname}
set dbdir		${prefix}/var/db/${rname}/defaultdb
set logdir		${prefix}/var/log/${rname}
set dbuser		postgres
set dbgrp		postgres
set dbhome		${prefix}/var/db/${rname}

add_users ${dbuser} shell=/bin/sh group=${dbgrp} \
    home=${dbhome} \
    realname=PostgreSQL-94\ Server

startupitem.create	yes
startupitem.init	\
	"PGCTL=${libdir}/bin/pg_ctl"
startupitem.start	\
	"su ${dbuser} -c \"\${PGCTL} -D \${POSTGRESQL94DATA:=${dbdir}} start -l ${logdir}/postgres.log\""
startupitem.stop	\
"su ${dbuser} -c \"\${PGCTL} -D \${POSTGRESQL94DATA:=${dbdir}} stop -s -m fast\""

destroot {
	xinstall -m 755 -d ${destroot}${logdir}
	system "touch ${destroot}${logdir}/postgres.log"
	system "chown ${dbuser}:${dbgrp} ${destroot}${logdir}/postgres.log"
}

notes "\nTo create a database instance, after install do\n\
		sudo mkdir -p ${dbdir}\n\
		sudo chown ${dbuser}:${dbgrp} ${dbdir}\n\
		sudo su ${dbuser} -c \'cd ${dbhome} && ${libdir}/bin/initdb -D ${dbdir}\' "

livecheck.type	none