gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libeufin] branch master updated (09482f4c -> f9378fd2)


From: gnunet
Subject: [libeufin] branch master updated (09482f4c -> f9378fd2)
Date: Thu, 02 Mar 2023 14:41:49 +0100

This is an automated email from the git hooks/post-receive script.

grothoff pushed a change to branch master
in repository libeufin.

    from 09482f4c Long polling.
     new b5c14d23 update Debian package of libeufin to include more DB setup 
logic
     new f9378fd2 update Debian package of libeufin to include more DB setup 
logic

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 debian/db/install/pgsql  | 34 ++++++++++++++++++++++++++++++++++
 debian/libeufin.config   | 22 ++++++++++++++++++++++
 debian/libeufin.install  |  7 ++++++-
 debian/libeufin.postinst | 32 ++++++++++++++++++++++++++++++++
 debian/libeufin.postrm   | 30 ++++++++++++++++++++++++++++++
 debian/libeufin.prerm    | 22 ++++++++++++++++++++++
 6 files changed, 146 insertions(+), 1 deletion(-)
 create mode 100755 debian/db/install/pgsql
 create mode 100644 debian/libeufin.config
 create mode 100644 debian/libeufin.postrm
 create mode 100644 debian/libeufin.prerm

diff --git a/debian/db/install/pgsql b/debian/db/install/pgsql
new file mode 100755
index 00000000..5336037a
--- /dev/null
+++ b/debian/db/install/pgsql
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+set -eu
+
+libeufindb_secretconf=/etc/libeufin-db.secret.conf
+
+# Get database settings from dbconfig-common and write Taler configuration 
files.
+if [ -f /etc/dbconfig-common/taler-libeufin.conf ]; then
+  . /etc/dbconfig-common/taler-libeufin.conf
+  case "$dbc_dbtype" in
+  pgsql)
+    # We assume ident auth here.  We might support password auth later.
+    echo -e "[libeufin-postgres]\nCONFIG=postgres:///${dbc_dbname}\n\n" > \
+      $libeufindb_secretconf
+
+    # Allow the libeufin-sandbox/nexus user to create schemas, needed by dbinit
+    echo "GRANT CREATE ON DATABASE \"${dbc_dbtype}\" TO \"libeufin-nexus\";" | 
sudo -u postgres psql -f -
+    echo "GRANT CREATE ON DATABASE \"${dbc_dbtype}\" TO \"libeufin-sandbox\";" 
| sudo -u postgres psql -f -
+    ;;
+  sqlite3)
+    # Later: use something like:
+    # sqlite:///$DATA_DIR/libeufin.db
+    # But for now, sqlite is unsupported:
+    echo "Unsupported database type $dbc_type."
+    exit 1
+    ;;
+  "") ;;
+
+  *)
+    echo "Unsupported database type $dbc_type."
+    exit 1
+    ;;
+  esac
+fi
diff --git a/debian/libeufin.config b/debian/libeufin.config
new file mode 100644
index 00000000..1e256c61
--- /dev/null
+++ b/debian/libeufin.config
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+set -e
+
+. /usr/share/debconf/confmodule
+
+_USERNAME=libeufin
+_GROUPNAME=libeufin
+
+# For now, we only support postgres
+dbc_dbtypes=pgsql
+dbc_dbuser=${_USERNAME}
+
+dbc_authmethod_user=ident
+dbc_authmethod_admin=ident
+
+if [ -f /usr/share/dbconfig-common/dpkg/config.pgsql ]; then
+    . /usr/share/dbconfig-common/dpkg/config.pgsql
+    dbc_go libeufin "$@"
+fi
+
+db_stop
diff --git a/debian/libeufin.install b/debian/libeufin.install
index def283a9..32213f72 100644
--- a/debian/libeufin.install
+++ b/debian/libeufin.install
@@ -1,3 +1,8 @@
 debian/etc/* etc/
-# Only used to install the SPA + JS config:
+
+# Files needed by dbconf
+debian/db/install/* usr/share/dbconfig-common/scripts/libeufin/install/
+
+# Install the SPA + JS config:
 debian/usr/share/libeufin/* usr/share/libeufin/
+
diff --git a/debian/libeufin.postinst b/debian/libeufin.postinst
index 494eb031..b3586787 100644
--- a/debian/libeufin.postinst
+++ b/debian/libeufin.postinst
@@ -2,12 +2,37 @@
 
 set -e
 
+if [ -d /run/systemd/system ]; then
+        systemctl --system daemon-reload >/dev/null || true
+fi
+if [ "$1" = "remove" ]; then
+        if [ -x "/usr/bin/deb-systemd-helper" ]; then
+                deb-systemd-helper mask 'libeufin-nexus.service' >/dev/null || 
true
+                deb-systemd-helper mask 'libeufin-sandbox.service' >/dev/null 
|| true
+        fi
+fi
+
+if [ "$1" = "purge" ]; then
+        if [ -x "/usr/bin/deb-systemd-helper" ]; then
+                deb-systemd-helper purge 'libeufin-nexus.service' >/dev/null 
|| true
+                deb-systemd-helper purge 'libeufin-sandbox.service' >/dev/null 
|| true
+                deb-systemd-helper unmask 'libeufin-nexus.service' >/dev/null 
|| true
+                deb-systemd-helper unmask 'libeufin-sandbox.service' 
>/dev/null || true
+        fi
+fi
 nexus_user=libeufin-nexus
 sandbox_user=libeufin-sandbox
 nexus_group=libeufin-nexus
 sandbox_group=libeufin-sandbox
 libeufin_home=/var/lib/libeufin
 
+# Set permissions for sqlite3 file
+# (for when we support sqlite3 in the future)
+dbc_dbfile_owner="${_USERNAME}:${_GROUPNAME}"
+dbc_dbfile_perms="0600"
+
+. /usr/share/debconf/confmodule
+
 case "${1}" in
   configure)
 
@@ -29,6 +54,13 @@ case "${1}" in
       adduser --quiet --system --no-create-home --ingroup $sandbox_group 
--home $libeufin_home $sandbox_user
     fi
 
+    # Set up postgres database (needs dbconfig-pgsql package)
+    if [ -f /usr/share/dbconfig-common/dpkg/postinst.pgsql ]; then
+      . /usr/share/dbconfig-common/dpkg/postinst.pgsql
+      dbc_pgsql_createdb_encoding="UTF8"
+      dbc_go libeufin "$@"
+    fi
+
     ;;
 
   abort-upgrade|abort-remove|abort-deconfigure)
diff --git a/debian/libeufin.postrm b/debian/libeufin.postrm
new file mode 100644
index 00000000..56acce50
--- /dev/null
+++ b/debian/libeufin.postrm
@@ -0,0 +1,30 @@
+#!/bin/sh
+
+set -e
+
+if [ -f /usr/share/debconf/confmodule ]; then
+    . /usr/share/debconf/confmodule
+fi
+
+if [ -f /usr/share/dbconfig-common/dpkg/postrm.pgsql ]; then
+    . /usr/share/dbconfig-common/dpkg/postrm.pgsql
+    dbc_go libeufin "$@"
+fi
+
+case "${1}" in
+purge)
+# TODO: anything to clean up? Like:
+#  rm -f /etc/libeufin-db.conf
+  ;;
+remove | upgrade | failed-upgrade | abort-install | abort-upgrade | disappear)
+  ;;
+
+  *)
+  echo "postrm called with unknown argument \`${1}'" >&2
+  exit 1
+  ;;
+esac
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/libeufin.prerm b/debian/libeufin.prerm
new file mode 100644
index 00000000..5363996a
--- /dev/null
+++ b/debian/libeufin.prerm
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+set -e
+
+if [ -d /run/systemd/system ] && [ "$1" = remove ]; then
+        deb-systemd-invoke stop 'libeufin-nexus.service' >/dev/null || true
+        deb-systemd-invoke stop 'libeufin-sandbox.service' >/dev/null || true
+fi
+
+if [ -f /usr/share/debconf/confmodule ]; then
+    . /usr/share/debconf/confmodule
+fi
+. /usr/share/dbconfig-common/dpkg/prerm
+
+if [ -f /usr/share/dbconfig-common/dpkg/prerm.pgsql ]; then
+    . /usr/share/dbconfig-common/dpkg/prerm.pgsql
+    dbc_go libeufin "$@"
+fi
+
+
+db_stop
+exit 0

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]