aboutsummaryrefslogtreecommitdiffstats
path: root/meta-openstack/recipes-support
diff options
context:
space:
mode:
authorMihai Prica <prica.mihai@gmail.com>2013-06-11 13:46:00 +0300
committerBruce Ashfield <bruce.ashfield@windriver.com>2013-08-28 18:41:56 -0400
commite778b1d3bc83ac2e24ddc1860083d72ae6759c00 (patch)
treec40c19f2041c9f6ab0d4ac5d8ae30f1dde667a63 /meta-openstack/recipes-support
parent6b967c23ec5fc8a5397aba6e6365e3dd00250185 (diff)
downloadmeta-cloud-services-e778b1d3bc83ac2e24ddc1860083d72ae6759c00.tar.gz
meta-cloud-services-e778b1d3bc83ac2e24ddc1860083d72ae6759c00.tar.bz2
meta-cloud-services-e778b1d3bc83ac2e24ddc1860083d72ae6759c00.zip
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 <prica.mihai@gmail.com>
Diffstat (limited to 'meta-openstack/recipes-support')
-rw-r--r--meta-openstack/recipes-support/postgresql/postgresql/postgresql69
-rw-r--r--meta-openstack/recipes-support/postgresql/postgresql_8.4.7.bbappend36
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 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"