| 1 | #!/bin/sh |
| 2 | |
| 3 | set -e |
| 4 | |
| 5 | . /usr/share/debconf/confmodule |
| 6 | |
| 7 | config="/etc/prometheus-nextcloud-exporter.yml" |
| 8 | |
| 9 | update_config () { |
| 10 | db_get prometheus-nextcloud-exporter/server |
| 11 | server="$RET" |
| 12 | db_get prometheus-nextcloud-exporter/username |
| 13 | username="$RET" |
| 14 | db_get prometheus-nextcloud-exporter/password |
| 15 | password="$RET" |
| 16 | |
| 17 | sed -i -e "s|^\(\s*server:\s*\"\)\S\+\(\"\s*\)$|\1$server\2|" \ |
| 18 | -e "s|^\(\s*username:\s*\"\)\S\+\(\"\s*\)$|\1$username\2|" \ |
| 19 | -e "s|^\(\s*password:\s*\"\)\S\+\(\"\s*\)$|\1$password\2|" \ |
| 20 | "$config" |
| 21 | } |
| 22 | |
| 23 | case "$1" in |
| 24 | configure) |
| 25 | # Add prometheus user |
| 26 | adduser --quiet --system --home /var/lib/prometheus --no-create-home \ |
| 27 | --group --gecos "Prometheus daemon" prometheus |
| 28 | |
| 29 | [ -f "$config" ] && update_config |
| 30 | if ! dpkg-statoverride --list /etc/prometheus-nextcloud-exporter.yml \ |
| 31 | >/dev/null |
| 32 | then |
| 33 | chown root:prometheus /etc/prometheus-nextcloud-exporter.yml |
| 34 | chmod 640 /etc/prometheus-nextcloud-exporter.yml |
| 35 | fi |
| 36 | ;; |
| 37 | |
| 38 | abort-upgrade|abort-remove|abort-deconfigure) |
| 39 | ;; |
| 40 | |
| 41 | *) |
| 42 | echo "postinst called with unknown argument \`$1'" >&2 |
| 43 | exit 1 |
| 44 | ;; |
| 45 | esac |
| 46 | |
| 47 | #DEBHELPER# |
| 48 | |
| 49 | exit 0 |