# Issues with Raspberry Pi upgrade script

**URL:** https://discourse.nodered.org/t/issues-with-raspberry-pi-upgrade-script/89803
**Category:** General
**Created:** [27 July 2024 00:20 UTC](https://discourse.nodered.org/t/issues-with-raspberry-pi-upgrade-script/89803 "2024-07-27T00:20:45Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![DerekK19](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/derekk19/32/93126_2.png) [@DerekK19](https://discourse.nodered.org/u/DerekK19)
#### Post date: [27 July 2024 00:20 UTC](https://discourse.nodered.org/t/issues-with-raspberry-pi-upgrade-script/89803/1 "2024-07-27T00:20:45Z")

</div>

There are a few bugs in the update-nodejs-and-nodered installer script. These bugs arise when using the --nodered-user parameter:

This parameter sets the variable NODERED\_USER to the = part of the parameter. However the line that checks if the user is in the sudoers group does not use this variable, it uses $USER.

The line should read:

groups "$NODERED\_USER" | grep -q '\bsudo\b' && GRS="Y" || GRS="N"

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [27 July 2024 01:10 UTC](https://discourse.nodered.org/t/issues-with-raspberry-pi-upgrade-script/89803/2 "2024-07-27T01:10:53Z")

</div>

Welcome to the forum @DerekK19.

I don't think it's necessary for the Node-red user to be a member of the sudo group ( **Couldn't check - see note below** ).  
However it **is** necessary for the user who installs Node-red since the script calls sudo many times.

So I suspect that the line you highlight is intended to check that the **current user** is a member.

You might be right there is a bug there though, should it be like this?

```auto
groups "$USER" | grep -q '\bsudo\b' && GRS="Y" || GRS="N"
    if [["$GRS" == "N"]]; then
        echo "User $USER not in sudoers group. Exiting"
        exit 1;
    fi

```

or even

```auto
groups | grep -q '\bsudo\b' && GRS="Y" || GRS="N"
    if [["$GRS" == "N"]]; then
        echo "You are not in sudoers group. Exiting"
        exit 1;
    fi

```

**Note** I just tried installing Node-red with the --node-red-user=pi parameter and the script fell over at line 272

```auto
cd: /home/pi: Permission denied

```

and ls -l /home gives me

```auto
drwx------ 2 newuser newuser 4096 Jul 27 02:04 newuser
drwx------ 5 pi pi 4096 Jul 27 01:49 pi

```

Since neither of these users can cd to the other's $HOME, and we are strongly discouraged from running the script as root what user is able to install Node-red for someone else?

@dceejay can you comment on these two issues?

---

<div class="post-metadata">

### Author: ![DerekK19](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/derekk19/32/93126_2.png) [@DerekK19](https://discourse.nodered.org/u/DerekK19)
#### Post date: [27 July 2024 01:29 UTC](https://discourse.nodered.org/t/issues-with-raspberry-pi-upgrade-script/89803/3 "2024-07-27T01:29:57Z")

</div>

Thanks for that. To get the install to work, I added my node red user to the sudo group (very dangerous I think) and ran as that user, then didn't pass the --nodered-user parameter. Having done the install I will now remove my node red user from the sudo group - and just hope I remember all this next time I try to upgrade node-red

I think I need to read that script more fully since there is something wrong (or misleading) there

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [27 July 2024 01:35 UTC](https://discourse.nodered.org/t/issues-with-raspberry-pi-upgrade-script/89803/4 "2024-07-27T01:35:02Z")

</div>

> [@DerekK19](#):
>
> very dangerous I think

I very nearly removed my only login user (pi) from the sudo group as a test.  
Not sure how I could have reversed that. 😱

---

<div class="post-metadata">

### Author: ![DerekK19](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/derekk19/32/93126_2.png) [@DerekK19](https://discourse.nodered.org/u/DerekK19)
#### Post date: [27 July 2024 02:28 UTC](https://discourse.nodered.org/t/issues-with-raspberry-pi-upgrade-script/89803/5 "2024-07-27T02:28:03Z")

</div>

First thing I do is add a second user then make that user a sudo user. Otherwise your only option is to rebuild your Pi (Been there, done that!)

---

<div class="post-metadata">

### Author: ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)
#### Post date: [27 July 2024 07:41 UTC](https://discourse.nodered.org/t/issues-with-raspberry-pi-upgrade-script/89803/6 "2024-07-27T07:41:46Z")

</div>

Yes - you are correct - the intention is that the Node-RED user shouldn't need sudo - but he user running the install script should - so yes there do seem to be some wrinkles in there. Suggestions and/or PR would be greatly appreciated.

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [27 July 2024 08:11 UTC](https://discourse.nodered.org/t/issues-with-raspberry-pi-upgrade-script/89803/7 "2024-07-27T08:11:30Z")

</div>

> [@jbudd](#):
>
> Since neither of these users can cd to the other's $HOME, and we are strongly discouraged from running the script as root what user is able to install Node-red for someone else?

~~What about this though?~~

To answer my own question:  
To install Node-red for a different user (on a Raspberry Pi) use the command

```auto
sudo bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --nodered-user=<Nodered user name>

```

and confirm twice that you really want to do this.

---

<div class="post-metadata">

### Author: ![DerekK19](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/derekk19/32/93126_2.png) [@DerekK19](https://discourse.nodered.org/u/DerekK19)
#### Post date: [28 July 2024 03:10 UTC](https://discourse.nodered.org/t/issues-with-raspberry-pi-upgrade-script/89803/8 "2024-07-28T03:10:01Z")

</div>

It looks like a small change is needed to the script. Just change groups "$NODERED\_USER" to groups "$USER"

Then as jbudd explains the current user would use sudo to run the script and pass the Node-Red user name as a --nodered-user parameter:

> [@jbudd](#):
>
> ```auto
> groups "$USER" | grep -q '\bsudo\b' && GRS="Y" || GRS="N"
> if [["$GRS" == "N"]]; then
> echo "User $USER not in sudoers group. Exiting"
> exit 1;
> fi
> 
> ```

Then the installing user would run:

> [@](#):
>
> sudo bash \<(curl -sL https:
> 
> > Blockquote
> 
> ​//raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --nodered-user=\<Nodered user name\>

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [26 October 2024 03:10 UTC](https://discourse.nodered.org/t/issues-with-raspberry-pi-upgrade-script/89803/9 "2024-10-26T03:10:02Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
