2020-12-28 11:39:05 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
. /usr/share/debconf/confmodule
|
|
|
|
|
2021-07-16 17:31:19 +02:00
|
|
|
TALER_HOME="/var/lib/taler-exchange"
|
2021-07-26 14:18:02 +02:00
|
|
|
CONFIG_FILE="/etc/default/taler-exchange"
|
|
|
|
_GROUPNAME=taler-exchange-secmod
|
|
|
|
_DBGROUPNAME=taler-exchange-db
|
|
|
|
_EUSERNAME=taler-exchange-httpd
|
|
|
|
_RSECUSERNAME=taler-exchange-secmod-rsa
|
|
|
|
_ESECUSERNAME=taler-exchange-secmod-rsa
|
|
|
|
_AGGRUSERNAME=taler-exchange-aggregator
|
|
|
|
_WIREUSERNAME=taler-exchange-wire
|
2021-07-16 17:31:19 +02:00
|
|
|
|
2021-07-16 17:16:38 +02:00
|
|
|
# usage: fixperm user:group perms file
|
|
|
|
function fixperm() {
|
|
|
|
chown "$1" "$3"
|
|
|
|
chmod "$2" "$3"
|
|
|
|
}
|
|
|
|
|
2021-07-16 17:31:19 +02:00
|
|
|
# usage: lncfg user home target
|
2021-07-16 17:16:38 +02:00
|
|
|
function lncfg() {
|
2021-07-16 17:45:54 +02:00
|
|
|
local cf=$TALER_HOME/$2/.config
|
|
|
|
if [ ! -e $cf ]; then
|
|
|
|
mkdir $cf
|
2021-07-16 17:51:31 +02:00
|
|
|
chown $(stat -L -c %u $TALER_HOME/$2):$(stat -L -c %g $TALER_HOME/$2) $cf
|
2021-07-16 17:45:54 +02:00
|
|
|
fi
|
2021-07-16 18:24:41 +02:00
|
|
|
ln -sf $3 $cf/taler.conf
|
2021-07-16 17:16:38 +02:00
|
|
|
}
|
|
|
|
|
2020-12-28 11:39:05 +01:00
|
|
|
case "${1}" in
|
2021-07-16 17:16:38 +02:00
|
|
|
configure)
|
|
|
|
|
2021-07-26 14:18:02 +02:00
|
|
|
# Create taler groups as needed
|
2021-07-16 17:16:38 +02:00
|
|
|
if ! getent group ${_GROUPNAME} >/dev/null; then
|
2021-07-26 14:18:02 +02:00
|
|
|
echo -n "Creating new Taler group ${_GROUPNAME} ..."
|
2021-07-16 17:16:38 +02:00
|
|
|
addgroup --quiet --system ${_GROUPNAME}
|
|
|
|
echo " done."
|
|
|
|
fi
|
|
|
|
if ! getent group ${_DBGROUPNAME} >/dev/null; then
|
2021-07-26 14:18:02 +02:00
|
|
|
echo -n "Creating new Taler group ${_DBGROUPNAME} ..."
|
2021-07-16 17:16:38 +02:00
|
|
|
addgroup --quiet --system ${_DBGROUPNAME}
|
|
|
|
echo " done."
|
|
|
|
fi
|
|
|
|
|
2021-07-26 14:18:02 +02:00
|
|
|
# Create taler users if needed
|
2021-07-16 17:16:38 +02:00
|
|
|
if ! getent passwd ${_EUSERNAME} >/dev/null; then
|
2021-07-26 14:18:02 +02:00
|
|
|
echo -n "Creating new Taler user ${_EUSERNAME} ..."
|
2021-07-16 17:16:38 +02:00
|
|
|
adduser --quiet --system --ingroup ${_GROUPNAME} --home ${TALER_HOME}/httpd ${_EUSERNAME}
|
|
|
|
adduser ${_EUSERNAME} ${_DBGROUPNAME}
|
|
|
|
echo " done."
|
|
|
|
fi
|
|
|
|
if ! getent passwd ${_RSECUSERNAME} >/dev/null; then
|
2021-07-26 14:18:02 +02:00
|
|
|
echo -n "Creating new Taler user ${_RSECUSERNAME} ..."
|
2021-07-16 17:16:38 +02:00
|
|
|
adduser --quiet --system --ingroup ${_GROUPNAME} --home ${TALER_HOME}/secmod-rsa ${_RSECUSERNAME}
|
|
|
|
echo " done."
|
|
|
|
fi
|
|
|
|
if ! getent passwd ${_ESECUSERNAME} >/dev/null; then
|
2021-07-26 14:18:02 +02:00
|
|
|
echo -n "Creating new Taler user ${_ESECUSERNAME} ..."
|
2021-07-16 17:16:38 +02:00
|
|
|
adduser --quiet --system --ingroup ${_GROUPNAME} --home ${TALER_HOME}/secmod-eddsa ${_ESECUSERNAME}
|
|
|
|
echo " done."
|
|
|
|
fi
|
|
|
|
if ! getent passwd ${_WIREUSERNAME} >/dev/null; then
|
2021-07-26 14:18:02 +02:00
|
|
|
echo -n "Creating new Taler user ${_WIREUSERNAME} ..."
|
2021-07-16 17:16:38 +02:00
|
|
|
adduser --quiet --system --home ${TALER_HOME}/wire ${_WIREUSERNAME}
|
|
|
|
adduser --quiet ${_WIREUSERNAME} ${_DBGROUPNAME}
|
|
|
|
echo " done."
|
|
|
|
fi
|
|
|
|
if ! getent passwd ${_AGGRUSERNAME} >/dev/null; then
|
2021-07-26 14:18:02 +02:00
|
|
|
echo -n "Creating new Taler user ${_AGGRUSERNAME} ..."
|
2021-07-16 17:16:38 +02:00
|
|
|
adduser --quiet --system --home ${TALER_HOME}/aggregator ${_AGGRUSERNAME}
|
|
|
|
adduser --quiet ${_AGGRUSERNAME} ${_DBGROUPNAME}
|
|
|
|
echo " done."
|
|
|
|
fi
|
|
|
|
|
|
|
|
fixperm ${_WIREUSERNAME}:root 460 /etc/taler/exchange-wire-gateway.conf
|
|
|
|
fixperm root:${_DBGROUPNAME} 640 /etc/taler/exchange-db.conf
|
2021-01-02 14:05:45 +01:00
|
|
|
|
2021-07-16 17:16:38 +02:00
|
|
|
echo -n "Linking config files"
|
2021-07-16 17:31:19 +02:00
|
|
|
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
|
2021-07-16 17:16:38 +02:00
|
|
|
echo " done"
|
2021-01-01 20:43:59 +01:00
|
|
|
|
2021-07-16 17:16:38 +02:00
|
|
|
# Cleaning
|
|
|
|
echo "All done."
|
|
|
|
;;
|
2020-12-28 11:39:05 +01:00
|
|
|
|
2021-07-16 17:16:38 +02:00
|
|
|
abort-upgrade | abort-remove | abort-deconfigure) ;;
|
2020-12-28 11:39:05 +01:00
|
|
|
|
2021-07-16 17:16:38 +02:00
|
|
|
*)
|
|
|
|
echo "postinst called with unknown argument \`${1}'" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
2020-12-28 11:39:05 +01:00
|
|
|
esac
|
|
|
|
|
|
|
|
#DEBHELPER#
|
|
|
|
|
|
|
|
exit 0
|