@cryptotaxi247 / netdata-1 / commits / 230fbe067

Reorder functions properly in updater script. (#12399)

POSIX shell script requires functions to be defined before first use.

Austin S. Hemmelgarn committed Mar 15, 2022 at 14:21 UTC 230fbe067d7287101443960077466cb9b7a086bc
1 file changed +17 -18
packaging/installer/netdata-updater.sh
+17 -18
@@ -56,6 +56,11 @@ error() {
56 echo >&3 "$(date) : ERROR: " "${@}"
57 }
58
59 +fatal() {
60 + error "FAILED TO UPDATE NETDATA : ${1}"
61 + exit 1
62 +}
63 +
64 : "${ENVIRONMENT_FILE:=THIS_SHOULD_BE_REPLACED_BY_INSTALLER_SCRIPT}"
65
66 if [ "${ENVIRONMENT_FILE}" = "THIS_SHOULD_BE_REPLACED_BY_INSTALLER_SCRIPT" ]; then
@@ -107,18 +112,6 @@ issystemd() {
112 return 1
113 }
114
110 -_get_scheduler_type() {
111 - if _get_intervaldir > /dev/null ; then
112 - echo 'interval'
113 - elif issystemd ; then
114 - echo 'systemd'
115 - elif [ -d /etc/cron.d ] ; then
116 - echo 'crontab'
117 - else
118 - echo 'none'
119 - fi
120 -}
121 -
115 _get_intervaldir() {
116 if [ -d /etc/cron.daily ]; then
117 echo /etc/cron.daily
@@ -131,6 +124,18 @@ _get_intervaldir() {
124 return 0
125 }
126
127 +_get_scheduler_type() {
128 + if _get_intervaldir > /dev/null ; then
129 + echo 'interval'
130 + elif issystemd ; then
131 + echo 'systemd'
132 + elif [ -d /etc/cron.d ] ; then
133 + echo 'crontab'
134 + else
135 + echo 'none'
136 + fi
137 +}
138 +
139 install_build_dependencies() {
140 bash="$(command -v bash 2> /dev/null)"
141
@@ -263,12 +268,6 @@ safe_sha256sum() {
268 fi
269 }
270
266 -# this is what we will do if it fails (head-less only)
267 -fatal() {
268 - error "FAILED TO UPDATE NETDATA : ${1}"
269 - exit 1
270 -}
271 -
271 cleanup() {
272 if [ -n "${logfile}" ]; then
273 cat >&2 "${logfile}"