From: Costa Tsaousis (ktsaou) Date: Sun, 25 Sep 2016 23:10:39 +0000 (+0300) Subject: netdata-installer.sh banner is not a snake; fixes #1023 X-Git-Tag: v1.4.0~23^2 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cfb9800f7b56ea515adf5169a99e1db76bb31e78;p=netdata.git netdata-installer.sh banner is not a snake; fixes #1023 --- diff --git a/netdata-installer.sh b/netdata-installer.sh index bdf35015..c3b97243 100755 --- a/netdata-installer.sh +++ b/netdata-installer.sh @@ -28,6 +28,29 @@ printf "\n" >>netdata-installer.log REINSTALL_PWD="${PWD}" REINSTALL_COMMAND="$(printf "%q " "$0" "${@}"; printf "\n")" +banner() { + local l1=" ^" \ + l2=" |.-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-. .-" \ + l3=" | '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' '-' " \ + l4=" +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+--->" \ + sp=" " \ + netdata="netdata" start end msg="${*}" + + [ ${#msg} -lt ${#netdata} ] && msg="${msg}${sp:0:$(( ${#netdata} - ${#msg}))}" + [ ${#msg} -gt $(( ${#l2} - 20 )) ] && msg="${msg:0:$(( ${#l2} - 23 ))}..." + + start="$(( ${#l2} / 2 - 4 ))" + [ $(( start + ${#msg} + 4 )) -gt ${#l2} ] && start=$((${#l2} - ${#msg} - 4)) + end=$(( ${start} + ${#msg} + 4 )) + + echo >&2 + echo >&2 "${l1}" + echo >&2 "${l2:0:start}${sp:0:2}${netdata}${sp:0:$((end - start - 2 - ${#netdata}))}${l2:end:$((${#l2} - end))}" + echo >&2 "${l3:0:start}${sp:0:2}${msg}${sp:0:2}${l3:end:$((${#l2} - end))}" + echo >&2 "${l4}" + echo >&2 +} + service="$(which service 2>/dev/null || command -v service 2>/dev/null)" systemctl="$(which systemctl 2>/dev/null || command -v systemctl 2>/dev/null)" service() { @@ -52,6 +75,7 @@ NETDATA_PREFIX= LIBS_ARE_HERE=0 usage() { + banner "installer command line options" cat < @@ -177,26 +201,24 @@ do fi done +banner "real-time performance monitoring, done right!" cat <&2 <<"DONE1" - - - ^ - |.-. .-. .-. .-. .-. netdata .-. .-. .-. .- - | '-' '-' '-' '-' ' is installed now! '-' '-' '-' - +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+---> - - enjoy real-time performance and health monitoring... - -DONE1 + banner "is installed now!" + echo >&2 " enjoy real-time performance and health monitoring..." exit 0 fi @@ -1202,14 +1218,7 @@ elif [ -f "netdata-updater.sh" ] rm "netdata-updater.sh" fi -cat >&2 <<"DONE" - - ^ - |.-. .-. .-. .-. .-. netdata .-. .- - | '-' '-' '-' '-' ' is installed and running now! '-' - +----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+---> - - enjoy real-time performance and health monitoring... - -DONE +banner "is installed and running now!" +echo >&2 " enjoy real-time performance and health monitoring..." +echo >&2 exit 0