From e778b1d3bc83ac2e24ddc1860083d72ae6759c00 Mon Sep 17 00:00:00 2001 From: Mihai Prica Date: Tue, 11 Jun 2013 13:46:00 +0300 Subject: postgresql: Configured service and added initscript -The postinstall will initialize the database; -The postgres user is needed because postgresql can't be run as root. -The initscript will start the service at start-up. Signed-off-by: Mihai Prica --- .../postgresql/postgresql/postgresql | 69 ++++++++++++++++++++++ .../postgresql/postgresql_8.4.7.bbappend | 36 +++++++++++ 2 files changed, 105 insertions(+) create mode 100644 meta-openstack/recipes-support/postgresql/postgresql/postgresql create mode 100644 meta-openstack/recipes-support/postgresql/postgresql_8.4.7.bbappend (limited to 'meta-openstack/recipes-support/postgresql') diff --git a/meta-openstack/recipes-support/postgresql/postgresql/postgresql b/meta-openstack/recipes-support/postgresql/postgresql/postgresql new file mode 100644 index 0000000..4df4536 --- /dev/null +++ b/meta-openstack/recipes-support/postgresql/postgresql/postgresql @@ -0,0 +1,69 @@ +#!/bin/sh +set -e + +### BEGIN INIT INFO +# Provides: postgresql +# Required-Start: $local_fs $remote_fs $network $time +# Required-Stop: $local_fs $remote_fs $network $time +# Should-Start: $syslog +# Should-Stop: $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: PostgreSQL RDBMS server +### END INIT INFO + +DAEMON=/usr/bin/postmaster +DESC="PostgreSQL RDBMS server" + +start () +{ + echo -n "Starting postgres server..." + if pidof ${DAEMON} > /dev/null; then + echo "already running." + exit 0 + fi + start-stop-daemon --start --quiet --chuid postgres --exec ${DAEMON} --background -- -D /etc/postgresql + if [ $? -eq 0 ]; then + echo "done." + else + echo "failed." + fi +} + +stop () +{ + echo -n "Stopping postgres server..." + if ! pidof ${DAEMON} >/dev/null; then + echo "not running." + exit 0 + fi + start-stop-daemon --stop --quiet --chuid postgres --exec ${DAEMON} + if [ $? -eq 0 ]; then + echo "done." + else + echo "failed." + fi +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + force-reload) + stop + start + ;; + restart) + stop + start + ;; + *) + echo "Usage: $0 {start|stop|force-reload|restart}" + exit 1 + ;; +esac + +exit 0 diff --git a/meta-openstack/recipes-support/postgresql/postgresql_8.4.7.bbappend b/meta-openstack/recipes-support/postgresql/postgresql_8.4.7.bbappend new file mode 100644 index 0000000..5e9a2f7 --- /dev/null +++ b/meta-openstack/recipes-support/postgresql/postgresql_8.4.7.bbappend @@ -0,0 +1,36 @@ +FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" +PRINC := "${@int(PRINC) + 1}" + +SRC_URI += "file://postgresql" + +inherit useradd update-rc.d + +do_install_append() { + install -d ${D}${sysconfdir}/${PN} + chown postgres ${D}${sysconfdir}/${PN} + + install -d ${D}${sysconfdir}/init.d/ + install -m 0755 ${WORKDIR}/postgresql ${D}${sysconfdir}/init.d/postgresql +} + +USERADD_PACKAGES = "${PN}" +GROUPADD_PARAM_${PN} = "--system postgres" +USERADD_PARAM_${PN} = "--system --home /var/lib/postgres -g postgres \ + --no-create-home --shell /bin/false postgres" + +pkg_postinst_${PN} () { + if [ "x$D" != "x" ]; then + exit 1 + fi + + sudo -u postgres initdb -D /etc/${PN}/ + #quick fix + /etc/init.d/postgresql start + sleep 1 + sudo -u postgres createuser -s nova +} + +FILES_${PN} += "${localstatedir}/run/${PN}" + +INITSCRIPT_NAME = "${PN}" +INITSCRIPT_PARAMS = "defaults" -- cgit v1.2.3-54-g00ecf