aboutsummaryrefslogtreecommitdiff
path: root/debian/taler-auditor.postinst
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-01-03 23:29:27 +0100
committerChristian Grothoff <christian@grothoff.org>2021-01-03 23:29:27 +0100
commit9a24b4a0dccc299e17279e115a3e460092cab0d3 (patch)
tree9b2122dfcd3fec99118fa03831dcf8296468956f /debian/taler-auditor.postinst
parentd981da056e776e0756cfddb22f18308b9ab913a5 (diff)
fix auditor postinst
Diffstat (limited to 'debian/taler-auditor.postinst')
-rw-r--r--debian/taler-auditor.postinst95
1 files changed, 95 insertions, 0 deletions
diff --git a/debian/taler-auditor.postinst b/debian/taler-auditor.postinst
new file mode 100644
index 000000000..7d3865080
--- /dev/null
+++ b/debian/taler-auditor.postinst
@@ -0,0 +1,95 @@
+#!/bin/bash
+
+set -e
+
+. /usr/share/debconf/confmodule
+
+case "${1}" in
+ configure)
+ db_version 2.0
+
+ db_get taler-auditor/username
+ _USERNAME="${RET:-taler-auditor-httpd}"
+
+ db_get taler-auditor/groupname
+ _GROUPNAME="${RET:-taler-auditor-httpd}"
+
+ db_stop
+
+ CONFIG_FILE="/etc/default/taler-auditor"
+ TALER_HOME="/var/lib/taler-auditor"
+
+ # 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
+ # Creating taler users if needed
+ if ! getent passwd ${_USERNAME} > /dev/null
+ then
+ echo -n "Creating new Taler user ${_USERNAME}:"
+ adduser --quiet --system --ingroup ${_GROUPNAME} --home ${TALER_HOME}/httpd ${_USERNAME}
+ echo " done."
+ fi
+ # Writing new values to configuration file
+ echo -n "Writing new configuration file:"
+ CONFIG_NEW=$(tempfile)
+
+cat > "${CONFIG_NEW}" <<EOF
+# This file controls the behaviour of the Taler init script.
+# It will be parsed as a shell script.
+# please do not edit by hand, use 'dpkg-reconfigure taler-auditor'.
+
+TALER_USER=${_USERNAME}
+TALER_GROUP=${_GROUPNAME}
+EOF
+
+cat > "/etc/systemd/system/taler-auditor-httpd.service" <<EOF
+[Unit]
+Description=GNU Taler payment system auditor REST API
+After=postgres.service network.target
+
+[Service]
+EnvironmentFile=/etc/default/taler-auditor
+User=${_USERNAME}
+Type=simple
+Restart=on-failure
+ExecStart=/usr/bin/taler-auditor-httpd -c /etc/taler-auditor.conf
+
+[Install]
+WantedBy=multi-user.target
+EOF
+
+ cp -f "${CONFIG_NEW}" "${CONFIG_FILE}"
+ rm -f "${CONFIG_NEW}"
+ echo " done."
+
+ echo -n "Setting up system services "
+
+ mkdir -p /var/lib/taler-auditor/tmp
+ chown root:${_GROUPNAME} /var/lib/taler-auditor/tmp
+ chmod 770 /var/lib/taler-auditor/tmp
+ chmod +s /var/lib/taler-auditor/tmp
+
+ systemctl daemon-reload
+
+ 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