diff options
| author | Mihai Prica <prica.mihai@gmail.com> | 2013-06-11 13:46:00 +0300 |
|---|---|---|
| committer | Bruce Ashfield <bruce.ashfield@windriver.com> | 2013-08-28 18:41:56 -0400 |
| commit | e778b1d3bc83ac2e24ddc1860083d72ae6759c00 (patch) | |
| tree | c40c19f2041c9f6ab0d4ac5d8ae30f1dde667a63 /meta-openstack | |
| parent | 6b967c23ec5fc8a5397aba6e6365e3dd00250185 (diff) | |
| download | meta-cloud-services-e778b1d3bc83ac2e24ddc1860083d72ae6759c00.tar.gz | |
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')
| -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 0000000..4df4536 --- /dev/null +++ b/meta-openstack/recipes-support/postgresql/postgresql/postgresql | |||
| @@ -0,0 +1,69 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | set -e | ||
| 3 | |||
| 4 | ### BEGIN INIT INFO | ||
| 5 | # Provides: postgresql | ||
| 6 | # Required-Start: $local_fs $remote_fs $network $time | ||
| 7 | # Required-Stop: $local_fs $remote_fs $network $time | ||
| 8 | # Should-Start: $syslog | ||
| 9 | # Should-Stop: $syslog | ||
| 10 | # Default-Start: 2 3 4 5 | ||
| 11 | # Default-Stop: 0 1 6 | ||
| 12 | # Short-Description: PostgreSQL RDBMS server | ||
| 13 | ### END INIT INFO | ||
| 14 | |||
| 15 | DAEMON=/usr/bin/postmaster | ||
| 16 | DESC="PostgreSQL RDBMS server" | ||
| 17 | |||
| 18 | start () | ||
| 19 | { | ||
| 20 | echo -n "Starting postgres server..." | ||
| 21 | if pidof ${DAEMON} > /dev/null; then | ||
| 22 | echo "already running." | ||
| 23 | exit 0 | ||
| 24 | fi | ||
| 25 | start-stop-daemon --start --quiet --chuid postgres --exec ${DAEMON} --background -- -D /etc/postgresql | ||
| 26 | if [ $? -eq 0 ]; then | ||
| 27 | echo "done." | ||
| 28 | else | ||
| 29 | echo "failed." | ||
| 30 | fi | ||
| 31 | } | ||
| 32 | |||
| 33 | stop () | ||
| 34 | { | ||
| 35 | echo -n "Stopping postgres server..." | ||
| 36 | if ! pidof ${DAEMON} >/dev/null; then | ||
| 37 | echo "not running." | ||
| 38 | exit 0 | ||
| 39 | fi | ||
| 40 | start-stop-daemon --stop --quiet --chuid postgres --exec ${DAEMON} | ||
| 41 | if [ $? -eq 0 ]; then | ||
| 42 | echo "done." | ||
| 43 | else | ||
| 44 | echo "failed." | ||
| 45 | fi | ||
| 46 | } | ||
| 47 | |||
| 48 | case "$1" in | ||
| 49 | start) | ||
| 50 | start | ||
| 51 | ;; | ||
| 52 | stop) | ||
| 53 | stop | ||
| 54 | ;; | ||
| 55 | force-reload) | ||
| 56 | stop | ||
| 57 | start | ||
| 58 | ;; | ||
| 59 | restart) | ||
| 60 | stop | ||
| 61 | start | ||
| 62 | ;; | ||
| 63 | *) | ||
| 64 | echo "Usage: $0 {start|stop|force-reload|restart}" | ||
| 65 | exit 1 | ||
| 66 | ;; | ||
| 67 | esac | ||
| 68 | |||
| 69 | 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 @@ | |||
| 1 | FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | ||
| 2 | PRINC := "${@int(PRINC) + 1}" | ||
| 3 | |||
| 4 | SRC_URI += "file://postgresql" | ||
| 5 | |||
| 6 | inherit useradd update-rc.d | ||
| 7 | |||
| 8 | do_install_append() { | ||
| 9 | install -d ${D}${sysconfdir}/${PN} | ||
| 10 | chown postgres ${D}${sysconfdir}/${PN} | ||
| 11 | |||
| 12 | install -d ${D}${sysconfdir}/init.d/ | ||
| 13 | install -m 0755 ${WORKDIR}/postgresql ${D}${sysconfdir}/init.d/postgresql | ||
| 14 | } | ||
| 15 | |||
| 16 | USERADD_PACKAGES = "${PN}" | ||
| 17 | GROUPADD_PARAM_${PN} = "--system postgres" | ||
| 18 | USERADD_PARAM_${PN} = "--system --home /var/lib/postgres -g postgres \ | ||
| 19 | --no-create-home --shell /bin/false postgres" | ||
| 20 | |||
| 21 | pkg_postinst_${PN} () { | ||
| 22 | if [ "x$D" != "x" ]; then | ||
| 23 | exit 1 | ||
| 24 | fi | ||
| 25 | |||
| 26 | sudo -u postgres initdb -D /etc/${PN}/ | ||
| 27 | #quick fix | ||
| 28 | /etc/init.d/postgresql start | ||
| 29 | sleep 1 | ||
| 30 | sudo -u postgres createuser -s nova | ||
| 31 | } | ||
| 32 | |||
| 33 | FILES_${PN} += "${localstatedir}/run/${PN}" | ||
| 34 | |||
| 35 | INITSCRIPT_NAME = "${PN}" | ||
| 36 | INITSCRIPT_PARAMS = "defaults" | ||
