allow kickstart.sh to run unattainted with --dont-wait or --non-interactive; fixes #2305
Costa Tsaousis (ktsaou) committed
Jun 11, 2017 at 19:32 UTC
8351d165bad46f2f5abfc68cf662a682bd8fa44b
1 file changed
+28
-8
kickstart.sh
+28
-8
@@ -176,6 +176,7 @@ export PATH="${PATH}:/usr/local/bin:/usr/local/sbin"
176
curl="$(which_cmd curl)"
177
wget="$(which_cmd wget)"
178
bash="$(which_cmd bash)"
179
+git="$(which_cmd git)"
180
181
if [ -z "${BASH_VERSION}" ]
182
then
@@ -218,13 +219,33 @@ sudo=""
219
# ---------------------------------------------------------------------------------------------------------------------
220
# install required system packages
221
221
-KICKSTART_OPTIONS="netdata"
222
-if [ "${1}" = "all" ]
222
+INTERACTIVE=1
223
+PACKAGES_INSTALLER_OPTIONS="netdata"
224
+NETDATA_INSTALLER_OPTIONS=""
225
+while [ ! -z "${1}" ]
226
+do
227
+ if [ "${1}" = "all" ]
228
+ then
229
+ PACKAGES_INSTALLER_OPTIONS="netdata-all"
230
+ shift 1
231
+ elif [ "${1}" = "--dont-wait" -o "${1}" = "--non-interactive" ]
232
+ then
233
+ INTERACTIVE=0
234
+ shift 1
235
+ else
236
+ break
237
+ fi
238
+done
239
+
240
+if [ "${INTERACTIVE}" = "0" ]
241
then
224
- KICKSTART_OPTIONS="netdata-all"
225
- shift 1
242
+ PACKAGES_INSTALLER_OPTIONS="--dont-wait --non-interactive ${PACKAGES_INSTALLER_OPTIONS}"
243
+ NETDATA_INSTALLER_OPTIONS="--dont-wait"
244
fi
245
246
+# echo "PACKAGES_INSTALLER_OPTIONS=${PACKAGES_INSTALLER_OPTIONS}"
247
+# echo "NETDATA_INSTALLER_OPTIONS=${NETDATA_INSTALLER_OPTIONS} ${*}"
248
+
249
if [ "${OS}" = "GNU/Linux" -o "${SYSTEM}" = "Linux" ]
250
then
251
if [ "${HAS_BASH4}" = "1" ]
@@ -248,7 +269,7 @@ then
269
if [ -s "${tmp}" ]
270
then
271
progress "Running downloaded script to detect required packages..."
251
- run ${sudo} "${bash}" "${tmp}" ${KICKSTART_OPTIONS} || ask=1
272
+ run ${sudo} "${bash}" "${tmp}" ${PACKAGES_INSTALLER_OPTIONS} || ask=1
273
rm "${tmp}"
274
else
275
rm "${tmp}"
@@ -278,8 +299,6 @@ fi
299
# ---------------------------------------------------------------------------------------------------------------------
300
# download netdata source
301
281
-git="$(which_cmd git)"
282
-
302
NETDATA_SOURCE_DIR=
303
if [ ! -z "${git}" -a -x "${git}" ]
304
then
@@ -326,7 +345,8 @@ then
345
if [ -x netdata-installer.sh ]
346
then
347
progress "Installing netdata..."
329
- run ${sudo} ./netdata-installer.sh -u "${@}" || fatal "netdata-installer.sh exited with error"
348
+ run ${sudo} ./netdata-installer.sh -u ${NETDATA_INSTALLER_OPTIONS} "${@}" || \
349
+ fatal "netdata-installer.sh exited with error"
350
else
351
fatal "Cannot install netdata from source (the source directory does not include netdata-installer.sh)."
352
fi