Properly handle non-interactive installs as non-root users. (#12089)
THis ensures that `sudo` and `doas` properly fail when we are running non-interactively if they would require the user to input a password.
Austin S. Hemmelgarn committed
Feb 10, 2022 at 06:47 UTC
b0b0a12da71c634ba05df8fa5457a7c122c5d5c1
2 files changed
+11
-3
packaging/installer/kickstart.sh
+10
-2
@@ -462,11 +462,19 @@ str_in_list() {
462
confirm_root_support() {
463
if [ "$(id -u)" -ne "0" ]; then
464
if [ -z "${ROOTCMD}" ] && command -v sudo > /dev/null; then
465
- ROOTCMD="sudo"
465
+ if [ "${INTERACTIVE}" -eq 0 ]; then
466
+ ROOTCMD="sudo -n"
467
+ else
468
+ ROOTCMD="sudo"
469
+ fi
470
fi
471
472
if [ -z "${ROOTCMD}" ] && command -v doas > /dev/null; then
469
- ROOTCMD="doas"
473
+ if [ "${INTERACTIVE}" -eq 0 ]; then
474
+ ROOTCMD="doas -n"
475
+ else
476
+ ROOTCMD="doas"
477
+ fi
478
fi
479
480
if [ -z "${ROOTCMD}" ] && command -v pkexec > /dev/null; then
packaging/installer/methods/kickstart.md
+1
-1
@@ -136,7 +136,7 @@ To use `md5sum` to verify the integrity of the `kickstart.sh` script you will do
136
run the following:
137
138
```bash
139
-[ "862580a7c6e4b973b6fcfd907e2f1bbc" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
139
+[ "0cfdc04fd4004f77ebc3c1e564ee6476" = "$(curl -Ss https://my-netdata.io/kickstart.sh | md5sum | cut -d ' ' -f 1)" ] && echo "OK, VALID" || echo "FAILED, INVALID"
140
```
141
142
If the script is valid, this command will return `OK, VALID`.