diff options
author | Paul Katsoulakis <34388743+paulkatsoulakis@users.noreply.github.com> | 2019-03-29 14:52:03 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-29 14:52:03 +0000 |
commit | c8d2e6c7d3b955b6d5781e2710b02bccc29a3c79 (patch) | |
tree | 128c5354ba1d88e998d9fbbee0f7739f3ef2f073 /packaging/makeself | |
parent | d97423136f70f69d9bbc4364f863d734d13905ff (diff) |
netdata/packaging/installer: netdata-installer.sh script (and subscripts) refactoring wrap-up (#5736)
* remove dead quickfix
* unify global variable naming
* do not use double negation
* simplify setcap detection
* simplify logic of setting capabilities to apps.plugin
* always set group in chown
* simplify parameter parsing and banner notifications
* use built-in command for checking program availability
* lint functions.sh
* fix errors returned by shellcheck
* remove unused functions and use portable_service
* move user management functions closer together and remove "check" functions to reduce levels of indirection
* extract add_netdata_user_and_group and move it into installers for better code readability
* improve readability by not using global variable holding number of processors
* move netdata.conf file creation into one function
* revert migration to portable_service
* Less verbose setcap
* remove TODOs
* do not show output when not needed
* fix checking for group existence
* fix variable name
* netdata/packaging/installer: Dont spill out unnecessary output in stdout/stderr, it may confuse our users
The second commit was a follow up cleanup on nits.
* access: change codeowner
* Revert "access: change codeowner"
This reverts commit 6ee51ccae960584d5b1b7c243f5aabf046a99eff.
sorry, wrong repo
* netdata/packaging/installer: bug fix - do not use pidof as the name of the helper method
1) rename to safe_pidof, which is actually more accurate and describe what this method serves for (safe pid detection)
2) Renaming it also avoids the bug introduced by the usage of , that resulted in endless nested calls of the BASH method pidif
(Refer to command -v usage)
Diffstat (limited to 'packaging/makeself')
-rwxr-xr-x | packaging/makeself/install-or-update.sh | 46 | ||||
-rwxr-xr-x | packaging/makeself/jobs/50-bash-4.4.18.install.sh | 2 | ||||
-rwxr-xr-x | packaging/makeself/jobs/50-curl-7.60.0.install.sh | 2 | ||||
-rwxr-xr-x | packaging/makeself/jobs/50-fping-4.2.install.sh | 2 |
4 files changed, 30 insertions, 22 deletions
diff --git a/packaging/makeself/install-or-update.sh b/packaging/makeself/install-or-update.sh index bfcbe720aa..1c65533a7a 100755 --- a/packaging/makeself/install-or-update.sh +++ b/packaging/makeself/install-or-update.sh @@ -71,18 +71,27 @@ fi # ----------------------------------------------------------------------------- progress "Add user netdata to required user groups" -NETDATA_USER="root" -NETDATA_GROUP="root" -add_netdata_user_and_group "/opt/netdata" -if [ $? -eq 0 ] - then - NETDATA_USER="netdata" - NETDATA_GROUP="netdata" +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 else - run_failed "Failed to add netdata user and group" + run_failed "Failed to add netdata user and group" + run_failed "The installer does not run as root." fi - # ----------------------------------------------------------------------------- progress "Check SSL certificates paths" @@ -206,20 +215,19 @@ fi # ----------------------------------------------------------------------------- -if [ ${STARTIT} -eq 1 ] -then +if [ ${STARTIT} -eq 0 ]; then + create_netdata_conf "/opt/netdata/etc/netdata/netdata.conf" + netdata_banner "is installed now!" +else progress "starting netdata" - restart_netdata "/opt/netdata/bin/netdata" - if [ $? -eq 0 ] - then - download_netdata_conf "${NETDATA_USER}:${NETDATA_GROUP}" "/opt/netdata/etc/netdata/netdata.conf" "http://localhost:19999/netdata.conf" + if ! restart_netdata "/opt/netdata/bin/netdata"; then + create_netdata_conf "/opt/netdata/etc/netdata/netdata.conf" netdata_banner "is installed and running now!" else - generate_netdata_conf "${NETDATA_USER}:${NETDATA_GROUP}" "/opt/netdata/etc/netdata/netdata.conf" "http://localhost:19999/netdata.conf" + create_netdata_conf "/opt/netdata/etc/netdata/netdata.conf" "http://localhost:19999/netdata.conf" netdata_banner "is installed now!" fi -else - generate_netdata_conf "${NETDATA_USER}:${NETDATA_GROUP}" "/opt/netdata/etc/netdata/netdata.conf" "http://localhost:19999/netdata.conf" - netdata_banner "is installed now!" fi +run chown "${NETDATA_USER}:${NETDATA_GROUP}" "/opt/netdata/etc/netdata/netdata.conf" +run chmod 0664 "/opt/netdata/etc/netdata/netdata.conf" diff --git a/packaging/makeself/jobs/50-bash-4.4.18.install.sh b/packaging/makeself/jobs/50-bash-4.4.18.install.sh index 3bdf3e7518..a762d37aef 100755 --- a/packaging/makeself/jobs/50-bash-4.4.18.install.sh +++ b/packaging/makeself/jobs/50-bash-4.4.18.install.sh @@ -38,7 +38,7 @@ run ./configure \ run make clean -run make -j${SYSTEM_CPUS} +run make -j$(find_processors) cat >examples/loadables/Makefile <<EOF all: diff --git a/packaging/makeself/jobs/50-curl-7.60.0.install.sh b/packaging/makeself/jobs/50-curl-7.60.0.install.sh index 2b5c8f1394..c91598251f 100755 --- a/packaging/makeself/jobs/50-curl-7.60.0.install.sh +++ b/packaging/makeself/jobs/50-curl-7.60.0.install.sh @@ -25,7 +25,7 @@ run ./configure \ run sed -i -e "s/curl_LDFLAGS =/curl_LDFLAGS = -all-static/" src/Makefile run make clean -run make -j${SYSTEM_CPUS} +run make -j$(find_processors) run make install if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ] diff --git a/packaging/makeself/jobs/50-fping-4.2.install.sh b/packaging/makeself/jobs/50-fping-4.2.install.sh index b1acfa2e45..a137753d8e 100755 --- a/packaging/makeself/jobs/50-fping-4.2.install.sh +++ b/packaging/makeself/jobs/50-fping-4.2.install.sh @@ -20,7 +20,7 @@ install: EOF run make clean -run make -j${SYSTEM_CPUS} +run make -j$(find_processors) run make install if [ ${NETDATA_BUILD_WITH_DEBUG} -eq 0 ] |