From 8b059e57a63917ee427147e9b0a2951fb728e99d Mon Sep 17 00:00:00 2001 From: Robert Fratto Date: Thu, 22 Jul 2021 11:16:53 -0400 Subject: [PATCH] deb package: add grafana-agent user to adm and systemd-journal groups Closes #737 --- packaging/deb/control/postinst | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packaging/deb/control/postinst b/packaging/deb/control/postinst index d29e8077ca1e..7390fe52e623 100644 --- a/packaging/deb/control/postinst +++ b/packaging/deb/control/postinst @@ -14,7 +14,15 @@ case "$1" in groupadd -r "$GRAFANA_AGENT_GROUP" fi if ! getent passwd "$GRAFANA_AGENT_USER" > /dev/null 2>&1 ; then - useradd -m -r -g grafana-agent -d /var/lib/grafana-agent -s /sbin/nologin -c "grafana-agent user" grafana-agent + useradd -m -r -g "$GRAFANA_AGENT_GROUP" -d /var/lib/grafana-agent -s /sbin/nologin -c "grafana-agent user" "$GRAFANA_AGENT_USER" + fi + + # Add grafana agent user to groups used for reading logs. + if ! getent group adm > /dev/null 2>&1 ; then + usermod -a -G adm "$GRAFANA_AGENT_USER" + fi + if ! getent group systemd-journal > /dev/null 2>&1 ; then + usermod -a -G systemd-journal "$GRAFANA_AGENT_USER" fi chmod 640 /etc/grafana-agent.yaml