merchant

Merchant backend to process payments, run by merchants
Log | Files | Refs | Submodules | README | LICENSE

commit 2b36cd1d866ca080e0f4e026f0445fe1577b07cc
parent a0a8f482fb69d6fc79e13f3fba302fc7ff964a3f
Author: Christian Grothoff <christian@grothoff.org>
Date:   Sat,  2 Jan 2021 14:05:31 +0100

debian package fixes

Diffstat:
Mdebian/control | 6+++---
Mdebian/db/install/pgsql | 73++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Ddebian/db/upgrade/pgsql | 2--
Mdebian/taler-merchant.config | 18++++++++++++++++++
Mdebian/taler-merchant.install | 3+--
Mdebian/taler-merchant.postinst | 51+++++++++++++--------------------------------------
6 files changed, 107 insertions(+), 46 deletions(-)

diff --git a/debian/control b/debian/control @@ -38,7 +38,7 @@ Architecture: any Pre-Depends: ${misc:Pre-Depends} Depends: - libtalerexchange (= ${binary:Version}), + libtalerexchange (>= 0.9.0), adduser, lsb-base, netbase, @@ -53,8 +53,8 @@ Package: libtalermerchant-dev Section: libdevel Architecture: any Depends: - libtalerexchange-dev (= ${binary:Version}), - libgnunet-dev (>=1:0.14.0), + libtalerexchange-dev (>= 0.9.0), + libgnunet-dev (>=0.14.0), ${misc:Depends} Description: libraries to talk to a GNU Taler merchant (development) . diff --git a/debian/db/install/pgsql b/debian/db/install/pgsql @@ -1,2 +1,73 @@ #!/bin/sh -taler-merchant-dbinit -c /etc/taler-merchant.conf + +set -eu + +# get database settings from dbconfig-common and configure +# for ADMINISTRATIVE access +if [ -f /etc/dbconfig-common/taler-merchant.conf ]; then + . /etc/dbconfig-common/taler-merchant.conf + case "$dbc_dbtype" in + pgsql) + taler-config -w \ + -c /etc/taler-merchant.conf \ + -s "merchantdb-postgres" \ + -o "CONFIG" \ + -V "postgres:///$dbc_dbname" + taler-config -w \ + -c /etc/taler-merchant.conf \ + -s "merchant" \ + -o "DB" \ + -V "postgres" + ;; + sqlite3) + # Later: use something like: + # sqlite:///$DATA_DIR/merchant.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 + +# Run database initialization logic +sudo -u postgres taler-merchant-dbinit -c /etc/taler-merchant.conf + + +# get database settings from dbconfig-common and configure +# for service access! +if [ -f /etc/dbconfig-common/taler-merchant.conf ]; then + . /etc/dbconfig-common/taler-merchant.conf + case "$dbc_dbtype" in + pgsql) + taler-config -w \ + -c /etc/taler-merchant.conf \ + -s "merchantdb-postgres" \ + -o "CONFIG" \ + -V "postgres://$dbc_dbuser:$dbc_dbpass@$dbc_dbserver/$dbc_dbname" + taler-config -w \ + -c /etc/taler-merchant.conf \ + -s "merchant" \ + -o "DB" \ + -V "postgres" + ;; + sqlite3) + # Later: use something like: + # sqlite:///$DATA_DIR/merchant.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/db/upgrade/pgsql b/debian/db/upgrade/pgsql @@ -1,2 +0,0 @@ -#!/bin/sh -taler-merchant-dbinit -c /etc/taler-merchant.conf diff --git a/debian/taler-merchant.config b/debian/taler-merchant.config @@ -10,6 +10,24 @@ db_go db_input low taler-merchant/groupname || true db_go +# Set permissions for sqlite3 file +# (for when we support sqlite3 in the future) +dbc_dbfile_owner="${_USERNAME}:${_GROUPNAME}" +dbc_dbfile_perms="0600" + +dbc_psql_createdb_encoding="UTF8" + +# Set MySQL encoding to UTF8, just in case MySQL +# support is added in the future. +dbc_mysql_createdb_encoding="UTF8" + +# Try to get it to use UNIX domain sockets, if possible. +# (Note: doesn't seem to do much, still uses username+PW+TCP +# on my system :-( dbconfig documentation sucks.). +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 diff --git a/debian/taler-merchant.install b/debian/taler-merchant.install @@ -1,6 +1,5 @@ usr/bin/ usr/lib/*/taler/*.so -debian/conf/* etc/taler-merchant/ debian/etc/* /etc/ +debian/conf/* etc/taler-merchant/ debian/db/install/* usr/share/dbconfig-common/scripts/taler-merchant/install/ -debian/db/upgrade/* usr/share/dbconfig-common/scripts/taler-merchant/upgrade/ diff --git a/debian/taler-merchant.postinst b/debian/taler-merchant.postinst @@ -45,6 +45,7 @@ case "${1}" in _GROUPNAME="${RET:-www-data}" # Read default values + CONFIG_FILE="/etc/default/taler-merchant" TALER_HOME="/var/lib/taler-merchant" # Creating taler group if needed @@ -62,6 +63,18 @@ case "${1}" in echo " done." fi + + # Setup 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 taler-merchant "$@" + fi + + chown ${_USERNAME}:postgres /etc/taler-merchant.conf + chmod 460 /etc/taler-merchant.conf + + # Create access secret SECRET=`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 64 | head -n 1` echo SECRET > ${TALER_HOME}/master-api-key.txt @@ -99,44 +112,6 @@ EOF cp -f "${CONFIG_NEW}" "${CONFIG_FILE}" echo " done." - # Setup 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 taler-merchant "$@" - fi - - # get database settings from dbconfig-common - if [ -f /etc/dbconfig-common/taler-merchant.conf ]; then - . /etc/dbconfig-common/taler-merchant.conf - case "$dbc_dbtype" in - pgsql) - taler-config -c /etc/taler-merchant.conf \ - -s "merchantdb-postgres" \ - -o "CONFIG" \ - -V "postgres://$dbc_dbuser:$dbc_dbpass@$dbc_dbserver/$dbc_dbname" - taler-config -c /etc/taler-merchant.conf \ - -s "merchant" \ - -o "DB" \ - -V "postgres" - ;; - sqlite3) - # Later: use something like: - # sqlite:///$DATA_DIR/merchant.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 - - # Configure Webserver db_get taler-merchant/reconfigure-webserver webservers="$RET"