@cryptotaxi247 / netdata-1 / commits / 68dbbc73f

netdata/packaging/installer: nits and fixes (#6121)

* netdata: fix attempt for labels * Revert "netdata: fix attempt for labels" This reverts commit b61525925f5a6d752eac97e4a1cd7af915567ad2. * netdata: fix attempt for labels (2) * netdata/packaging/installer: Improvements over netdata installer process around go.d plugin 1) Align retries and timeouts between curl and wget scenarios, should take same time with either tool 2) Add more information when reaching the two error cases, to instruct the user on how to handle the errors 3) Make the download failure a soft error, just warn about skipping install 4) Rename download to download_go, we only run it for go so make this crystal clear * netdata/packaging/installer: when download has not succeeded, warn the user abort the go.d install and continue * netdata/packaging: Enforce usage of predefined start/stop commands for netdata. Add some verbosity too for visibility * netdata/packaging/installer: FreeBSD install - add a note for rc setup, then during first start up use onestart to avoid confusing warnings * netdata/packaging: Add newer debian supported versions, also a info print nit * netdata/packaging: Attend first feedback - use separate variable for the command needed by installer * netdata/packaging: make POSIX compliant equalities. The double equal sign is not working on all shells (dash for example) * netdata/packaging: fix missed md5sum update in README.md * netdata/packaging: revert debian selection - got misguided I obviously didnt test correctly and i misread the release notes, i didnt check the introduction of systemd during jessie release, i only looked for mentions in stretch. So revert this change and retest both on droplet and container installations * netdata/packaging: MacOS - silence a few unimportant errors, make initial detection friendlier 1) Silence failure of commands that are expected to fail on mac 2) add alternatives to uname, to match mac syntax for friendlier output * netdata/packaging: Update README.md * netdata/packaging: Adjustments from PR feedback 1) inform about disable-go when bailing out on download failure 2) Make sure you fail the download if the file is empty 3) Make sure you bail out if checksum fails * netdata/packaging/ci: revert download timeout logic for wget -- seems that there was an exceptional case on wget requiring this differentiation as per cakrits comments -- will revise later, as this is not critical to change

Paul Emm. Katsoulakis committed May 27, 2019 at 13:40 UTC 68dbbc73f751ecc739ec3614aa66865d197f25ea
7 files changed +67 -32
netdata-installer.sh
+29 -9
@@ -44,15 +44,21 @@ else
44 source "${NETDATA_SOURCE_DIR}/packaging/installer/functions.sh" || exit 1
45 fi
46
47 -download() {
47 +download_go() {
48 url="${1}"
49 dest="${2}"
50 +
51 if command -v curl >/dev/null 2>&1; then
51 - run curl -sSL --connect-timeout 10 --retry 3 "${url}" >"${dest}" || fatal "Cannot download ${url}"
52 + run curl -sSL --connect-timeout 10 --retry 3 "${url}" > "${dest}"
53 elif command -v wget >/dev/null 2>&1; then
53 - run wget -T 15 -O - "${url}" >"${dest}" || fatal "Cannot download ${url}"
54 + run wget -T 15 -O - "${url}" > "${dest}"
55 else
55 - fatal "I need curl or wget to proceed, but neither is available on this system."
56 + echo >&2
57 + echo >&2 "Downloading go.d plugin from '${url}' failed because of missing mandatory packages."
58 + echo >&2 "Either add packages or disable it by issuing '--disable-go' in the installer"
59 + echo >&2
60 +
61 + run_failed "I need curl or wget to proceed, but neither is available on this system."
62 fi
63 }
64
@@ -775,24 +781,37 @@ install_go() {
781 for index in "${ARCH_MAP[@]}" ; do
782 KEY="${index%%::*}"
783 VALUE="${index##*::}"
778 - if [ "$KEY" == "$ARCH" ]; then
784 + if [ "$KEY" = "$ARCH" ]; then
785 ARCH="${VALUE}"
786 break
787 fi
788 done
789 tmp=$(mktemp -d /tmp/netdata-go-XXXXXX)
784 - GO_PACKAGE_BASENAME="go.d.plugin-$GO_PACKAGE_VERSION.$OS-$ARCH"
790 + GO_PACKAGE_BASENAME="go.d.plugin-${GO_PACKAGE_VERSION}.${OS}-${ARCH}"
791 +
792 + download_go "https://github.com/netdata/go.d.plugin/releases/download/${GO_PACKAGE_VERSION}/${GO_PACKAGE_BASENAME}" "${tmp}/${GO_PACKAGE_BASENAME}"
793
786 - download "https://github.com/netdata/go.d.plugin/releases/download/$GO_PACKAGE_VERSION/$GO_PACKAGE_BASENAME" "${tmp}/$GO_PACKAGE_BASENAME"
794 + download_go "https://github.com/netdata/go.d.plugin/releases/download/${GO_PACKAGE_VERSION}/config.tar.gz" "${tmp}/config.tar.gz"
795 +
796 + if [ ! -f "${tmp}/${GO_PACKAGE_BASENAME}" ] || [ ! -f "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/config.tar.gz" ] || [ ! -s "${tmp}/${GO_PACKAGE_BASENAME}" ]; then
797 + run_failed "go.d plugin download failed, go.d plugin will not be available"
798 + echo >&2 "Either check the error or consider disabling it by issuing '--disable-go' in the installer"
799 + echo >&2
800 + return 0
801 + fi
802
788 - download "https://github.com/netdata/go.d.plugin/releases/download/$GO_PACKAGE_VERSION/config.tar.gz" "${tmp}/config.tar.gz"
803 grep "${GO_PACKAGE_BASENAME}\$" "${INSTALLER_DIR}/packaging/go.d.checksums" > "${tmp}/sha256sums.txt" 2>/dev/null
804 grep "config.tar.gz" "${INSTALLER_DIR}/packaging/go.d.checksums" >> "${tmp}/sha256sums.txt" 2>/dev/null
805
806 # Checksum validation
807 if ! (cd "${tmp}" && safe_sha256sum -c "sha256sums.txt"); then
808 +
809 + echo >&2 "go.d plugin checksum validation failure."
810 + echo >&2 "Either check the error or consider disabling it by issuing '--disable-go' in the installer"
811 + echo >&2
812 +
813 run_failed "go.d.plugin package files checksum validation failed."
795 - return 1
814 + return 0
815 fi
816
817 # Install new files
@@ -818,6 +837,7 @@ NETDATA_START_CMD="${NETDATA_PREFIX}/usr/sbin/netdata"
837
838 if grep -q docker /proc/1/cgroup >/dev/null 2>&1; then
839 echo >&2 "We are running within a docker container, will not be installing netdata service"
840 + echo >&2
841 else
842 install_netdata_service || run_failed "Cannot install netdata init service."
843 fi
packaging/installer/README.md
+2 -2
@@ -44,7 +44,7 @@ bash <(curl -Ss https://my-netdata.io/kickstart.sh)
44 Verify the integrity of the script with this:
45
46 ```bash
47 -[ "fe451cd039c8f99b2ba4ca0feab88033" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
47 +[ "8a2b054081a108dff915994ce77f2f2d" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
48 ```
49 *It should print `OK, VALID` if the script is the one we ship.*
50
@@ -101,7 +101,7 @@ To install Netdata with a binary package on any Linux distro, any kernel version
101 Verify the integrity of the script with this:
102
103 ```bash
104 -[ "9ff4f5f37d23dff431f80d5349e0a25c" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
104 +[ "8779d8717ccaa8dac18d599502eef591" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
105 ```
106
107 *It should print `OK, VALID` if the script is the one we ship.*
packaging/installer/functions.sh
+28 -13
@@ -332,6 +332,8 @@ install_non_systemd_init() {
332
333 NETDATA_START_CMD="netdata"
334 NETDATA_STOP_CMD="killall netdata"
335 +NETDATA_INSTALLER_START_CMD="${NETDATA_START_CMD}"
336 +NETDATA_INSTALLER_STOP_CMD="${NETDATA_STOP_CMD}"
337
338 install_netdata_service() {
339 local uname="$(uname 2>/dev/null)"
@@ -351,15 +353,23 @@ install_netdata_service() {
353
354 elif [ "${uname}" = "FreeBSD" ]; then
355
354 - run cp system/netdata-freebsd /etc/rc.d/netdata &&
355 - NETDATA_START_CMD="service netdata start" &&
356 - NETDATA_STOP_CMD="service netdata stop" &&
357 - return 0
356 + run cp system/netdata-freebsd /etc/rc.d/netdata && NETDATA_START_CMD="service netdata start" &&
357 + NETDATA_STOP_CMD="service netdata stop" &&
358 + NETDATA_INSTALLER_START_CMD="service netdata onestart" &&
359 + NETDATA_INSTALLER_STOP_CMD="${NETDATA_STOP_CMD}"
360 + myret=$?
361 +
362 + echo >&2 "Note: To explicitly enable netdata automatic start, set 'netdata_enable' to 'YES' in /etc/rc.conf"
363 + echo >&2 ""
364 +
365 + return ${myret}
366
367 elif issystemd; then
368 # systemd is running on this system
369 NETDATA_START_CMD="systemctl start netdata"
370 NETDATA_STOP_CMD="systemctl stop netdata"
371 + NETDATA_INSTALLER_START_CMD="${NETDATA_START_CMD}"
372 + NETDATA_INSTALLER_STOP_CMD="${NETDATA_STOP_CMD}"
373
374 SYSTEMD_DIRECTORY=""
375
@@ -390,6 +400,8 @@ install_netdata_service() {
400 NETDATA_START_CMD="rc-service netdata start"
401 NETDATA_STOP_CMD="rc-service netdata stop"
402 fi
403 + NETDATA_INSTALLER_START_CMD="${NETDATA_START_CMD}"
404 + NETDATA_INSTALLER_STOP_CMD="${NETDATA_STOP_CMD}"
405 fi
406
407 return ${ret}
@@ -429,6 +441,7 @@ stop_netdata_on_pid() {
441 ret=$?
442
443 test ${ret} -eq 0 && printf >&2 "." && sleep 2
444 +
445 done
446
447 echo >&2
@@ -446,8 +459,6 @@ netdata_pids() {
459
460 myns="$(readlink /proc/self/ns/pid 2>/dev/null)"
461
449 - # echo >&2 "Stopping a (possibly) running netdata (namespace '${myns}')..."
450 -
462 for p in \
463 $(cat /var/run/netdata.pid 2>/dev/null) \
464 $(cat /var/run/netdata/netdata.pid 2>/dev/null) \
@@ -477,12 +488,15 @@ restart_netdata() {
488
489 local started=0
490
480 - progress "Start netdata"
491 + progress "Restarting netdata instance"
492
493 if [ "${UID}" -eq 0 ]; then
483 - service netdata stop
484 - stop_all_netdata
485 - service netdata restart && started=1
494 + echo >&2
495 + echo >&2 "Stopping all netdata threads"
496 + run stop_all_netdata
497 +
498 + echo >&2 "Starting netdata using command '${NETDATA_INSTALLER_START_CMD}'"
499 + run ${NETDATA_INSTALLER_START_CMD} && started=1
500
501 if [ ${started} -eq 1 ] && [ -z "$(netdata_pids)" ]; then
502 echo >&2 "Ooops! it seems netdata is not started."
@@ -490,7 +504,8 @@ restart_netdata() {
504 fi
505
506 if [ ${started} -eq 0 ]; then
493 - service netdata start && started=1
507 + echo >&2 "Attempting another netdata start using command '${NETDATA_INSTALLER_START_CMD}'"
508 + run ${NETDATA_INSTALLER_START_CMD} && started=1
509 fi
510 fi
511
@@ -500,8 +515,8 @@ restart_netdata() {
515 fi
516
517 if [ ${started} -eq 0 ]; then
503 - # still not started...
504 -
518 + # still not started... another forced attempt, just run the binary
519 + echo >&2 "Netdata service still not started, attempting another forced restart by running '${netdata} ${@}'"
520 run stop_all_netdata
521 run "${netdata}" "${@}"
522 return $?
packaging/installer/kickstart-static64.sh
+1 -1
@@ -127,7 +127,7 @@ download() {
127 }
128
129 set_tarball_urls() {
130 - if [ "$1" == "stable" ]; then
130 + if [ "$1" = "stable" ]; then
131 local latest
132 # Simple version
133 # latest="$(curl -sSL https://api.github.com/repos/netdata/netdata/releases/latest | grep tag_name | cut -d'"' -f4)"
packaging/installer/kickstart.sh
+5 -5
@@ -141,7 +141,7 @@ warning() {
141
142 create_tmp_directory() {
143 # Check if tmp is mounted as noexec
144 - if grep -Eq '^[^ ]+ /tmp [^ ]+ ([^ ]*,)?noexec[, ]' /proc/mounts; then
144 + if grep -Eq '^[^ ]+ /tmp [^ ]+ ([^ ]*,)?noexec[, ]' /proc/mounts > /dev/null 2>&1; then
145 pattern="$(pwd)/netdata-kickstart-XXXXXX"
146 else
147 pattern="/tmp/netdata-kickstart-XXXXXX"
@@ -163,7 +163,7 @@ download() {
163 }
164
165 set_tarball_urls() {
166 - if [ "$1" == "stable" ]; then
166 + if [ "$1" = "stable" ]; then
167 local latest
168 # Simple version
169 # latest="$(curl -sSL https://api.github.com/repos/netdata/netdata/releases/latest | grep tag_name | cut -d'"' -f4)"
@@ -200,9 +200,9 @@ detect_bash4() {
200 }
201
202 dependencies() {
203 - SYSTEM="$(uname -s)"
204 - OS="$(uname -o)"
205 - MACHINE="$(uname -m)"
203 + SYSTEM="$(uname -s 2> /dev/null || uname -v)"
204 + OS="$(uname -o 2> /dev/null || uname -rs)"
205 + MACHINE="$(uname -m 2> /dev/null)"
206
207 echo "System : ${SYSTEM}"
208 echo "Operating System : ${OS}"
packaging/installer/netdata-uninstaller.sh
+1 -1
@@ -232,7 +232,7 @@ quit_msg() {
232
233 user_input() {
234 TEXT="$1"
235 - if [ "${INTERACTIVITY}" == "-i" ]; then
235 + if [ "${INTERACTIVITY}" = "-i" ]; then
236 read -r -p "$TEXT" >&2
237 fi
238 }
packaging/installer/netdata-updater.sh
+1 -1
@@ -73,7 +73,7 @@ set_tarball_urls() {
73 return
74 fi
75
76 - if [ "$1" == "stable" ]; then
76 + if [ "$1" = "stable" ]; then
77 local latest
78 # Simple version
79 # latest="$(curl -sSL https://api.github.com/repos/netdata/netdata/releases/latest | grep tag_name | cut -d'"' -f4)"