diff options
Diffstat (limited to 'meta-openstack/recipes-support')
-rw-r--r-- | meta-openstack/recipes-support/postgresql/postgresql/postgresql | 69 | ||||
-rw-r--r-- | meta-openstack/recipes-support/postgresql/postgresql_8.4.7.bbappend | 36 |
2 files changed, 105 insertions, 0 deletions
diff --git a/meta-openstack/recipes-support/postgresql/postgresql/postgresql b/meta-openstack/recipes-support/postgresql/postgresql/postgresql new file mode 100644 index 00000000..4df4536e --- /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 00000000..5e9a2f75 --- /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" |