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