Mercurial > vanilla
changeset 1169:194681a6d42d
databases/postgresql: initial import, closes #2411
author | David Demelier <markand@malikania.fr> |
---|---|
date | Thu, 10 Oct 2019 13:47:08 +0200 |
parents | 4c9819a4c990 |
children | ee9a3ed0343b |
files | Docs/uids.md databases/postgresql/postgresql databases/postgresql/postgresql.sh databases/postgresql/postgresql.sha1 databases/postgresql/postgresql.txt |
diffstat | 5 files changed, 299 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/Docs/uids.md Tue Oct 08 20:35:00 2019 +0200 +++ b/Docs/uids.md Thu Oct 10 13:47:08 2019 +0200 @@ -8,15 +8,16 @@ The following UID/GID are defined: -| uid | gid | package(s) | -|---------------------|---------------------|------------------| -| sshd (100) | sshd (100) | network/openssh | -| polkitd (101) | polkitd (101) | security/polkit | -| pulse (102) | pulse (102) | audio/pulseaudio | -| | pulse-rt (103) | audio/pulseaudio | -| | pulse-access (104) | audio/pulseaudio | -| wesnothd (105) | wesnothd (105) | games/wesnoth | -| mpd (106) | mpd (106) | audio/mpd | -| avahi (107) | avahi (107) | dns/avahi | -| avahi-autoipd (108) | avahi-autoipd (108) | dns/avahi | -| irccd (109) | irccd (109) | irc/irccd | +| uid | gid | package(s) | +|---------------------|---------------------|----------------------| +| sshd (100) | sshd (100) | network/openssh | +| polkitd (101) | polkitd (101) | security/polkit | +| pulse (102) | pulse (102) | audio/pulseaudio | +| | pulse-rt (103) | audio/pulseaudio | +| | pulse-access (104) | audio/pulseaudio | +| wesnothd (105) | wesnothd (105) | games/wesnoth | +| mpd (106) | mpd (106) | audio/mpd | +| avahi (107) | avahi (107) | dns/avahi | +| avahi-autoipd (108) | avahi-autoipd (108) | dns/avahi | +| irccd (109) | irccd (109) | irc/irccd | +| postgresql (110) | postgresql (110) | databases/postgresql |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/databases/postgresql/postgresql Thu Oct 10 13:47:08 2019 +0200 @@ -0,0 +1,97 @@ +#!/bin/busybox sh +# +# /etc/rc.d/postgresql -- run control script for postgresql +# +# Copyright (c) 2019 David Demelier <markand@malikania.fr> +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +if [ -f /etc/rc.conf ]; then + . /etc/rc.conf +fi + +: ${POSTGRESQL_PID:=/var/run/postgresql/postgresql.pid} +: ${POSTGRESQL_USER:=postgresql} +: ${POSTGRESQL_GROUP:=postgresql} +: ${POSTGRESQL_DIR:=/var/db/postgresql} +: ${POSTGRESQL_CMD:=/bin/postgres} +: ${POSTGRESQL_ARGS:=-D ${POSTGRESQL_DIR}} + +postgresql_start() +{ + mkdir -p $(dirname $POSTGRESQL_PID) + + if [ -s $POSTGRESQL_PID ]; then + echo "postgresql is already running with pid: $(cat $POSTGRESQL_PID)" + else + echo "Starting postgresql: $POSTGRESQL_CMD $POSTGRESQL_ARGS" + start-stop-daemon \ + -Sbmvp $POSTGRESQL_PID \ + -c $POSTGRESQL_USER:$POSTGRESQL_GROUP \ + -x $POSTGRESQL_CMD -- $POSTGRESQL_ARGS + fi +} + +postgresql_init() +{ + mkdir -p $POSTGRESQL_DIR + chown $POSTGRESQL_USER:$POSTGRESQL_GROUP $POSTGRESQL_DIR + busybox su $POSTGRESQL_USER -lp -c "pg_ctl -D $POSTGRESQL_DIR initdb" +} + +postgresql_status() +{ + if [ -s $POSTGRESQL_PID ]; then + echo "postgresql is running with pid: $(cat $POSTGRESQL_PID)" + else + echo "postgresql is not running" + fi +} + +postgresql_stop() +{ + if [ -s $POSTGRESQL_PID ]; then + echo "Stopping postgresql." + start-stop-daemon -Kqp $POSTGRESQL_PID + rm -f $POSTGRESQL_PID + fi +} + +postgresql_restart() +{ + postgresql_stop + sleep 3 + postgresql_start +} + +case $1 in +init) + postgresql_init + ;; +start) + postgresql_start + ;; +status) + postgresql_status + ;; +stop) + postgresql_stop + ;; +restart) + postgresql_restart + ;; +*) + echo "usage: $(basename $0) init|restart|start|status|stop" + ;; +esac
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/databases/postgresql/postgresql.sh Thu Oct 10 13:47:08 2019 +0200 @@ -0,0 +1,178 @@ +#!/bin/sh +# +# Copyright (c) 2019 David Demelier <markand@malikania.fr> +# +# Permission to use, copy, modify, and/or distribute this software for any +# purpose with or without fee is hereby granted, provided that the above +# copyright notice and this permission notice appear in all copies. +# +# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +# + +# TODO: add KERBEROS, SELINUX option. + +PKGNAME=postgresql +PKGVERSION=12.0 +PKGREVISION=1 +PKGLICENSE="CUSTOM" +PKGSUMMARY="popular object-relational database management system" +PKGDOWNLOAD="https://ftp.postgresql.org/pub/source/v$PKGVERSION/$PKGNAME-$PKGVERSION.tar.gz" +PKGDEPENDS="" +PKGOPTIONS="COMPLETION ICU LLVM NLS PAM PERL PYTHON SSL TCL XML XSLT ZLIB" +PKGUIDS="postgresql:110" +PKGGIDS="postgresql:110" +PKGPROTECT="etc/rc.d/postgresql" + +: ${CHOST:=$(uname -m)-linux-musl} +: ${CBUILD:=$(uname -m)-linux-musl} +: ${CC:=clang} +: ${CFLAGS:=-O2} +: ${CXX:=clang++} +: ${CXXFLAGS:=-O2} +: ${LDFLAGS:=} +: ${LIBS:=} +: ${COMPLETION:=yes} # Note: can be readline (or yes) or libedit. +: ${ICU:=no} +: ${LLVM:=no} +: ${NLS:=yes} +: ${PAM:=no} +: ${PERL:=no} +: ${PYTHON:=no} +: ${SSL:=yes} # Note: SSL support through libressl. +: ${TCL:=no} +: ${XML:=no} # Note: XML: support through libxml2. +: ${XSLT:=no} +: ${ZLIB:=yes} + +case "$COMPLETION" in +"readline"|"yes") + PKGDEPENDS="readline $PKGDEPENDS" + with_completion="--with-readline" + ;; +"libedit") + PKGDEPENDS="libedit $PKGDEPENDS" + with_completion="--without-readline --with-libedit-preferred" + ;; +*) + with_completion="--without-readline" + ;; +esac + +if [ "$ICU" = "yes" ]; then + PKGDEPENDS="icu $PKGDEPENDS" + with_icu="--with-icu" +else + with_icu="--without-icu" +fi + +if [ "$LLVM" = "yes" ]; then + PKGDEPENDS="llvm $PKGDEPENDS" + with_llvm="--with-llvm" +else + with_llvm="--without-llvm" +fi + +if [ "$NLS" = "yes" ]; then + PKGDEPENDS="gettext $PKGDEPENDS" + with_nls="--enable-nls" +else + with_nls="--disable-nls" +fi + +if [ "$PAM" = "yes" ]; then + PKGDEPENDS="linux-pam $PKGDEPENDS" + with_pam="--with-pam" +else + with_pam="--without-pam" +fi + +if [ "$PERL" = "yes" ]; then + PKGDEPENDS="perl $PKGDEPENDS" + with_perl="--with-perl" +else + with_perl="--without-perl" +fi + +if [ "$PYTHON" = "yes" ]; then + PKGDEPENDS="python $PKGDEPENDS" + with_python="--with-python" +else + with_python="--without-python" +fi + +if [ "$SSL" = "yes" ]; then + PKGDEPENDS="libressl $PKGDEPENDS" + with_ssl="--with-openssl" +else + with_ssl="--without-openssl" +fi + +if [ "$TCL" = "yes" ]; then + PKGDEPENDS="tcl $PKGDEPENDS" + with_tcl="--with-tcl" +else + with_tcl="--without-tcl" +fi + +if [ "$XML" = "yes" ]; then + PKGDEPENDS="libxml2 $PKGDEPENDS" + with_xml="--with-libxml" +else + with_xml="--without-libxml" +fi + +if [ "$XSLT" = "yes" ]; then + PKGDEPENDS="libxslt $PKGDEPENDS" + with_xslt="--with-libxslt" +else + with_xslt="--without-libxslt" +fi + +if [ "$ZLIB" = "yes" ]; then + PKGDEPENDS="zlib $PKGDEPENDS" + with_zlib="--with-zlib" +else + with_zlib="--without-zlib" +fi + +build() +{ + rm -rf $PKGNAME-$PKGVERSION + tar xvf $PKGNAME-$PKGVERSION.tar.gz + cd $PKGNAME-$PKGVERSION + + CC="$CC" \ + CFLAGS="$CFLAGS" \ + CXX="$CXX" \ + CXXFLAGS="$CXXFLAGS" \ + LDFLAGS="$LDFLAGS" \ + LIBS="$LIBS" \ + ./configure \ + --build=$CBUILD \ + --host=$CHOST \ + --prefix= \ + $with_completion \ + $with_icu \ + $with_llvm \ + $with_nls \ + $with_pam \ + $with_perl \ + $with_python \ + $with_ssl \ + $with_tcl \ + $with_xml \ + $with_xslt \ + $with_zlib + make + make install DESTDIR=$DESTDIR + install -Dm0644 ../postgresql $DESTDIR/etc/rc.d/postgresql + + cd .. + rm -rf $PKGNAME-$PKGVERSION +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/databases/postgresql/postgresql.sha1 Thu Oct 10 13:47:08 2019 +0200 @@ -0,0 +1,1 @@ +3487c6e6a3acb2e03a74c3b6ccedff7d5d658caf postgresql-12.0.tar.gz
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/databases/postgresql/postgresql.txt Thu Oct 10 13:47:08 2019 +0200 @@ -0,0 +1,10 @@ +The following services have been installed: + + /etc/rc.d/postgresql + +Make sure to set executable permission on the files and enable them in the +SERVICES configuration variable (see rc.conf(5) for more information). + +Before running PostgreSQL, make sure to initialize the database before: + + /etc/rc.d/postgresql init