Subject: Re: [alpine-devel] [PATCH] testing/pgagent: new aport

From: Rafał Rzepecki <[email-masked]>
Date: Thu, 26 Feb 2015 01:31:46 +0000

Hi, attaching updated patch. Let me know if you have any further comments.

wt., 16 gru 2014 o 14:47 użytkownik Natanael Copa <[email-masked]>
napisał:

> On Fri, 21 Nov 2014 13:40:08 -0500
> Rafa* Rzepecki <[email-masked]> wrote:
>
> > On Fri, Nov 21, 2014 at 2:33 AM, Natanael Copa <[email-masked]>
> wrote:
> > >
> > > On Thu, 20 Nov 2014 16:23:29 -0500
> > > Rafa* Rzepecki <[email-masked]> wrote:
> > >
> > > > http://www.pgadmin.org/docs/dev/pgagent.html
> > > > a job scheduler for PostgreSQL
> > > > ---
> ...
> > > > diff --git a/testing/pgagent/pgagent.confd
> b/testing/pgagent/pgagent.confd
> > > > new file mode 100644
> > > > index 0000000..a85be20
> > > > --- /dev/null
> > > > +++ b/testing/pgagent/pgagent.confd
> > > > @@ -0,0 +1,22 @@
> > > > +# Pool time interval
> > > > +PGA_POLL="10"
> > > > +
> > > > +# Retry period
> > > > +PGA_RETRY="30"
> > > > +
> > > > +# Log file
> > > > +PGA_LOG="/var/log/pgagent.log"
> > >
> > > Having the log file in /var/log means it needs to have root
> > > permissions. Does the agent really need to run as root?
> >
> > It doesn't and shouldn't; in fact it should run as postgres in the
> > case the scripts are used verbatim. Frankly I just copied them from
> > Gentoo without much thought :) Those things probably should get
> > reported 'upstream' once we converge on the best solution.
> >
> > Anyway, what's the preferred way to setup logging in this case? A
> > post-install script that creates a /var/log subdirectory with proper
> > permissions?
> >
> > Also, I'm not entirely sure what the user should be. If the agent is
> > running on a local postgres, it's most practical (even if not the most
> > secure) if it runs as 'postgres' user so it has superuser on the
> > database; if it's not running on the local server, the scripts aren't
> > generic enough to make it work anyway (auth needs to be set up, which
> > might be done in a number of different ways -- password, kerberos,
> > ident, ssl, etc.) so an admin would have to modify the init script
> > anyway.
>
> I think we can run it as postgresql as default and make the
> alternatives configurable.
>
> >
> > > > diff --git a/testing/pgagent/pgagent.initd
> b/testing/pgagent/pgagent.initd
> > > > new file mode 100644
> > > > index 0000000..0e37fcc
> > > > --- /dev/null
> > > > +++ b/testing/pgagent/pgagent.initd
> > > > @@ -0,0 +1,25 @@
> > > > +#!/sbin/runscript
> > > > +# Copyright 1999-2012 Gentoo Foundation
> > > > +# Distributed under the terms of the GNU General Public License v2
> > > > +# $Header: /var/cvsroot/gentoo-x86/dev-db/pgagent/files/pgagent.initd,v
> 1.1 2012/04/28 18:34:11 titanofold Exp $
> > > > +
> > > > +PGAGENTOPT="-t ${PGA_POLL} -r ${PGA_RETRY} -s ${PGA_LOG} -l
> ${PGA_LEVEL}"
> > > > +
> > > > +PGOPT="hostaddr=${PG_HOST} dbname=${PG_DBNAME} user=${PG_USER}"
> > > > +
> > > > +depend() {
> > > > +    use net
> > > > +    need postgresql
> > >
> > > Does the agent really require that a postgresql server runs on this
> > > host even if the PG_HOST is pointing to some other host?
> > >
> > > I suspect that you can actually run the agent on different host than
> the
> > > postgresql server and in that case, you don't need postgresql. It
> > > should probably say "use postgresql".
> >
> > Yes, thanks; as mentioned above it's just lifted from Gentoo verbatim.
> > I agree it should probably have use postgres, but heed the
> > aforementioned comments about how one would probably modify the script
> > anyway in anything different than the most common case.
> >
> > I'm not sure how to approach it best. Ideas are welcome :)
>
> Well, you should not need edit the scripts, only the config. Thats why
> there is a separate conf.d/ file.
>
> I would just replace the 'need postgresql' with 'use postgresql' and
> remove postgresql from depends.
>
> thanks!
>
> -nc
>
From 0d52e9bae455d855f05b0681c5eb4cab9aca0a24 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Rafa=C5=82=20Rzepecki?= <[email-masked]>
Date: Thu, 20 Nov 2014 16:06:30 -0500
Subject: [PATCH] testing/pgagent: new aport

http://www.pgadmin.org/docs/dev/pgagent.html
a job scheduler for PostgreSQL
---
 testing/pgagent/APKBUILD      | 73 +++++++++++++++++++++++++++++++++++++++++++
 testing/pgagent/pgagent.confd | 25 +++++++++++++++
 testing/pgagent/pgagent.initd | 25 +++++++++++++++
 3 files changed, 123 insertions(+)
 create mode 100644 testing/pgagent/APKBUILD
 create mode 100644 testing/pgagent/pgagent.confd
 create mode 100644 testing/pgagent/pgagent.initd

diff --git a/testing/pgagent/APKBUILD b/testing/pgagent/APKBUILD
new file mode 100644
index 0000000..e4fa2cf
--- /dev/null
+++ b/testing/pgagent/APKBUILD
@@ -0,0 +1,73 @@
+# Contributor: Rafal Rzepecki <[email-masked]>
+# Maintainer:
+pkgname=pgagent
+pkgver=3.4.0
+pkgrel=0
+pkgdesc="a job scheduler for PostgreSQL"
+url="http://www.pgadmin.org/docs/dev/pgagent.html"
+arch="all"
+license="POSTGRESQL"
+depends="" # all runtime dependencies are automatic with so dependencies
+depends_dev="wxgtk-dev postgresql-dev"
+makedepends="$depends_dev cmake"
+install=""
+subpackages="$pkgname-doc"
+source="
+	https://ftp.postgresql.org/pub/pgadmin3/release/pgagent/pgAgent-$pkgver-Source.tar.gz
+	pgagent.initd
+	pgagent.confd
+"
+pkgusers="postgres"
+
+_builddir="$srcdir"/pgAgent-$pkgver-Source
+prepare() {
+	local i
+	cd "$_builddir"
+	for i in $source; do
+		case $i in
+		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
+		esac
+	done
+}
+
+build() {
+	cd "$_builddir"
+	cmake -DCMAKE_INSTALL_PREFIX=/usr -DSTATIC_BUILD:BOOLEAN=FALSE
+	make || return 1
+}
+
+package() {
+	cd "$_builddir"
+
+	make DESTDIR="$pkgdir" install
+
+	# remove useless doc files
+	rm "$pkgdir"/usr/README
+	rm "$pkgdir"/usr/LICENSE
+
+	# move misplaced files
+	mkdir -p $pkgdir/usr/share/pgagent
+	mv $pkgdir/usr/share/*.sql $pkgdir/usr/share/pgagent
+
+	install -m755 -D "$srcdir"/$pkgname.initd \
+		"$pkgdir"/etc/init.d/$pkgname || return 1
+	install -m644 -D "$srcdir"/$pkgname.confd \
+		"$pkgdir"/etc/conf.d/$pkgname || return 1
+
+	# log directory
+	mkdir -p $pkgdir/var/log/$pkgname
+	chown postgres:postgres $pkgdir/var/log/$pkgname
+
+	install -Dm644 "$_builddir"/LICENSE "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
+	install -Dm644 "$_builddir"/README "$pkgdir"/usr/share/doc/$pkgname/README
+}
+
+md5sums="187caa1843f0d82f6caa1be0f80d6232  pgAgent-3.4.0-Source.tar.gz
+f6cf210bd796a8af9b216e71cc2d2017  pgagent.initd
+2d15293df212c8e5dda507ab1c0f825f  pgagent.confd"
+sha256sums="0da0ac8f453cf34ab6f708eee036bed0fd0e5fa311de283b92d2ff06600bbb3d  pgAgent-3.4.0-Source.tar.gz
+efed57884da94da0727d20215a24e3e8b626d2307d25568c357b76d851fae12f  pgagent.initd
+ed4bdd0b2e5d6d1babc4689863c20ab3b61134a50142d14d5c3bf9ed14087b20  pgagent.confd"
+sha512sums="3b068fc6f5e51ff20604f8cec3e067d04b5b1537229da15ee442000f5fe834697a4eae86be0e9a58b8ee5da24cc985c8c9804d71cb2a50e93ec4cf9a424a4ff0  pgAgent-3.4.0-Source.tar.gz
+1f684b63273d772e339569bacce109f4fbd4d7d91571db1ea395b05b94e023c29c594497c9b7742f5ff920faec20405e19acefcb02b90b33d888eddd3ba88e3e  pgagent.initd
+82fa0536c6a961943fd398ffcb7bfe1920eee7bc8c729f3bbf4d8fdf61c3671eb78f55ff5511b5f0110ec78933d9cf0fbab7a12c3e206fb0347c513850a09fbd  pgagent.confd"
diff --git a/testing/pgagent/pgagent.confd b/testing/pgagent/pgagent.confd
new file mode 100644
index 0000000..6d46e9f
--- /dev/null
+++ b/testing/pgagent/pgagent.confd
@@ -0,0 +1,25 @@
+# Pool time interval
+PGA_POLL="10"
+
+# Retry period
+PGA_RETRY="30"
+
+# Log file
+PGA_LOG="/var/log/pgagent/pgagent.log"
+
+# Logging verbosity
+# ERROR=0, WARNING=1, DEBUG=2
+PGA_LEVEL="1"
+
+# Server parameters
+# Host address
+PG_HOST="localhost"
+
+# DB name
+PG_DBNAME="postgres"
+
+# Username
+PG_USER="postgres"
+
+# Local user to run as
+RUN_AS="postgres"
diff --git a/testing/pgagent/pgagent.initd b/testing/pgagent/pgagent.initd
new file mode 100644
index 0000000..3a2a88d
--- /dev/null
+++ b/testing/pgagent/pgagent.initd
@@ -0,0 +1,25 @@
+#!/sbin/runscript
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-db/pgagent/files/pgagent.initd,v 1.1 2012/04/28 18:34:11 titanofold Exp $
+
+PGAGENTOPT="-t ${PGA_POLL} -r ${PGA_RETRY} -s ${PGA_LOG} -l ${PGA_LEVEL}"
+
+PGOPT="hostaddr=${PG_HOST} dbname=${PG_DBNAME} user=${PG_USER}"
+
+depend() {
+    use net
+    use postgresql
+}
+
+start() {
+    ebegin "Starting pgagent"
+    start-stop-daemon --start --user ${RUN_AS} --exec /usr/bin/pgagent -- ${PGAGENTOPT} ${PGOPT}
+    eend $?
+}
+
+stop() {
+    ebegin "Stopping pgagent"
+    start-stop-daemon --stop --name pgagent
+    eend $?
+}
-- 
2.3.0