summaryrefslogtreecommitdiffstats
path: root/packaging/installer/kickstart.sh
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2019-05-21 18:56:05 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2019-05-21 18:56:05 +0000
commit54deae27eed83a162ee438ef6bad4a23767757dd (patch)
treeda5333377dfacf22177375aef822a8e696f007eb /packaging/installer/kickstart.sh
parentReleasing debian version 1.14.0-1. (diff)
downloadnetdata-54deae27eed83a162ee438ef6bad4a23767757dd.tar.xz
netdata-54deae27eed83a162ee438ef6bad4a23767757dd.zip
Merging upstream version 1.15.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'packaging/installer/kickstart.sh')
-rwxr-xr-xpackaging/installer/kickstart.sh47
1 files changed, 37 insertions, 10 deletions
diff --git a/packaging/installer/kickstart.sh b/packaging/installer/kickstart.sh
index a8057c19c..2db95f21d 100755
--- a/packaging/installer/kickstart.sh
+++ b/packaging/installer/kickstart.sh
@@ -58,13 +58,27 @@ setup_terminal() {
return 0
}
+setup_terminal || echo >/dev/null
-progress() {
- echo >&2 " --- ${TPUT_DIM}${TPUT_BOLD}${*}${TPUT_RESET} --- "
+# -----------------------------------------------------------------------------
+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"
}
+run_failed() {
+ printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n"
+}
+
+ESCAPED_PRINT_METHOD=
+printf "%q " test >/dev/null 2>&1
+[ $? -eq 0 ] && ESCAPED_PRINT_METHOD="printfq"
escaped_print() {
- if printf "%q " test >/dev/null 2>&1; then
+ if [ "${ESCAPED_PRINT_METHOD}" = "printfq" ]; then
printf "%q " "${@}"
else
printf "%s" "${*}"
@@ -72,24 +86,39 @@ escaped_print() {
return 0
}
+progress() {
+ echo >&2 " --- ${TPUT_DIM}${TPUT_BOLD}${*}${TPUT_RESET} --- "
+}
+
+run_logfile="/dev/null"
run() {
- local dir="${PWD}" info_console
+ local user="${USER--}" dir="${PWD}" info info_console
if [ "${UID}" = "0" ]; then
+ info="[root ${dir}]# "
info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]# "
else
+ info="[${user} ${dir}]$ "
info_console="[${TPUT_DIM}${dir}${TPUT_RESET}]$ "
fi
- escaped_print "${info_console}${TPUT_BOLD}${TPUT_YELLOW}" "${@}" "${TPUT_RESET}\n" >&2
+ printf >>"${run_logfile}" "${info}"
+ escaped_print >>"${run_logfile}" "${@}"
+ printf >>"${run_logfile}" " ... "
+
+ printf >&2 "${info_console}${TPUT_BOLD}${TPUT_YELLOW}"
+ escaped_print >&2 "${@}"
+ printf >&2 "${TPUT_RESET}\n"
- ${@}
+ "${@}"
local ret=$?
if [ ${ret} -ne 0 ]; then
- printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n"
+ run_failed
+ printf >>"${run_logfile}" "FAILED with exit code ${ret}\n"
else
- printf >&2 "${TPUT_BGGREEN}${TPUT_WHITE}${TPUT_BOLD} OK ${TPUT_RESET} ${*} \n\n"
+ run_ok
+ printf >>"${run_logfile}" "OK\n"
fi
return ${ret}
@@ -224,8 +253,6 @@ sudo=""
[ "${UID}" -ne "0" ] && sudo="sudo"
export PATH="${PATH}:/usr/local/bin:/usr/local/sbin"
-setup_terminal || echo >/dev/null
-
# ---------------------------------------------------------------------------------------------------------------------
# try to update using autoupdater in the first place