summaryrefslogtreecommitdiffstats
path: root/packaging/installer/functions.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-06 16:11:34 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-06 16:11:34 +0000
commitd079b656b4719739b2247dcd9d46e9bec793095a (patch)
treed2c950c70a776bcf697c963151c5bd959f8a9f03 /packaging/installer/functions.sh
parentReleasing debian version 1.37.1-2. (diff)
downloadnetdata-d079b656b4719739b2247dcd9d46e9bec793095a.tar.xz
netdata-d079b656b4719739b2247dcd9d46e9bec793095a.zip
Merging upstream version 1.38.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'packaging/installer/functions.sh')
-rw-r--r--packaging/installer/functions.sh14
1 files changed, 11 insertions, 3 deletions
diff --git a/packaging/installer/functions.sh b/packaging/installer/functions.sh
index e354ac651..ebb4aab75 100644
--- a/packaging/installer/functions.sh
+++ b/packaging/installer/functions.sh
@@ -396,6 +396,14 @@ get_os_key() {
fi
}
+get_group(){
+ if command -v getent > /dev/null 2>&1; then
+ getent group "${1:-""}"
+ else
+ cat /etc/group | grep "^${1}:"
+ fi
+}
+
issystemd() {
pids=''
p=''
@@ -933,7 +941,7 @@ portable_add_group() {
groupname="${1}"
# Check if group exist
- if cut -d ':' -f 1 < /etc/group | grep "^${groupname}$" 1> /dev/null 2>&1; then
+ if get_group "${groupname}" > /dev/null 2>&1; then
echo >&2 "Group '${groupname}' already exists."
return 0
fi
@@ -969,14 +977,14 @@ portable_add_user_to_group() {
username="${2}"
# Check if group exist
- if ! cut -d ':' -f 1 < /etc/group | grep "^${groupname}$" > /dev/null 2>&1; then
+ if ! get_group "${groupname}" > /dev/null 2>&1; then
echo >&2 "Group '${groupname}' does not exist."
# Don’t treat this as a failure, if the group does not exist we should not be trying to add the user to it.
return 0
fi
# Check if user is in group
- if expr ",$(grep "^${groupname}:" < /etc/group | cut -d ':' -f 4)," : ",""${username}"","; then
+ if get_group "${groupname}" | cut -d ':' -f 4 | grep -wq "${username}"; then
# username is already there
echo >&2 "User '${username}' is already in group '${groupname}'."
return 0