Browse Source

revert #5457 and test if files exist after installation (#5460)

[netdata patch release]
Paweł Krupa 6 years ago
parent
commit
24c500a1ce

+ 5 - 17
netdata-installer.sh

@@ -43,16 +43,12 @@ fi
 download() {
 	url="${1}"
 	dest="${2}"
-	if command -v wget >/dev/null 2>&1; then
-		if [ -t 1 ]; then
-			run wget --timeout=5 --tries=3 -O - "${url}" >"${dest}"
-		else
-			run wget --timeout=5 --tries=3 --progress=dot:mega -O - "${url}" >"${dest}"
-		fi
-	elif command -v curl >/dev/null 2>&1; then
-		run curl -L --connect-timeout 10 --retry 3 "${url}" >"${dest}"
+	if command -v curl >/dev/null 2>&1; then
+		run curl -L --connect-timeout 5 --retry 3 "${url}" >"${dest}" || fatal "Cannot download ${url}"
+	elif command -v wget >/dev/null 2>&1; then
+		run wget -T 15 -O - "${url}" >"${dest}" || fatal "Cannot download ${url}"
 	else
-		echo >&2 "I need curl or wget to proceed, but neither is available on this system."
+		fatal "I need curl or wget to proceed, but neither is available on this system."
 	fi
 }
 
@@ -816,16 +812,8 @@ install_go() {
 		GO_PACKAGE_BASENAME="go.d.plugin-$GO_PACKAGE_VERSION.$OS-$ARCH"
 
 		download "https://github.com/netdata/go.d.plugin/releases/download/$GO_PACKAGE_VERSION/$GO_PACKAGE_BASENAME" "${tmp}/$GO_PACKAGE_BASENAME"
-		if [ $? ] ; then
-			echo >&2 "go.d.plugin package could not be downloaded"
-			return 1
-		fi
 
 		download "https://github.com/netdata/go.d.plugin/releases/download/$GO_PACKAGE_VERSION/config.tar.gz" "${tmp}/config.tar.gz"
-		if [ $? ] ; then
-			echo >&2 "go.d.plugin config could not be downloaded"
-			return 1
-		fi
 		grep "${GO_PACKAGE_BASENAME}" "${installer_dir}/packaging/go.d.checksums" > "${tmp}/sha256sums.txt" 2>/dev/null
 		grep "config.tar.gz" "${installer_dir}/packaging/go.d.checksums" >> "${tmp}/sha256sums.txt" 2>/dev/null
 

+ 4 - 0
packaging/installer/functions.sh

@@ -189,6 +189,10 @@ portable_find_processors() {
 portable_find_processors
 
 # -----------------------------------------------------------------------------
+fatal() {
+	printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${*} \n\n"
+	exit 1
+}
 
 run_ok() {
 	printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} ${*} \n\n"

+ 4 - 4
packaging/installer/kickstart-static64.sh

@@ -83,10 +83,10 @@ fatal() {
 download() {
 	url="${1}"
 	dest="${2}"
-	if command -v wget >/dev/null 2>&1; then
-		run wget -O - "${url}" >"${dest}" || fatal "Cannot download ${url}"
-	elif command -v curl >/dev/null 2>&1; then
-		run curl -L "${url}" >"${dest}" || fatal "Cannot download ${url}"
+	if command -v curl >/dev/null 2>&1; then
+		run curl -L --connect-timeout 5 --retry 3 "${url}" >"${dest}" || fatal "Cannot download ${url}"
+	elif command -v wget >/dev/null 2>&1; then
+		run wget -T 15 -O - "${url}" >"${dest}" || fatal "Cannot download ${url}"
 	else
 		fatal "I need curl or wget to proceed, but neither is available on this system."
 	fi

+ 4 - 4
packaging/installer/kickstart.sh

@@ -115,10 +115,10 @@ fatal() {
 download() {
 	url="${1}"
 	dest="${2}"
-	if command -v wget >/dev/null 2>&1; then
-		run wget -O - "${url}" >"${dest}" || fatal "Cannot download ${url}"
-	elif command -v curl >/dev/null 2>&1; then
-		run curl -L "${url}" >"${dest}" || fatal "Cannot download ${url}"
+	if command -v curl >/dev/null 2>&1; then
+		run curl -L --connect-timeout 5 --retry 3 "${url}" >"${dest}" || fatal "Cannot download ${url}"
+	elif command -v wget >/dev/null 2>&1; then
+		run wget -T 15 -O - "${url}" >"${dest}" || fatal "Cannot download ${url}"
 	else
 		fatal "I need curl or wget to proceed, but neither is available on this system."
 	fi

+ 5 - 5
packaging/installer/netdata-updater.sh

@@ -34,12 +34,12 @@ failed() {
 download() {
 	url="${1}"
 	dest="${2}"
-	if command -v wget >/dev/null 2>&1; then
-		wget -O - "${url}" >"${dest}" 2>&3 || echo >&2 "Cannot download ${url}" >&3 2>&3
-	elif command -v curl >/dev/null 2>&1; then
-		curl -L "${url}" >"${dest}" 2>&3 || echo "Cannot download ${url}" >&3 2>&3
+	if command -v curl >/dev/null 2>&1; then
+		curl -L --connect-timeout 5 --retry 3 "${url}" >"${dest}" || fatal "Cannot download ${url}"
+	elif command -v wget >/dev/null 2>&1; then
+		wget -T 15 -O - "${url}" >"${dest}" || fatal "Cannot download ${url}"
 	else
-		failed "curl or wget is needed to proceed, but neither is available on this system."
+		failed "I need curl or wget to proceed, but neither is available on this system."
 	fi
 }
 

+ 8 - 0
tests/lifecycle.bats

@@ -2,6 +2,11 @@
 
 INSTALLATION="$BATS_TMPDIR/installation"
 ENV="${INSTALLATION}/netdata/etc/netdata/.environment"
+# list of files which need to be checked. Path cannot start from '/'
+FILES="usr/libexec/netdata/plugins.d/go.d.plugin
+       usr/libexec/netdata/plugins.d/charts.d.plugin
+       usr/libexec/netdata/plugins.d/python.d.plugin
+       usr/libexec/netdata/plugins.d/node.d.plugin"
 
 setup() {
 	if [ ! -f .gitignore ];	then
@@ -12,6 +17,9 @@ setup() {
 
 @test "install netdata" {
 	./netdata-installer.sh  --dont-wait --dont-start-it --auto-update --install "${INSTALLATION}"
+	for file in $FILES; do
+		[ ! -f "$BATS_TMPDIR/$file" ]
+	done
 }
 
 @test "update netdata" {