@@ -195,6 +195,12 @@ if [ "$EUID" == "0" ]; then
195
195
SUDO=' '
196
196
SUDOE=' '
197
197
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
198
204
fi
199
205
200
206
# setup user, home and group
@@ -743,6 +749,9 @@ case $yn in
743
749
echo " Finished: $( date) " | $SUDO tee -a /var/log/nodered-install.log
744
750
745
751
file=/home/$NODERED_USER /.node-red/settings.js
752
+ if [[ " $NODERED_USER " == " root" ]]; then
753
+ file=/root/.node-red/settings.js
754
+ fi
746
755
if [ ! -f $file ]; then
747
756
echo " "
748
757
elif ! diff -q /usr/lib/node_modules/node-red/settings.js $file & > /dev/null 2>&1 ; then
@@ -772,7 +781,7 @@ case $yn in
772
781
echo " sudo rm -f /etc/sudoers.d/010_pi-nopasswd"
773
782
echo " "
774
783
fi
775
- if [ ! -f ~ /.node-red/settings.js ]; then
784
+ if [ ! -f $file ]; then
776
785
echo " - You can customise the initial settings by running:"
777
786
echo " "
778
787
echo " node-red admin init"
@@ -794,14 +803,14 @@ case $yn in
794
803
fi
795
804
echo " **********************************************************************************"
796
805
echo " "
797
- if [ ! -f ~ /.node-red/settings.js ]; then
806
+ if [ ! -f $file ]; then
798
807
initset=" ${INITSET} "
799
808
# [ ! "${INITSET}" ] && read -t 60 -p " Would you like to customise the settings now (y/N) ? " initset
800
809
case $initset in
801
810
[Yy]* )
802
811
export HOSTIP=` hostname -I | cut -d ' ' -f 1`
803
812
/usr/bin/node-red admin init
804
- $SUDO chown 0:0 ~ /.node-red/settings.js
813
+ $SUDO chown 0:0 $file
805
814
;;
806
815
[Nn]* )
807
816
echo " Settings not initialized."
@@ -811,7 +820,7 @@ case $yn in
811
820
# echo " "
812
821
# exit 1
813
822
/usr/bin/node-red admin init
814
- $SUDO chown 0:0 ~ /.node-red/settings.js
823
+ $SUDO chown 0:0 $file
815
824
;;
816
825
esac
817
826
fi
0 commit comments