netdata/packaging: Fix kickstart/kickstart-static64 formatting bugs (#6048)
* netdata/packaging: Fix kickstart/kickstart-static64 formatting bugs, been broken too long i suppose * netdata/packaging: Fix md5sum for kickstarts
Paul Emm. Katsoulakis committed
May 19, 2019 at 12:23 UTC
e003e247d0a3b0ad803dbd9efc730ee56d976e2f
3 files changed
+75
-21
packaging/installer/README.md
+2
-2
@@ -42,7 +42,7 @@ bash <(curl -Ss https://my-netdata.io/kickstart.sh)
42
Verify the integrity of the script with this:
43
44
```bash
45
-[ "15c688e7228ebee83ace1811273cd089" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
45
+[ "fe451cd039c8f99b2ba4ca0feab88033" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
46
```
47
*It should print `OK, VALID` if the script is the one we ship.*
48
@@ -99,7 +99,7 @@ To install Netdata with a binary package on any Linux distro, any kernel version
99
Verify the integrity of the script with this:
100
101
```bash
102
-[ "97427a0fc5a52593b603c2ae887d4466" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
102
+[ "9ff4f5f37d23dff431f80d5349e0a25c" = "$(curl -Ss https://my-netdata.io/kickstart-static64.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
103
```
104
105
*It should print `OK, VALID` if the script is the one we ship.*
packaging/installer/kickstart-static64.sh
+36
-9
@@ -32,13 +32,27 @@ setup_terminal() {
32
33
return 0
34
}
35
+setup_terminal || echo >/dev/null
36
36
-progress() {
37
- echo >&2 " --- ${TPUT_DIM}${TPUT_BOLD}${*}${TPUT_RESET} --- "
37
+# -----------------------------------------------------------------------------
38
+fatal() {
39
+ printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${*} \n\n"
40
+ exit 1
41
+}
42
+
43
+run_ok() {
44
+ printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} ${*} \n\n"
45
}
46
47
+run_failed() {
48
+ printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n"
49
+}
50
+
51
+ESCAPED_PRINT_METHOD=
52
+printf "%q " test >/dev/null 2>&1
53
+[ $? -eq 0 ] && ESCAPED_PRINT_METHOD="printfq"
54
escaped_print() {
41
- if printf "%q " test >/dev/null 2>&1; then
55
+ if [ "${ESCAPED_PRINT_METHOD}" = "printfq" ]; then
56
printf "%q " "${@}"
57
else
58
printf "%s" "${*}"
@@ -46,24 +60,39 @@ escaped_print() {
60
return 0
61
}
62
63
+progress() {
64
+ echo >&2 " --- ${TPUT_DIM}${TPUT_BOLD}${*}${TPUT_RESET} --- "
65
+}
66
+
67
+run_logfile="/dev/null"
68
run() {
50
- local dir="${PWD}" info_console
69
+ local user="${USER--}" dir="${PWD}" info info_console
70
71
if [ "${UID}" = "0" ]; then
72
+ info="[root ${dir}]# "
73
info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]# "
74
else
75
+ info="[${user} ${dir}]$ "
76
info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]$ "
77
fi
78
58
- escaped_print "${info_console}${TPUT_BOLD}${TPUT_YELLOW}" "${@}" "${TPUT_RESET}\n" >&2
79
+ printf >>"${run_logfile}" "${info}"
80
+ escaped_print >>"${run_logfile}" "${@}"
81
+ printf >>"${run_logfile}" " ... "
82
+
83
+ printf >&2 "${info_console}${TPUT_BOLD}${TPUT_YELLOW}"
84
+ escaped_print >&2 "${@}"
85
+ printf >&2 "${TPUT_RESET}\n"
86
87
"${@}"
88
89
local ret=$?
90
if [ ${ret} -ne 0 ]; then
64
- printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n"
91
+ run_failed
92
+ printf >>"${run_logfile}" "FAILED with exit code ${ret}\n"
93
else
66
- printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} ${*} \n\n"
94
+ run_ok
95
+ printf >>"${run_logfile}" "OK\n"
96
fi
97
98
return ${ret}
@@ -130,8 +159,6 @@ sudo=""
159
[ -z "${UID}" ] && UID="$(id -u)"
160
[ "${UID}" -ne "0" ] && sudo="sudo"
161
133
-setup_terminal || echo >/dev/null
134
-
162
# ---------------------------------------------------------------------------------------------------------------------
163
if [ "$(uname -m)" != "x86_64" ]; then
164
fatal "Static binary versions of netdata are available only for 64bit Intel/AMD CPUs (x86_64), but yours is: $(uname -m)."
packaging/installer/kickstart.sh
+37
-10
@@ -58,13 +58,27 @@ setup_terminal() {
58
59
return 0
60
}
61
+setup_terminal || echo >/dev/null
62
62
-progress() {
63
- echo >&2 " --- ${TPUT_DIM}${TPUT_BOLD}${*}${TPUT_RESET} --- "
63
+# -----------------------------------------------------------------------------
64
+fatal() {
65
+ printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${*} \n\n"
66
+ exit 1
67
+}
68
+
69
+run_ok() {
70
+ printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} ${*} \n\n"
71
}
72
73
+run_failed() {
74
+ printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n"
75
+}
76
+
77
+ESCAPED_PRINT_METHOD=
78
+printf "%q " test >/dev/null 2>&1
79
+[ $? -eq 0 ] && ESCAPED_PRINT_METHOD="printfq"
80
escaped_print() {
67
- if printf "%q " test >/dev/null 2>&1; then
81
+ if [ "${ESCAPED_PRINT_METHOD}" = "printfq" ]; then
82
printf "%q " "${@}"
83
else
84
printf "%s" "${*}"
@@ -72,24 +86,39 @@ escaped_print() {
86
return 0
87
}
88
89
+progress() {
90
+ echo >&2 " --- ${TPUT_DIM}${TPUT_BOLD}${*}${TPUT_RESET} --- "
91
+}
92
+
93
+run_logfile="/dev/null"
94
run() {
76
- local dir="${PWD}" info_console
95
+ local user="${USER--}" dir="${PWD}" info info_console
96
97
if [ "${UID}" = "0" ]; then
98
+ info="[root ${dir}]# "
99
info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]# "
100
else
101
+ info="[${user} ${dir}]$ "
102
info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]$ "
103
fi
104
84
- escaped_print "${info_console}${TPUT_BOLD}${TPUT_YELLOW}" "${@}" "${TPUT_RESET}\n" >&2
105
+ printf >>"${run_logfile}" "${info}"
106
+ escaped_print >>"${run_logfile}" "${@}"
107
+ printf >>"${run_logfile}" " ... "
108
+
109
+ printf >&2 "${info_console}${TPUT_BOLD}${TPUT_YELLOW}"
110
+ escaped_print >&2 "${@}"
111
+ printf >&2 "${TPUT_RESET}\n"
112
86
- ${@}
113
+ "${@}"
114
115
local ret=$?
116
if [ ${ret} -ne 0 ]; then
90
- printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n"
117
+ run_failed
118
+ printf >>"${run_logfile}" "FAILED with exit code ${ret}\n"
119
else
92
- printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} ${*} \n\n"
120
+ run_ok
121
+ printf >>"${run_logfile}" "OK\n"
122
fi
123
124
return ${ret}
@@ -224,8 +253,6 @@ sudo=""
253
[ "${UID}" -ne "0" ] && sudo="sudo"
254
export PATH="${PATH}:/usr/local/bin:/usr/local/sbin"
255
227
-setup_terminal || echo >/dev/null
228
-
256
# ---------------------------------------------------------------------------------------------------------------------
257
# try to update using autoupdater in the first place
258