merchant

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

commit a209ca8c6240cab7d4966239189f990ce9629ad6
parent 06aa423d1f9f2aae290d430ee8199cc88b7b9c1a
Author: bohdan-potuzhnyi <bohdan.potuzhnyi@gmail.com>
Date:   Thu,  5 Dec 2024 16:34:40 +0100

Merge branch 'master' into dev/bohdan-potuzhnyi/donau-integration

Diffstat:
Mcontrib/taler-merchant-dbconfig | 174++++++++++++++++++++++++++++++++++++-------------------------------------------
Mdebian/.gitignore | 54+++++++++++++++++++++++++++---------------------------
Mdebian/etc/apache2/sites-available/taler-merchant.conf | 2+-
Mdebian/etc/nginx/sites-available/taler-merchant | 2+-
Adebian/etc/taler-merchant/overrides.conf | 1+
Mdebian/taler-merchant.README.Debian | 2+-
Mdebian/taler-merchant.install | 2++
Mdebian/taler-merchant.postinst | 4++--
Mdebian/taler-merchant.postrm | 2+-
Mdebian/taler-merchant.taler-merchant-depositcheck.service | 2+-
Mdebian/taler-merchant.taler-merchant-exchangekeyupdate.service | 2+-
Mdebian/taler-merchant.taler-merchant-httpd.service | 2+-
Mdebian/taler-merchant.taler-merchant-kyccheck.service | 2+-
Mdebian/taler-merchant.taler-merchant-reconciliation.service | 2+-
Mdebian/taler-merchant.taler-merchant-webhook.service | 2+-
Mdebian/taler-merchant.taler-merchant-wirewatch.service | 2+-
Mdebian/taler-merchant.tmpfiles | 2+-
Msrc/backend/merchant.conf | 2+-
Msrc/util/os_installation.c | 4++--
19 files changed, 127 insertions(+), 138 deletions(-)

diff --git a/contrib/taler-merchant-dbconfig b/contrib/taler-merchant-dbconfig @@ -26,123 +26,109 @@ CFGFILE="/etc/taler-merchant/taler-merchant.conf" # Parse command-line options while getopts 'c:hrsu:' OPTION; do - case "$OPTION" in - c) - CFGFILE="$OPTARG" - ;; - h) - echo 'Supported options:' - echo " -c FILENAME -- use configuration FILENAME (default: $CFGFILE)" - echo " -h -- print this help text" - echo " -r -- reset database (dangerous)" - echo " -s -- skip database initialization" - echo " -u USER -- taler-merchant to be run by USER (default: $DBUSER)" - exit 0 - ;; - r) - RESET_DB="1" - ;; - s) - SKIP_DBINIT="1" - ;; - u) - DBUSER="$OPTARG" - ;; - ?) - echo "Unrecognized command line option '$OPTION'" 1&>2 - exit 1 - ;; - esac + case "$OPTION" in + c) + CFGFILE="$OPTARG" + ;; + h) + echo 'Supported options:' + echo " -c FILENAME -- use configuration FILENAME (default: $CFGFILE)" + echo " -h -- print this help text" + echo " -r -- reset database (dangerous)" + echo " -s -- skip database initialization" + echo " -u USER -- taler-merchant to be run by USER (default: $DBUSER)" + exit 0 + ;; + r) + RESET_DB="1" + ;; + s) + SKIP_DBINIT="1" + ;; + u) + DBUSER="$OPTARG" + ;; + ?) + echo "Unrecognized command line option '$OPTION'" 1 &>2 + exit 1 + ;; + esac done -if ! id postgres > /dev/null -then - echo "Could not find 'postgres' user. Please install Postgresql first" - exit 1 +if ! id postgres >/dev/null; then + echo "Could not find 'postgres' user. Please install Postgresql first" + exit 1 fi -if [ "$(id -u)" -ne 0 ] -then - echo "This script must be run as root" - exit 1 +if [ "$(id -u)" -ne 0 ]; then + echo "This script must be run as root" + exit 1 fi -if [ 0 = "$SKIP_DBINIT" ] -then - if ! taler-merchant-dbinit -v 2> /dev/null - then - echo "Required 'taler-merchant-dbinit' not found. Please fix your installation." - exit 1 - fi - DBINIT=$(which taler-merchant-dbinit) +if [ 0 = "$SKIP_DBINIT" ]; then + if ! taler-merchant-dbinit -v 2>/dev/null; then + echo "Required 'taler-merchant-dbinit' not found. Please fix your installation." + exit 1 + fi + DBINIT=$(which taler-merchant-dbinit) fi -if ! id "$DBUSER" > /dev/null -then - echo "Could not find '$DBUSER' user. Please set it up first" - exit 1 +if ! id "$DBUSER" >/dev/null; then + echo "Could not find '$DBUSER' user. Please set it up first" + exit 1 fi echo "Setting up database user $DBUSER." 1>&2 -if ! sudo -i -u postgres createuser "$DBUSER" 2> /dev/null -then - echo "Database user '$DBUSER' already existed. Continuing anyway." 1>&2 +if ! sudo -i -u postgres createuser "$DBUSER" 2>/dev/null; then + echo "Database user '$DBUSER' already existed. Continuing anyway." 1>&2 fi -DBPATH=$(taler-config \ - -c "$CFGFILE" \ - -s merchantdb-postgres \ - -o CONFIG) +DBPATH=$(taler-merchant-config \ + -c "$CFGFILE" \ + -s merchantdb-postgres \ + -o CONFIG) -if ! echo "$DBPATH" | grep "postgres://" > /dev/null -then - echo "Invalid database configuration value '$DBPATH'." 1>&2 - exit 1 +if ! echo "$DBPATH" | grep "postgres://" >/dev/null; then + echo "Invalid database configuration value '$DBPATH'." 1>&2 + exit 1 fi -DBNAME=$(echo "$DBPATH" \ - | sed \ - -e "s/postgres:\/\/.*\///" \ - -e "s/?.*//") - -if sudo -i -u postgres psql "$DBNAME" < /dev/null 2> /dev/null -then - if [ 1 = "$RESET_DB" ] - then - echo "Deleting existing database $DBNAME." 1>&2 - if ! sudo -i -u postgres dropdb "$DBNAME" - then - echo "Failed to delete existing database '$DBNAME'" - exit 1 - fi - DO_CREATE=1 - else - echo "Database '$DBNAME' already exists, continuing anyway." - DO_CREATE=0 +DBNAME=$(echo "$DBPATH" | + sed \ + -e "s/postgres:\/\/.*\///" \ + -e "s/?.*//") + +if sudo -i -u postgres psql "$DBNAME" </dev/null 2>/dev/null; then + if [ 1 = "$RESET_DB" ]; then + echo "Deleting existing database $DBNAME." 1>&2 + if ! sudo -i -u postgres dropdb "$DBNAME"; then + echo "Failed to delete existing database '$DBNAME'" + exit 1 fi -else DO_CREATE=1 + else + echo "Database '$DBNAME' already exists, continuing anyway." + DO_CREATE=0 + fi +else + DO_CREATE=1 fi -if [ 1 = "$DO_CREATE" ] -then - echo "Creating database $DBNAME." 1>&2 - if ! sudo -i -u postgres createdb -O "$DBUSER" "$DBNAME" - then - echo "Failed to create database '$DBNAME'" - exit 1 - fi +if [ 1 = "$DO_CREATE" ]; then + echo "Creating database $DBNAME." 1>&2 + if ! sudo -i -u postgres createdb -O "$DBUSER" "$DBNAME"; then + echo "Failed to create database '$DBNAME'" + exit 1 + fi fi -if [ 0 = "$SKIP_DBINIT" ] -then - echo "Initializing database $DBNAME." 1>&2 - if ! sudo -u "$DBUSER" "$DBINIT" -c "$CFGFILE" - then - echo "Failed to initialize database schema" - exit 1 - fi +if [ 0 = "$SKIP_DBINIT" ]; then + echo "Initializing database $DBNAME." 1>&2 + if ! sudo -u "$DBUSER" "$DBINIT" -c "$CFGFILE"; then + echo "Failed to initialize database schema" + exit 1 + fi fi echo "Database configuration finished." 1>&2 diff --git a/debian/.gitignore b/debian/.gitignore @@ -1,27 +1,27 @@ -.debhelper/ -autoreconf.after -autoreconf.before -debhelper-build-stamp -files -libtalerexchange.debhelper.log -libtalerexchange.substvars -libtalerexchange/ -taler-exchange-dev.debhelper.log -taler-exchange-dev.substvars -taler-exchange-dev/ -taler-exchange.debhelper.log -taler-exchange.substvars -taler-exchange/ -tmp/ -libtalermerchant-dev.debhelper.log -libtalermerchant-dev.substvars -libtalermerchant-dev/ -libtalermerchant.debhelper.log -libtalermerchant/ -taler-merchant.debhelper.log -taler-merchant/ -libtalermerchant.substvars -taler-merchant.substvars -taler-merchant.postrm.debhelper -taler-merchant.links -taler-merchant.postinst.debhelper +/.debhelper/ +/autoreconf.after +/autoreconf.before +/debhelper-build-stamp +/files +/libtalerexchange.debhelper.log +/libtalerexchange.substvars +/libtalerexchange/ +/taler-exchange-dev.debhelper.log +/taler-exchange-dev.substvars +/taler-exchange-dev/ +/taler-exchange.debhelper.log +/taler-exchange.substvars +/taler-exchange/ +/tmp/ +/libtalermerchant-dev.debhelper.log +/libtalermerchant-dev.substvars +/libtalermerchant-dev/ +/libtalermerchant.debhelper.log +/libtalermerchant/ +/taler-merchant.debhelper.log +/taler-merchant/ +/libtalermerchant.substvars +/taler-merchant.substvars +/taler-merchant.postrm.debhelper +/taler-merchant.links +/taler-merchant.postinst.debhelper diff --git a/debian/etc/apache2/sites-available/taler-merchant.conf b/debian/etc/apache2/sites-available/taler-merchant.conf @@ -14,7 +14,7 @@ # Apache documentation. # <Location "/"> - ProxyPass "unix:/var/run/taler/merchant-httpd/merchant-http.sock|http://example.com/" + ProxyPass "unix:/var/run/taler-merchant/httpd/merchant-http.sock|http://example.com/" # NOTE: # - Uncomment this line if you use TLS/HTTPS diff --git a/debian/etc/nginx/sites-available/taler-merchant b/debian/etc/nginx/sites-available/taler-merchant @@ -15,7 +15,7 @@ server { access_log /var/log/nginx/merchant.log; error_log /var/log/nginx/merchant.err; location /taler-merchant/ { - proxy_pass http://unix:/var/run/taler/merchant-httpd/merchant-http.sock; + proxy_pass http://unix:/var/run/taler-merchant/httpd/merchant-http.sock; proxy_redirect off; proxy_set_header Host $host; diff --git a/debian/etc/taler-merchant/overrides.conf b/debian/etc/taler-merchant/overrides.conf @@ -0,0 +1 @@ +# This configuration will be changed by tooling. Do not touch it manually. diff --git a/debian/taler-merchant.README.Debian b/debian/taler-merchant.README.Debian @@ -9,7 +9,7 @@ deploying a configuration for the backend to the respective Web server at the "/taler-merchant/" endpoint. Note that you still must configure the currency accepted by the merchant in -/etc/taler/taler.conf. +/etc/taler-merchant/taler-merchant.conf. Afterwards, you can use the following commands to start, stop or restart the Taler merchant backend: diff --git a/debian/taler-merchant.install b/debian/taler-merchant.install @@ -3,6 +3,8 @@ usr/bin/taler-merchant-* # FIXME: Why does this not go into libtalermerchant? usr/lib/*/libtalermerchantdb.so.* +usr/lib/*/taler-merchant/*.so + usr/share/man/man*/taler-merchant* usr/share/info/taler-merchant* usr/share/taler-merchant/* diff --git a/debian/taler-merchant.postinst b/debian/taler-merchant.postinst @@ -32,11 +32,11 @@ configure) adduser --quiet --system --ingroup ${_GROUPNAME} --no-create-home --home ${TALER_HOME} ${_USERNAME} fi - if ! dpkg-statoverride --list /etc/taler/secrets/merchant-db.secret.conf >/dev/null 2>&1 + if ! dpkg-statoverride --list /etc/taler-merchant/secrets/merchant-db.secret.conf >/dev/null 2>&1 then dpkg-statoverride --add --update \ taler-merchant-httpd root 460 \ - /etc/taler/secrets/merchant-db.secret.conf + /etc/taler-merchant/secrets/merchant-db.secret.conf fi ;; diff --git a/debian/taler-merchant.postrm b/debian/taler-merchant.postrm @@ -12,7 +12,7 @@ fi case "${1}" in purge) dpkg-statoverride --remove \ - /etc/taler/secrets/merchant-db.secret.conf || true + /etc/taler-merchant/secrets/merchant-db.secret.conf || true deluser --quiet --system ${_USERNAME} || true ;; diff --git a/debian/taler-merchant.taler-merchant-depositcheck.service b/debian/taler-merchant.taler-merchant-depositcheck.service @@ -9,7 +9,7 @@ Restart=always RestartMode=direct RestartSec=1s RestartPreventExitStatus=9 -ExecStart=/usr/bin/taler-merchant-depositcheck -c /etc/taler/taler.conf -L INFO +ExecStart=/usr/bin/taler-merchant-depositcheck -c /etc/taler-merchant/taler-merchant.conf -L INFO PrivateTmp=yes PrivateDevices=yes ProtectSystem=full diff --git a/debian/taler-merchant.taler-merchant-exchangekeyupdate.service b/debian/taler-merchant.taler-merchant-exchangekeyupdate.service @@ -9,7 +9,7 @@ Restart=always RestartMode=direct RestartSec=1s RestartPreventExitStatus=9 -ExecStart=/usr/bin/taler-merchant-exchangekeyupdate -c /etc/taler/taler.conf -L INFO +ExecStart=/usr/bin/taler-merchant-exchangekeyupdate -c /etc/taler-merchant/taler-merchant.conf -L INFO PrivateTmp=yes PrivateDevices=yes ProtectSystem=full diff --git a/debian/taler-merchant.taler-merchant-httpd.service b/debian/taler-merchant.taler-merchant-httpd.service @@ -9,7 +9,7 @@ Restart=always RestartSec=1s RestartPreventExitStatus=9 RuntimeMaxSec=3600s -ExecStart=/usr/bin/taler-merchant-httpd -c /etc/taler/taler.conf -L INFO +ExecStart=/usr/bin/taler-merchant-httpd -c /etc/taler-merchant/taler-merchant.conf -L INFO Slice=taler-merchant.slice [Install] diff --git a/debian/taler-merchant.taler-merchant-kyccheck.service b/debian/taler-merchant.taler-merchant-kyccheck.service @@ -9,7 +9,7 @@ Restart=always RestartMode=direct RestartSec=1s RestartPreventExitStatus=9 -ExecStart=/usr/bin/taler-merchant-kyccheck -c /etc/taler/taler.conf -L INFO +ExecStart=/usr/bin/taler-merchant-kyccheck -c /etc/taler-merchant/taler-merchant.conf -L INFO PrivateTmp=yes PrivateDevices=yes ProtectSystem=full diff --git a/debian/taler-merchant.taler-merchant-reconciliation.service b/debian/taler-merchant.taler-merchant-reconciliation.service @@ -9,7 +9,7 @@ Restart=always RestartMode=direct RestartSec=1s RestartPreventExitStatus=9 -ExecStart=/usr/bin/taler-merchant-reconciliation -c /etc/taler/taler.conf -L INFO +ExecStart=/usr/bin/taler-merchant-reconciliation -c /etc/taler-merchant/taler-merchant.conf -L INFO PrivateTmp=yes PrivateDevices=yes ProtectSystem=full diff --git a/debian/taler-merchant.taler-merchant-webhook.service b/debian/taler-merchant.taler-merchant-webhook.service @@ -9,7 +9,7 @@ Restart=always RestartMode=direct RestartSec=1s RestartPreventExitStatus=9 -ExecStart=/usr/bin/taler-merchant-webhook -c /etc/taler/taler.conf -L INFO +ExecStart=/usr/bin/taler-merchant-webhook -c /etc/taler-merchant/taler-merchant.conf -L INFO PrivateTmp=yes PrivateDevices=yes ProtectSystem=full diff --git a/debian/taler-merchant.taler-merchant-wirewatch.service b/debian/taler-merchant.taler-merchant-wirewatch.service @@ -9,7 +9,7 @@ Restart=always RestartMode=direct RestartSec=1s RestartPreventExitStatus=9 -ExecStart=/usr/bin/taler-merchant-wirewatch -c /etc/taler/taler.conf -L INFO +ExecStart=/usr/bin/taler-merchant-wirewatch -c /etc/taler-merchant/taler-merchant.conf -L INFO PrivateTmp=yes PrivateDevices=yes ProtectSystem=full diff --git a/debian/taler-merchant.tmpfiles b/debian/taler-merchant.tmpfiles @@ -1,2 +1,2 @@ #Type Path Mode UID GID Age Argument -d /run/taler/merchant-httpd 0755 taler-merchant-httpd www-data - - +d /run/taler-merchant/httpd 0755 taler-merchant-httpd www-data - - diff --git a/src/backend/merchant.conf b/src/backend/merchant.conf @@ -30,7 +30,7 @@ LEGAL_PRESERVATION = 11 years # Which unix domain path should we bind to? Only used if "SERVE" is 'unix'. -UNIXPATH = ${TALER_RUNTIME_DIR}/merchant-httpd/merchant-http.sock +UNIXPATH = ${TALER_RUNTIME_DIR}/httpd/merchant-http.sock # What should be the file access permissions (see chmod) for "UNIXPATH"? UNIXPATH_MODE = 660 diff --git a/src/util/os_installation.c b/src/util/os_installation.c @@ -40,8 +40,8 @@ static const struct GNUNET_OS_ProjectData merchant_pd = { .base_config_varname = "TALER_BASE_CONFIG", .bug_email = "taler@lists.gnu.org", .homepage = "http://www.gnu.org/s/taler/", - .config_file = "taler.conf", - .user_config_file = "~/.config/taler.conf", + .config_file = "taler-merchant.conf", + .user_config_file = "~/.config/taler-merchant.conf", .version = PACKAGE_VERSION, .is_gnu = 1, .gettext_domain = "taler",