#!/bin/bash set -e . /usr/share/debconf/confmodule TALER_HOME="/var/lib/taler-exchange" # usage: fixperm user:group perms file function fixperm() { chown "$1" "$3" chmod "$2" "$3" } # usage: lncfg user home target function lncfg() { local cf=$TALER_HOME/$2/.config if [ ! -e $cf ]; then mkdir $cf chown $(stat -L -c %u $TALER_HOME/$2):$(stat -L -c %g $TALER_HOME/$2) $cf fi ln -sf $cf/taler.conf $3 } case "${1}" in configure) db_version 2.0 db_get taler-exchange/eusername _EUSERNAME="${RET:-taler-exchange-httpd}" db_get taler-exchange/rsecusername _RSECUSERNAME="${RET:-taler-exchange-secmod-rsa}" db_get taler-exchange/esecusername _ESECUSERNAME="${RET:-taler-exchange-secmod-eddsa}" db_get taler-exchange/wireusername _WIREUSERNAME="${RET:-taler-exchange-wire}" db_get taler-exchange/aggrusername _AGGRUSERNAME="${RET:-taler-exchange-aggregator}" db_get taler-exchange/groupname _GROUPNAME="${RET:-taler-private}" db_get taler-exchange/dbgroupname _DBGROUPNAME="${RET:-taler-exchange-db}" db_stop CONFIG_FILE="/etc/default/taler-exchange" # Creating taler groups as needed if ! getent group ${_GROUPNAME} >/dev/null; then echo -n "Creating new Taler group ${_GROUPNAME}:" addgroup --quiet --system ${_GROUPNAME} echo " done." fi if ! getent group ${_DBGROUPNAME} >/dev/null; then echo -n "Creating new Taler group ${_DBGROUPNAME}:" addgroup --quiet --system ${_DBGROUPNAME} echo " done." fi # Creating taler users if needed if ! getent passwd ${_EUSERNAME} >/dev/null; then echo -n "Creating new Taler user ${_EUSERNAME}:" adduser --quiet --system --ingroup ${_GROUPNAME} --home ${TALER_HOME}/httpd ${_EUSERNAME} adduser ${_EUSERNAME} ${_DBGROUPNAME} echo " done." fi if ! getent passwd ${_RSECUSERNAME} >/dev/null; then echo -n "Creating new Taler user ${_RSECUSERNAME}:" adduser --quiet --system --ingroup ${_GROUPNAME} --home ${TALER_HOME}/secmod-rsa ${_RSECUSERNAME} echo " done." fi if ! getent passwd ${_ESECUSERNAME} >/dev/null; then echo -n "Creating new Taler user ${_ESECUSERNAME}:" adduser --quiet --system --ingroup ${_GROUPNAME} --home ${TALER_HOME}/secmod-eddsa ${_ESECUSERNAME} echo " done." fi if ! getent passwd ${_WIREUSERNAME} >/dev/null; then echo -n "Creating new Taler user ${_WIREUSERNAME}:" adduser --quiet --system --home ${TALER_HOME}/wire ${_WIREUSERNAME} adduser --quiet ${_WIREUSERNAME} ${_DBGROUPNAME} echo " done." fi if ! getent passwd ${_AGGRUSERNAME} >/dev/null; then echo -n "Creating new Taler user ${_AGGRUSERNAME}:" adduser --quiet --system --home ${TALER_HOME}/aggregator ${_AGGRUSERNAME} adduser --quiet ${_AGGRUSERNAME} ${_DBGROUPNAME} echo " done." fi # Writing new values to configuration file echo -n "Writing new configuration file:" CONFIG_NEW=$(tempfile) cat >"${CONFIG_NEW}" <"/etc/systemd/system/taler-exchange-httpd.socket" <"/etc/systemd/system/taler-exchange-httpd.service" <"/etc/systemd/system/taler-exchange-secmod-rsa.service" <"/etc/systemd/system/taler-exchange-secmod-eddsa.service" <"/etc/systemd/system/taler-exchange-wirewatch.service" <"/etc/systemd/system/taler-exchange-transfer.service" <"/etc/systemd/system/taler-exchange-aggregator.service" </dev/null 2>&1 || true echo "done." echo -n "Linking config files" lncfg ${_EUSERNAME} httpd /etc/taler/exchange-service-default.conf lncfg ${_RSECUSERNAME} secmod-rsa /etc/taler/exchange-service-default.conf lncfg ${_ESECUSERNAME} secmod-eddsa /etc/taler/exchange-service-default.conf lncfg ${_AGGRUSERNAME} aggregator /etc/taler/exchange-service-default.conf lncfg ${_WIREUSERNAME} wire /etc/taler/exchange-service-wire.conf echo " done" # Cleaning echo "All done." ;; abort-upgrade | abort-remove | abort-deconfigure) ;; *) echo "postinst called with unknown argument \`${1}'" >&2 exit 1 ;; esac #DEBHELPER# exit 0