summaryrefslogtreecommitdiffstats
path: root/packaging/makeself/install-or-update.sh
diff options
context:
space:
mode:
authorPaul Emm. Katsoulakis <34388743+paulkatsoulakis@users.noreply.github.com>2019-04-05 11:47:18 +0200
committerGitHub <noreply@github.com>2019-04-05 11:47:18 +0200
commite1f7a105c4a08cd7ae4bd6fc79f022d1d59dcd8a (patch)
tree74fa69f3965e16c6568cb8ecea0839fe6a0a4c73 /packaging/makeself/install-or-update.sh
parent01b91117caecce0d50020a51673b9d3b3b0e01f0 (diff)
netdata/packaging/installer: HoS situation - Fix broken install-or-update script (#5806)
During the last major installer refactoring, we managed to break (again) the static64 installer. We modified the code that defines user/group ownerships for netdata installation, forcing the install to end up with a process running as netdata and files set as root To fix this, we re-instate default NETDATA_USER/NETDATA_GROUP to root, as it should be. Then we attempt group netadata creation. If that succeeds, we attempt user netdata creation. If that succeeds, we attempt secondary groups addition. Report errors on all otherwise situations from each step.
Diffstat (limited to 'packaging/makeself/install-or-update.sh')
-rwxr-xr-xpackaging/makeself/install-or-update.sh35
1 files changed, 18 insertions, 17 deletions
diff --git a/packaging/makeself/install-or-update.sh b/packaging/makeself/install-or-update.sh
index 1c65533a7a..2ab50a17cf 100755
--- a/packaging/makeself/install-or-update.sh
+++ b/packaging/makeself/install-or-update.sh
@@ -69,27 +69,28 @@ then
fi
# -----------------------------------------------------------------------------
-progress "Add user netdata to required user groups"
+progress "Attempt to create user/group netdata/netadata"
NETDATA_WANTED_GROUPS="docker nginx varnish haproxy adm nsd proxy squid ceph nobody"
NETDATA_ADDED_TO_GROUPS=""
-if [ "${UID}" -eq 0 ]; then
- if ! portable_add_group netdata; then
- run_failed "Failed to add netdata group"
- NETDATA_GROUP="root"
- fi
- if ! portable_add_user netdata "/opt/netdata"; then
- run_failed "Failed to add netdata user"
- NETDATA_USER="root"
- fi
-
- for g in ${NETDATA_WANTED_GROUPS}; do
- # shellcheck disable=SC2086
- portable_add_user_to_group ${g} netdata && NETDATA_ADDED_TO_GROUPS="${NETDATA_ADDED_TO_GROUPS} ${g}" || run_failed "Failed to add netdata user to secondary groups"
- done
+# Default user/group
+NETDATA_USER="root"
+NETDATA_GROUP="root"
+
+if portable_add_group netdata; then
+ if portable_add_user netdata "/opt/netdata"; then
+ progress "Add user netdata to required user groups"
+ for g in ${NETDATA_WANTED_GROUPS}; do
+ # shellcheck disable=SC2086
+ portable_add_user_to_group ${g} netdata && NETDATA_ADDED_TO_GROUPS="${NETDATA_ADDED_TO_GROUPS} ${g}" || run_failed "Failed to add netdata user to secondary groups"
+ done
+ NETDATA_USER="netdata"
+ NETDATA_GROUP="netdata"
+ else
+ run_failed "I could not add user netdata, will be using root"
+ fi
else
- run_failed "Failed to add netdata user and group"
- run_failed "The installer does not run as root."
+ run_failed "I could not add group netdata, so no user netdata will be created as well. Netdata run as root:root"
fi
# -----------------------------------------------------------------------------