From 4a726a2c72eef494fb730d005c22eeb15e03e35c Mon Sep 17 00:00:00 2001 From: Lorenzo Affetti Date: Tue, 30 Apr 2019 20:04:45 +0200 Subject: [PATCH] Create telegraf user in pre-install rpm scriptlet (#5783) --- scripts/post-install.sh | 8 -------- scripts/pre-install.sh | 8 ++++++++ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/post-install.sh b/scripts/post-install.sh index 9972364bc6e7d..50bef1081ff44 100644 --- a/scripts/post-install.sh +++ b/scripts/post-install.sh @@ -24,14 +24,6 @@ function install_chkconfig { chkconfig --add telegraf } -if ! grep "^telegraf:" /etc/group &>/dev/null; then - groupadd -r telegraf -fi - -if ! id telegraf &>/dev/null; then - useradd -r -M telegraf -s /bin/false -d /etc/telegraf -g telegraf -fi - # Remove legacy symlink, if it exists if [[ -L /etc/init.d/telegraf ]]; then rm -f /etc/init.d/telegraf diff --git a/scripts/pre-install.sh b/scripts/pre-install.sh index b371f462d36f4..3fad54f61c3bf 100644 --- a/scripts/pre-install.sh +++ b/scripts/pre-install.sh @@ -1,5 +1,13 @@ #!/bin/bash +if ! grep "^telegraf:" /etc/group &>/dev/null; then + groupadd -r telegraf +fi + +if ! id telegraf &>/dev/null; then + useradd -r -M telegraf -s /bin/false -d /etc/telegraf -g telegraf +fi + if [[ -d /etc/opt/telegraf ]]; then # Legacy configuration found if [[ ! -d /etc/telegraf ]]; then