@cryptotaxi247 / netdata-1 / commits / c0c6c4e3f

updated kickstart.sh to work on ubuntu systems

Costa Tsaousis (ktsaou) committed May 27, 2017 at 18:33 UTC c0c6c4e3fecc0bf72215a98976723af1bd27e648
1 file changed +20 -24
kickstart.sh
+20 -24
@@ -153,7 +153,11 @@ run() {
153 # ---------------------------------------------------------------------------------------------------------------------
154 # collect system information
155
156 -set -e
156 +fatal() {
157 + printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} ABORTED ${TPUT_RESET} ${*} \n\n"
158 + exit 1
159 +}
160 +
161 export PATH="${PATH}:/usr/local/bin:/usr/local/sbin"
162
163 curl="$(which_cmd curl)"
@@ -213,18 +217,18 @@ then
217 if [ "${HAS_BASH4}" = "1" ]
218 then
219 tmp="$(mktemp /tmp/netdata-kickstart-XXXXXX)"
220 + url="https://raw.githubusercontent.com/firehol/netdata-demo-site/master/install-required-packages.sh"
221
222 progress "Downloading script to detect required packages..."
223 if [ ! -z "${curl}" ]
224 then
220 - run ${curl} 'https://raw.githubusercontent.com/firehol/netdata-demo-site/master/install-required-packages.sh' >"${tmp}"
225 + run ${curl} "${url}" >"${tmp}" || fatal "Cannot download ${url}"
226 elif [ ! -z "${wget}" ]
227 then
223 - run "${wget}" -O - 'https://raw.githubusercontent.com/firehol/netdata-demo-site/master/install-required-packages.sh' >"${tmp}"
228 + run "${wget}" -O - "${url}" >"${tmp}" || fatal "Cannot download ${url}"
229 else
225 - run_failed "I need curl or wget to proceed, but neither is available on this system."
230 rm "${tmp}"
227 - exit 1
231 + fatal "I need curl or wget to proceed, but neither is available on this system."
232 fi
233
234 ask=0
@@ -234,9 +238,8 @@ then
238 run ${sudo} "${bash}" "${tmp}" ${KICKSTART_OPTIONS} || ask=1
239 rm "${tmp}"
240 else
237 - run_failed "Downloaded script is empty..."
241 rm "${tmp}"
239 - exit 1
242 + fatal "Downloaded script is empty..."
243 fi
244
245 if [ "${ask}" = "1" ]
@@ -275,20 +278,17 @@ then
278 if [ ! -d "${SOURCE_DST}/netdata.git" ]
279 then
280 progress "Downloading netdata source code..."
278 - run ${sudo} ${git} clone https://github.com/firehol/netdata.git "${SOURCE_DST}/netdata.git"
279 - cd "${SOURCE_DST}/netdata.git"
281 + run ${sudo} ${git} clone https://github.com/firehol/netdata.git "${SOURCE_DST}/netdata.git" || fatal "Cannot download netdata source"
282 + cd "${SOURCE_DST}/netdata.git" || fatal "Cannot cd to netdata source tree"
283 else
284 progress "Updating netdata source code..."
282 - cd "${SOURCE_DST}/netdata.git"
283 - run ${sudo} ${git} fetch --all
284 - run ${sudo} ${git} reset --hard origin/master
285 + cd "${SOURCE_DST}/netdata.git" || fatal "Cannot cd to netdata source tree"
286 + run ${sudo} ${git} fetch --all || fatal "Cannot fetch netdata source updates"
287 + run ${sudo} ${git} reset --hard origin/master || fatal "Cannot update netdata source tree"
288 fi
289 NETDATA_SOURCE_DIR="${SOURCE_DST}/netdata.git"
290 else
288 - echo >&2 "ERROR"
289 - echo >&2 "Cannot find the command 'git' to download the netdata source code."
290 - echo >&2
291 - exit 1
291 + fatal "Cannot find the command 'git' to download the netdata source code."
292 fi
293
294
@@ -297,7 +297,7 @@ fi
297
298 if [ ! -z "${NETDATA_SOURCE_DIR}" -a -d "${NETDATA_SOURCE_DIR}" ]
299 then
300 - cd "${NETDATA_SOURCE_DIR}"
300 + cd "${NETDATA_SOURCE_DIR}" || fatal "Cannot cd to netdata source tree"
301
302 install=0
303 if [ -x netdata-updater.sh ]
@@ -314,15 +314,11 @@ then
314 if [ -x netdata-installer.sh ]
315 then
316 progress "Installing netdata..."
317 - run ${sudo} ./netdata-installer.sh -u "${@}"
317 + run ${sudo} ./netdata-installer.sh -u "${@}" || fatal "netdata-installer.sh exited with error"
318 else
319 - echo >&2 "ERROR"
320 - echo >&2 "Cannot install netdata from source (the source directory does not include netdata-installer.sh)."
321 - exit 1
319 + fatal "Cannot install netdata from source (the source directory does not include netdata-installer.sh)."
320 fi
321 fi
322 else
325 - echo >&2 "ERROR"
326 - echo >&2 "Cannot install netdata from source, on this system (cannot download the source code)."
327 - exit 1
323 + fatal "Cannot install netdata from source, on this system (cannot download the source code)."
324 fi