#!/bin/bash set -e USER="bitcoin" # Source debconf library . /usr/share/debconf/confmodule case "$1" in configure) if [ -z "$2" ]; then mkdir -p /etc/datum-gateway if [ ! -f /etc/datum-gateway/datum_gateway_config.json ]; then cp /usr/share/datum-gateway/datum_gateway_config.json /etc/datum-gateway/datum_gateway_config.json fi PASSWORD=$(pwgen -s 32 1) db_set datum-gateway/password "$PASSWORD" chown $USER:$USER /etc/datum-gateway/datum_gateway_config.json runuser -u $USER -- jq --arg PASSWORD "$PASSWORD" 'del(.bitcoind.rpcuser) | del(.bitcoind.rpcpassword) | .bitcoind.rpccookiefile = "/var/lib/bitcoin/.cookie" | .mining.pool_address = "" | .api.admin_password = $PASSWORD | .api.modify_conf = true' /etc/datum-gateway/datum_gateway_config.json > /etc/datum-gateway/datum_gateway_config.json.tmp \ && mv /etc/datum-gateway/datum_gateway_config.json.tmp /etc/datum-gateway/datum_gateway_config.json db_subst datum-gateway/password PASSWORD "$PASSWORD" db_fset datum-gateway/password seen false db_input critical datum-gateway/password || true db_go fi if [ -f /etc/datum-gateway/datum_gateway_config.json ]; then db_get datum-gateway/bitcoin-address || RET= if [ "$RET" ]; then runuser -u $USER -- jq --arg BTCADDRESS "$RET" '.mining.pool_address = $BTCADDRESS' /etc/datum-gateway/datum_gateway_config.json > /etc/datum-gateway/datum_gateway_config.json.tmp \ && mv /etc/datum-gateway/datum_gateway_config.json.tmp /etc/datum-gateway/datum_gateway_config.json else echo -e "\e[1;33m Info:\e[0m No Bitcoin address entered, you can still configure it in the config file/GUI." >&2 fi fi db_stop ;; esac # Automatically added by dh_installsystemd/13.31 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then # The following line should be removed in trixie or trixie+1 deb-systemd-helper unmask 'datum-gateway.service' >/dev/null || true # was-enabled defaults to true, so new installations run enable. if deb-systemd-helper --quiet was-enabled 'datum-gateway.service'; then # Enables the unit on first installation, creates new # symlinks on upgrades if the unit file has changed. deb-systemd-helper enable 'datum-gateway.service' >/dev/null || true else # Update the statefile to add new symlinks (if any), which need to be # cleaned up on purge. Also remove old symlinks. deb-systemd-helper update-state 'datum-gateway.service' >/dev/null || true fi fi # End automatically added section # Automatically added by dh_installsystemd/13.31 if [ "$1" = "configure" ] || [ "$1" = "abort-upgrade" ] || [ "$1" = "abort-deconfigure" ] || [ "$1" = "abort-remove" ] ; then if [ -d /run/systemd/system ]; then systemctl --system daemon-reload >/dev/null || true if [ -n "$2" ]; then _dh_action=restart else _dh_action=start fi deb-systemd-invoke $_dh_action 'datum-gateway.service' >/dev/null || true fi fi # End automatically added section exit 0