@@ -195,6 +195,12 @@ if [ "$EUID" == "0" ]; then
195195 SUDO=' '
196196 SUDOE=' '
197197 id -u nobody & > /dev/null || adduser --no-create-home --shell /dev/null --disabled-password --disabled-login --gecos ' ' nobody & > /dev/null
198+ else
199+ groups " $USER " | grep -q ' sudo ' && GRS=" Y" || GRS=" N"
200+ if [[ " $GRS " == " N" ]]; then
201+ echo " User $NODERED_USER not in sudoers group. Exiting"
202+ exit 1;
203+ fi
198204fi
199205
200206# setup user, home and group
@@ -743,6 +749,9 @@ case $yn in
743749 echo " Finished: $( date) " | $SUDO tee -a /var/log/nodered-install.log
744750
745751 file=/home/$NODERED_USER /.node-red/settings.js
752+ if [[ " $NODERED_USER " == " root" ]]; then
753+ file=/root/.node-red/settings.js
754+ fi
746755 if [ ! -f $file ]; then
747756 echo " "
748757 elif ! diff -q /usr/lib/node_modules/node-red/settings.js $file & > /dev/null 2>&1 ; then
@@ -772,7 +781,7 @@ case $yn in
772781 echo " sudo rm -f /etc/sudoers.d/010_pi-nopasswd"
773782 echo " "
774783 fi
775- if [ ! -f ~ /.node-red/settings.js ]; then
784+ if [ ! -f $file ]; then
776785 echo " - You can customise the initial settings by running:"
777786 echo " "
778787 echo " node-red admin init"
@@ -794,14 +803,14 @@ case $yn in
794803 fi
795804 echo " **********************************************************************************"
796805 echo " "
797- if [ ! -f ~ /.node-red/settings.js ]; then
806+ if [ ! -f $file ]; then
798807 initset=" ${INITSET} "
799808 # [ ! "${INITSET}" ] && read -t 60 -p " Would you like to customise the settings now (y/N) ? " initset
800809 case $initset in
801810 [Yy]* )
802811 export HOSTIP=` hostname -I | cut -d ' ' -f 1`
803812 /usr/bin/node-red admin init
804- $SUDO chown 0:0 ~ /.node-red/settings.js
813+ $SUDO chown 0:0 $file
805814 ;;
806815 [Nn]* )
807816 echo " Settings not initialized."
@@ -811,7 +820,7 @@ case $yn in
811820 # echo " "
812821 # exit 1
813822 /usr/bin/node-red admin init
814- $SUDO chown 0:0 ~ /.node-red/settings.js
823+ $SUDO chown 0:0 $file
815824 ;;
816825 esac
817826 fi
0 commit comments