All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] postgresql: move initdb to postgresql-setup
@ 2014-09-16  9:36 Chong Lu
  2014-09-16  9:36 ` [PATCH 2/2] postgresql: add systemd unit file Chong Lu
  2014-09-16  9:41 ` [PATCH 1/2] postgresql: move initdb to postgresql-setup Chong Lu
  0 siblings, 2 replies; 4+ messages in thread
From: Chong Lu @ 2014-09-16  9:36 UTC (permalink / raw)
  To: openembedded-devel

We shouldn't use sysvinit init script to initialize database when use systemd
as the init manager, so split initdb function to postgresql-setup.
Before starting postgresql server, we can use "postgresql-setup initdb" to
initialize the database cluster.

Signed-off-by: Chong Lu <Chong.Lu@windriver.com>
---
 .../postgresql/files/postgresql-setup              | 73 ++++++++++++++++++++++
 .../postgresql/files/postgresql.init               | 52 +--------------
 meta-oe/recipes-support/postgresql/postgresql.inc  |  2 +
 3 files changed, 77 insertions(+), 50 deletions(-)
 create mode 100644 meta-oe/recipes-support/postgresql/files/postgresql-setup

diff --git a/meta-oe/recipes-support/postgresql/files/postgresql-setup b/meta-oe/recipes-support/postgresql/files/postgresql-setup
new file mode 100644
index 0000000..75bb01e
--- /dev/null
+++ b/meta-oe/recipes-support/postgresql/files/postgresql-setup
@@ -0,0 +1,73 @@
+#!/bin/sh
+#
+# postgresql-setup      Initialization operation for PostgreSQL
+
+# For SELinux we need to use 'runuser' not 'su'
+if [ -x /sbin/runuser ]
+then
+    SU=runuser
+else
+    SU=su
+fi
+
+PGENGINE=/usr/bin
+PGDATA=/var/lib/postgresql/data
+PGLOG=/var/lib/postgresql/pgstartup.log
+script_result=0
+
+initdb(){
+    if [ -f "$PGDATA/PG_VERSION" ]
+    then
+	echo -n "Data directory is not empty!"
+	echo -n " [FAILED] "
+	echo
+	script_result=1
+    else
+	echo -n "Initializing database: "
+	if [ ! -e "$PGDATA" -a ! -h "$PGDATA" ]
+	then
+		mkdir -p "$PGDATA" || exit 1
+		chown postgres:postgres "$PGDATA"
+		chmod go-rwx "$PGDATA"
+	fi
+	# Clean up SELinux tagging for PGDATA
+	[ -x /sbin/restorecon ] && /sbin/restorecon "$PGDATA"
+
+	# Make sure the startup-time log file is OK, too
+	if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ]
+	then
+		touch "$PGLOG" || exit 1
+		chown postgres:postgres "$PGLOG"
+		chmod go-rwx "$PGLOG"
+		[ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG"
+	fi
+
+	# Initialize the database
+	$SU -l postgres -c "$PGENGINE/initdb --pgdata='$PGDATA' --auth='ident'" >> "$PGLOG" 2>&1 < /dev/null
+
+	# Create directory for postmaster log
+	mkdir "$PGDATA/pg_log"
+	chown postgres:postgres "$PGDATA/pg_log"
+	chmod go-rwx "$PGDATA/pg_log"
+
+	if [ -f "$PGDATA/PG_VERSION" ]
+	then
+	    echo -n " [ OK ] "
+	else
+	    echo -n " [FAILED] "
+	    script_result=1
+	fi
+	echo
+    fi
+}
+
+case "$1" in
+  initdb)
+	initdb
+	;;
+  *)
+	echo "Usage: $0 initdb"
+	exit 2
+esac
+
+exit $script_result
diff --git a/meta-oe/recipes-support/postgresql/files/postgresql.init b/meta-oe/recipes-support/postgresql/files/postgresql.init
index ab46477..4a4f0cd 100644
--- a/meta-oe/recipes-support/postgresql/files/postgresql.init
+++ b/meta-oe/recipes-support/postgresql/files/postgresql.init
@@ -101,7 +101,7 @@ start(){
 	else
 		# No existing PGDATA! Warn the user to initdb it.
 		echo
-                echo "$PGDATA is missing. Use \"service postgresql initdb\" to initialize the cluster first."
+                echo "$PGDATA is missing. Use \"postgresql-setup initdb\" to initialize the cluster first."
 		echo -n " [FAILED] "
 		echo
 		exit 1
@@ -160,51 +160,6 @@ reload(){
     $SU -l postgres -c "$PGENGINE/pg_ctl reload -D '$PGDATA' -s" > /dev/null 2>&1 < /dev/null
 }
 
-initdb(){
-    if [ -f "$PGDATA/PG_VERSION" ]
-    then
-	echo -n "Data directory is not empty!"
-	echo -n " [FAILED] "
-	echo
-	script_result=1
-    else
-	echo -n $"Initializing database: "
-	if [ ! -e "$PGDATA" -a ! -h "$PGDATA" ]
-	then
-		mkdir -p "$PGDATA" || exit 1
-		chown postgres:postgres "$PGDATA"
-		chmod go-rwx "$PGDATA"
-	fi
-	# Clean up SELinux tagging for PGDATA
-	[ -x /sbin/restorecon ] && /sbin/restorecon "$PGDATA"
-
-	# Make sure the startup-time log file is OK, too
-	if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ]
-	then
-		touch "$PGLOG" || exit 1
-		chown postgres:postgres "$PGLOG"
-		chmod go-rwx "$PGLOG"
-		[ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG"
-	fi
-
-	# Initialize the database
-	$SU -l postgres -c "$PGENGINE/initdb --pgdata='$PGDATA' --auth='ident'" >> "$PGLOG" 2>&1 < /dev/null
-
-	# Create directory for postmaster log
-	mkdir "$PGDATA/pg_log"
-	chown postgres:postgres "$PGDATA/pg_log"
-	chmod go-rwx "$PGDATA/pg_log"
-
-	if [ -f "$PGDATA/PG_VERSION" ]
-	then
-	    echo -n " [ OK ] "
-	else
-	    echo -n " [FAILED] "
-	    script_result=1
-	fi
-	echo
-    fi
-}
 
 # See how we were called.
 case "$1" in
@@ -230,11 +185,8 @@ case "$1" in
   force-reload)
 	restart
 	;;
-  initdb)
-	initdb
-	;;
   *)
-	echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|initdb}"
+	echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
 	exit 2
 esac
 
diff --git a/meta-oe/recipes-support/postgresql/postgresql.inc b/meta-oe/recipes-support/postgresql/postgresql.inc
index a9b4a01..774c8fd 100644
--- a/meta-oe/recipes-support/postgresql/postgresql.inc
+++ b/meta-oe/recipes-support/postgresql/postgresql.inc
@@ -29,6 +29,7 @@ SRC_URI = "http://ftp.postgresql.org/pub/source/v${PV}/${BP}.tar.bz2 \
            file://postgresql-bashprofile \
            file://postgresql.pam \
            file://0001-Use-pkg-config-for-libxml2-detection.patch \
+           file://postgresql-setup \
 "
 
 LEAD_SONAME = "libpq.so"
@@ -171,6 +172,7 @@ do_install_append() {
     install -d ${D}${sysconfdir}/init.d
     install -m 0755 ${WORKDIR}/${BPN}.init ${D}${sysconfdir}/init.d/${BPN}-server
     sed -i -e "s/^PGVERSION=.*$/PGVERSION=${PV}/g" ${D}${sysconfdir}/init.d/${BPN}-server
+    install -m 0755 ${WORKDIR}/${BPN}-setup ${D}${bindir}/${BPN}-setup
     install -d -m 700 ${D}${localstatedir}/lib/${BPN}/data
     install -d -m 700 ${D}${localstatedir}/lib/${BPN}/backups
     install -m 644 ${WORKDIR}/${BPN}-bashprofile ${D}${localstatedir}/lib/${BPN}/.bash_profile
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] postgresql: add systemd unit file
  2014-09-16  9:36 [PATCH 1/2] postgresql: move initdb to postgresql-setup Chong Lu
@ 2014-09-16  9:36 ` Chong Lu
  2014-09-16  9:42   ` Chong Lu
  2014-09-16  9:41 ` [PATCH 1/2] postgresql: move initdb to postgresql-setup Chong Lu
  1 sibling, 1 reply; 4+ messages in thread
From: Chong Lu @ 2014-09-16  9:36 UTC (permalink / raw)
  To: openembedded-devel

Add systemd unit file for postgresql.
When 'sysvinit' and 'systemd' are both in DISTRO_FEATURES, we need to prevent
the init script from running via systemd.

Signed-off-by: Chong Lu <Chong.Lu@windriver.com>
---
 .../postgresql/files/postgresql.service            | 27 ++++++++++++++++++++++
 meta-oe/recipes-support/postgresql/postgresql.inc  | 22 +++++++++++++++++-
 2 files changed, 48 insertions(+), 1 deletion(-)
 create mode 100644 meta-oe/recipes-support/postgresql/files/postgresql.service

diff --git a/meta-oe/recipes-support/postgresql/files/postgresql.service b/meta-oe/recipes-support/postgresql/files/postgresql.service
new file mode 100644
index 0000000..4ec959e
--- /dev/null
+++ b/meta-oe/recipes-support/postgresql/files/postgresql.service
@@ -0,0 +1,27 @@
+[Unit]
+Description=PostgreSQL database server
+After=network.target
+
+[Service]
+Type=forking
+User=postgres
+Group=postgres
+
+# Port number for server to listen on
+Environment=PGPORT=5432
+
+# Location of database directory
+Environment=PGDATA=/var/lib/postgresql/data
+
+# Disable OOM kill on the postmaster
+OOMScoreAdjust=-17
+
+ExecStart=@BINDIR@/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300
+ExecStop=@BINDIR@/pg_ctl stop -D ${PGDATA} -s -m fast
+ExecReload=@BINDIR@/pg_ctl reload -D ${PGDATA} -s
+
+# Give a reasonable amount of time for the server to start up/shut down
+TimeoutSec=300
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta-oe/recipes-support/postgresql/postgresql.inc b/meta-oe/recipes-support/postgresql/postgresql.inc
index 774c8fd..d45f4b5 100644
--- a/meta-oe/recipes-support/postgresql/postgresql.inc
+++ b/meta-oe/recipes-support/postgresql/postgresql.inc
@@ -30,6 +30,7 @@ SRC_URI = "http://ftp.postgresql.org/pub/source/v${PV}/${BP}.tar.bz2 \
            file://postgresql.pam \
            file://0001-Use-pkg-config-for-libxml2-detection.patch \
            file://postgresql-setup \
+           file://postgresql.service \
 "
 
 LEAD_SONAME = "libpq.so"
@@ -37,7 +38,20 @@ LEAD_SONAME = "libpq.so"
 # LDFLAGS for shared libraries
 export LDFLAGS_SL = "${LDFLAGS}"
 
-inherit autotools pkgconfig perlnative pythonnative useradd update-rc.d
+inherit autotools pkgconfig perlnative pythonnative useradd update-rc.d systemd
+
+SYSTEMD_SERVICE_${PN} = "postgresql.service"
+SYSTEMD_AUTO_ENABLE_${PN} = "disable"
+
+DEPENDS_append = " ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd-systemctl-native', '', d)}"
+pkg_postinst_${PN} () {
+    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd sysvinit', 'true', 'false', d)}; then
+        if [ -n "$D" ]; then
+            OPTS="--root=$D"
+        fi
+        systemctl $OPTS mask postgresql-server.service
+    fi
+}
 
 enable_pam = "${@base_contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}"
 PACKAGECONFIG ??= "${enable_pam} openssl python uuid libxml tcl nls libxml perl"
@@ -184,6 +198,12 @@ do_install_append() {
         install -d ${D}${sysconfdir}/pam.d
         install -m 644 ${WORKDIR}/postgresql.pam ${D}${sysconfdir}/pam.d/postgresql
     fi
+
+    # Install systemd unit files
+    install -d ${D}${systemd_unitdir}/system
+    install -m 0644 ${WORKDIR}/postgresql.service ${D}${systemd_unitdir}/system
+    sed -i -e 's,@BINDIR@,${bindir},g' \
+        ${D}${systemd_unitdir}/system/postgresql.service
 }
 
 SSTATE_SCAN_FILES += "Makefile.global"
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] postgresql: move initdb to postgresql-setup
  2014-09-16  9:36 [PATCH 1/2] postgresql: move initdb to postgresql-setup Chong Lu
  2014-09-16  9:36 ` [PATCH 2/2] postgresql: add systemd unit file Chong Lu
@ 2014-09-16  9:41 ` Chong Lu
  1 sibling, 0 replies; 4+ messages in thread
From: Chong Lu @ 2014-09-16  9:41 UTC (permalink / raw)
  To: openembedded-devel

For meta-oe layer. Thanks

//Chong

On 09/16/2014 05:36 PM, Chong Lu wrote:
> We shouldn't use sysvinit init script to initialize database when use systemd
> as the init manager, so split initdb function to postgresql-setup.
> Before starting postgresql server, we can use "postgresql-setup initdb" to
> initialize the database cluster.
>
> Signed-off-by: Chong Lu <Chong.Lu@windriver.com>
> ---
>   .../postgresql/files/postgresql-setup              | 73 ++++++++++++++++++++++
>   .../postgresql/files/postgresql.init               | 52 +--------------
>   meta-oe/recipes-support/postgresql/postgresql.inc  |  2 +
>   3 files changed, 77 insertions(+), 50 deletions(-)
>   create mode 100644 meta-oe/recipes-support/postgresql/files/postgresql-setup
>
> diff --git a/meta-oe/recipes-support/postgresql/files/postgresql-setup b/meta-oe/recipes-support/postgresql/files/postgresql-setup
> new file mode 100644
> index 0000000..75bb01e
> --- /dev/null
> +++ b/meta-oe/recipes-support/postgresql/files/postgresql-setup
> @@ -0,0 +1,73 @@
> +#!/bin/sh
> +#
> +# postgresql-setup      Initialization operation for PostgreSQL
> +
> +# For SELinux we need to use 'runuser' not 'su'
> +if [ -x /sbin/runuser ]
> +then
> +    SU=runuser
> +else
> +    SU=su
> +fi
> +
> +PGENGINE=/usr/bin
> +PGDATA=/var/lib/postgresql/data
> +PGLOG=/var/lib/postgresql/pgstartup.log
> +script_result=0
> +
> +initdb(){
> +    if [ -f "$PGDATA/PG_VERSION" ]
> +    then
> +	echo -n "Data directory is not empty!"
> +	echo -n " [FAILED] "
> +	echo
> +	script_result=1
> +    else
> +	echo -n "Initializing database: "
> +	if [ ! -e "$PGDATA" -a ! -h "$PGDATA" ]
> +	then
> +		mkdir -p "$PGDATA" || exit 1
> +		chown postgres:postgres "$PGDATA"
> +		chmod go-rwx "$PGDATA"
> +	fi
> +	# Clean up SELinux tagging for PGDATA
> +	[ -x /sbin/restorecon ] && /sbin/restorecon "$PGDATA"
> +
> +	# Make sure the startup-time log file is OK, too
> +	if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ]
> +	then
> +		touch "$PGLOG" || exit 1
> +		chown postgres:postgres "$PGLOG"
> +		chmod go-rwx "$PGLOG"
> +		[ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG"
> +	fi
> +
> +	# Initialize the database
> +	$SU -l postgres -c "$PGENGINE/initdb --pgdata='$PGDATA' --auth='ident'" >> "$PGLOG" 2>&1 < /dev/null
> +
> +	# Create directory for postmaster log
> +	mkdir "$PGDATA/pg_log"
> +	chown postgres:postgres "$PGDATA/pg_log"
> +	chmod go-rwx "$PGDATA/pg_log"
> +
> +	if [ -f "$PGDATA/PG_VERSION" ]
> +	then
> +	    echo -n " [ OK ] "
> +	else
> +	    echo -n " [FAILED] "
> +	    script_result=1
> +	fi
> +	echo
> +    fi
> +}
> +
> +case "$1" in
> +  initdb)
> +	initdb
> +	;;
> +  *)
> +	echo "Usage: $0 initdb"
> +	exit 2
> +esac
> +
> +exit $script_result
> diff --git a/meta-oe/recipes-support/postgresql/files/postgresql.init b/meta-oe/recipes-support/postgresql/files/postgresql.init
> index ab46477..4a4f0cd 100644
> --- a/meta-oe/recipes-support/postgresql/files/postgresql.init
> +++ b/meta-oe/recipes-support/postgresql/files/postgresql.init
> @@ -101,7 +101,7 @@ start(){
>   	else
>   		# No existing PGDATA! Warn the user to initdb it.
>   		echo
> -                echo "$PGDATA is missing. Use \"service postgresql initdb\" to initialize the cluster first."
> +                echo "$PGDATA is missing. Use \"postgresql-setup initdb\" to initialize the cluster first."
>   		echo -n " [FAILED] "
>   		echo
>   		exit 1
> @@ -160,51 +160,6 @@ reload(){
>       $SU -l postgres -c "$PGENGINE/pg_ctl reload -D '$PGDATA' -s" > /dev/null 2>&1 < /dev/null
>   }
>   
> -initdb(){
> -    if [ -f "$PGDATA/PG_VERSION" ]
> -    then
> -	echo -n "Data directory is not empty!"
> -	echo -n " [FAILED] "
> -	echo
> -	script_result=1
> -    else
> -	echo -n $"Initializing database: "
> -	if [ ! -e "$PGDATA" -a ! -h "$PGDATA" ]
> -	then
> -		mkdir -p "$PGDATA" || exit 1
> -		chown postgres:postgres "$PGDATA"
> -		chmod go-rwx "$PGDATA"
> -	fi
> -	# Clean up SELinux tagging for PGDATA
> -	[ -x /sbin/restorecon ] && /sbin/restorecon "$PGDATA"
> -
> -	# Make sure the startup-time log file is OK, too
> -	if [ ! -e "$PGLOG" -a ! -h "$PGLOG" ]
> -	then
> -		touch "$PGLOG" || exit 1
> -		chown postgres:postgres "$PGLOG"
> -		chmod go-rwx "$PGLOG"
> -		[ -x /sbin/restorecon ] && /sbin/restorecon "$PGLOG"
> -	fi
> -
> -	# Initialize the database
> -	$SU -l postgres -c "$PGENGINE/initdb --pgdata='$PGDATA' --auth='ident'" >> "$PGLOG" 2>&1 < /dev/null
> -
> -	# Create directory for postmaster log
> -	mkdir "$PGDATA/pg_log"
> -	chown postgres:postgres "$PGDATA/pg_log"
> -	chmod go-rwx "$PGDATA/pg_log"
> -
> -	if [ -f "$PGDATA/PG_VERSION" ]
> -	then
> -	    echo -n " [ OK ] "
> -	else
> -	    echo -n " [FAILED] "
> -	    script_result=1
> -	fi
> -	echo
> -    fi
> -}
>   
>   # See how we were called.
>   case "$1" in
> @@ -230,11 +185,8 @@ case "$1" in
>     force-reload)
>   	restart
>   	;;
> -  initdb)
> -	initdb
> -	;;
>     *)
> -	echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|initdb}"
> +	echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
>   	exit 2
>   esac
>   
> diff --git a/meta-oe/recipes-support/postgresql/postgresql.inc b/meta-oe/recipes-support/postgresql/postgresql.inc
> index a9b4a01..774c8fd 100644
> --- a/meta-oe/recipes-support/postgresql/postgresql.inc
> +++ b/meta-oe/recipes-support/postgresql/postgresql.inc
> @@ -29,6 +29,7 @@ SRC_URI = "http://ftp.postgresql.org/pub/source/v${PV}/${BP}.tar.bz2 \
>              file://postgresql-bashprofile \
>              file://postgresql.pam \
>              file://0001-Use-pkg-config-for-libxml2-detection.patch \
> +           file://postgresql-setup \
>   "
>   
>   LEAD_SONAME = "libpq.so"
> @@ -171,6 +172,7 @@ do_install_append() {
>       install -d ${D}${sysconfdir}/init.d
>       install -m 0755 ${WORKDIR}/${BPN}.init ${D}${sysconfdir}/init.d/${BPN}-server
>       sed -i -e "s/^PGVERSION=.*$/PGVERSION=${PV}/g" ${D}${sysconfdir}/init.d/${BPN}-server
> +    install -m 0755 ${WORKDIR}/${BPN}-setup ${D}${bindir}/${BPN}-setup
>       install -d -m 700 ${D}${localstatedir}/lib/${BPN}/data
>       install -d -m 700 ${D}${localstatedir}/lib/${BPN}/backups
>       install -m 644 ${WORKDIR}/${BPN}-bashprofile ${D}${localstatedir}/lib/${BPN}/.bash_profile



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] postgresql: add systemd unit file
  2014-09-16  9:36 ` [PATCH 2/2] postgresql: add systemd unit file Chong Lu
@ 2014-09-16  9:42   ` Chong Lu
  0 siblings, 0 replies; 4+ messages in thread
From: Chong Lu @ 2014-09-16  9:42 UTC (permalink / raw)
  To: openembedded-devel

For meta-oe layer. Thanks

//Chong

On 09/16/2014 05:36 PM, Chong Lu wrote:
> Add systemd unit file for postgresql.
> When 'sysvinit' and 'systemd' are both in DISTRO_FEATURES, we need to prevent
> the init script from running via systemd.
>
> Signed-off-by: Chong Lu <Chong.Lu@windriver.com>
> ---
>   .../postgresql/files/postgresql.service            | 27 ++++++++++++++++++++++
>   meta-oe/recipes-support/postgresql/postgresql.inc  | 22 +++++++++++++++++-
>   2 files changed, 48 insertions(+), 1 deletion(-)
>   create mode 100644 meta-oe/recipes-support/postgresql/files/postgresql.service
>
> diff --git a/meta-oe/recipes-support/postgresql/files/postgresql.service b/meta-oe/recipes-support/postgresql/files/postgresql.service
> new file mode 100644
> index 0000000..4ec959e
> --- /dev/null
> +++ b/meta-oe/recipes-support/postgresql/files/postgresql.service
> @@ -0,0 +1,27 @@
> +[Unit]
> +Description=PostgreSQL database server
> +After=network.target
> +
> +[Service]
> +Type=forking
> +User=postgres
> +Group=postgres
> +
> +# Port number for server to listen on
> +Environment=PGPORT=5432
> +
> +# Location of database directory
> +Environment=PGDATA=/var/lib/postgresql/data
> +
> +# Disable OOM kill on the postmaster
> +OOMScoreAdjust=-17
> +
> +ExecStart=@BINDIR@/pg_ctl start -D ${PGDATA} -s -o "-p ${PGPORT}" -w -t 300
> +ExecStop=@BINDIR@/pg_ctl stop -D ${PGDATA} -s -m fast
> +ExecReload=@BINDIR@/pg_ctl reload -D ${PGDATA} -s
> +
> +# Give a reasonable amount of time for the server to start up/shut down
> +TimeoutSec=300
> +
> +[Install]
> +WantedBy=multi-user.target
> diff --git a/meta-oe/recipes-support/postgresql/postgresql.inc b/meta-oe/recipes-support/postgresql/postgresql.inc
> index 774c8fd..d45f4b5 100644
> --- a/meta-oe/recipes-support/postgresql/postgresql.inc
> +++ b/meta-oe/recipes-support/postgresql/postgresql.inc
> @@ -30,6 +30,7 @@ SRC_URI = "http://ftp.postgresql.org/pub/source/v${PV}/${BP}.tar.bz2 \
>              file://postgresql.pam \
>              file://0001-Use-pkg-config-for-libxml2-detection.patch \
>              file://postgresql-setup \
> +           file://postgresql.service \
>   "
>   
>   LEAD_SONAME = "libpq.so"
> @@ -37,7 +38,20 @@ LEAD_SONAME = "libpq.so"
>   # LDFLAGS for shared libraries
>   export LDFLAGS_SL = "${LDFLAGS}"
>   
> -inherit autotools pkgconfig perlnative pythonnative useradd update-rc.d
> +inherit autotools pkgconfig perlnative pythonnative useradd update-rc.d systemd
> +
> +SYSTEMD_SERVICE_${PN} = "postgresql.service"
> +SYSTEMD_AUTO_ENABLE_${PN} = "disable"
> +
> +DEPENDS_append = " ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'systemd-systemctl-native', '', d)}"
> +pkg_postinst_${PN} () {
> +    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd sysvinit', 'true', 'false', d)}; then
> +        if [ -n "$D" ]; then
> +            OPTS="--root=$D"
> +        fi
> +        systemctl $OPTS mask postgresql-server.service
> +    fi
> +}
>   
>   enable_pam = "${@base_contains('DISTRO_FEATURES', 'pam', 'pam', '', d)}"
>   PACKAGECONFIG ??= "${enable_pam} openssl python uuid libxml tcl nls libxml perl"
> @@ -184,6 +198,12 @@ do_install_append() {
>           install -d ${D}${sysconfdir}/pam.d
>           install -m 644 ${WORKDIR}/postgresql.pam ${D}${sysconfdir}/pam.d/postgresql
>       fi
> +
> +    # Install systemd unit files
> +    install -d ${D}${systemd_unitdir}/system
> +    install -m 0644 ${WORKDIR}/postgresql.service ${D}${systemd_unitdir}/system
> +    sed -i -e 's,@BINDIR@,${bindir},g' \
> +        ${D}${systemd_unitdir}/system/postgresql.service
>   }
>   
>   SSTATE_SCAN_FILES += "Makefile.global"



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-09-16  9:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-16  9:36 [PATCH 1/2] postgresql: move initdb to postgresql-setup Chong Lu
2014-09-16  9:36 ` [PATCH 2/2] postgresql: add systemd unit file Chong Lu
2014-09-16  9:42   ` Chong Lu
2014-09-16  9:41 ` [PATCH 1/2] postgresql: move initdb to postgresql-setup Chong Lu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.