# Run raspberry update script from nodered

**URL:** <https://discourse.nodered.org/t/run-raspberry-update-script-from-nodered/42082>\
**Category:** General\
**Created:** [5 March 2021 11:25 UTC](https://discourse.nodered.org/t/run-raspberry-update-script-from-nodered/42082 "2021-03-05T11:25:06Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![xselvasx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/xselvasx/32/38277_2.png) [@xselvasx](https://discourse.nodered.org/u/xselvasx)\
**Post date:** [5 March 2021 11:25 UTC](https://discourse.nodered.org/t/run-raspberry-update-script-from-nodered/42082/1 "2021-03-05T11:25:06Z")

</div>

hi, is possible to launch the update script for raspberry (  
bash \<(curl -sL [https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered](https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered))  
directly from raspberry nodered?  
thanks for the answer

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [5 March 2021 16:51 UTC](https://discourse.nodered.org/t/run-raspberry-update-script-from-nodered/42082/2 "2021-03-05T16:51:27Z")

</div>

Yes. You can use the exec node for that. Of course, you will need to make sure that the script doesn't prompt for a response because if it does, it will fail. You would also need to restart Node-RED afterwards assuming anything important was updated.

However, there are also other ways to keep things updated. Once you've run the script to get everything installed, you should be able to use the standard apt and npm tools to do updates.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [5 March 2021 16:56 UTC](https://discourse.nodered.org/t/run-raspberry-update-script-from-nodered/42082/3 "2021-03-05T16:56:49Z")

</div>

> [@TotallyInformation](#):
>
> Yes. You can use the exec node for that.

Are you sure?  
The script will stop node-RED, wouldn't that also stop the bash script session from running.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [5 March 2021 20:51 UTC](https://discourse.nodered.org/t/run-raspberry-update-script-from-nodered/42082/4 "2021-03-05T20:51:28Z")

</div>

No, not totally sure, I've not tried it 😁 But as long as exec is creating its own shell, I _think_ it will. Easy enough to test.

Personally, I don't use the script and certainly wouldn't use it to update my environment, especially from within Node-RED. I prefer to set up and use native commands to keep things simple.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [5 March 2021 21:45 UTC](https://discourse.nodered.org/t/run-raspberry-update-script-from-nodered/42082/5 "2021-03-05T21:45:52Z")

</div>

If you just want to update node-red then you could use an exec node to run  
`sudo npm install -g --unsafe-perm node-red`  
then another to restart node-red. You would need to set the system up to not require a password for that command.  
That will be another problem trying to run the bash script, it will ask for a password at some point.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [6 March 2021 02:17 UTC](https://discourse.nodered.org/t/run-raspberry-update-script-from-nodered/42082/6 "2021-03-06T02:17:01Z")

</div>

You can, of course, set your sudo settings to allow specific (or even all) sudo commands to be run without an additional password which is useful for the exec node - though worth thinking about the security risks.

Once you have apt sources configured for node.js, mosquitto, etc, just running `sudo apt update && sudo apt upgrade` will update everything. Though investigate the apt command switches if you want to ensure that you don't get any requests for interactions.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [6 March 2021 07:46 UTC](https://discourse.nodered.org/t/run-raspberry-update-script-from-nodered/42082/7 "2021-03-06T07:46:55Z")

</div>

> [@TotallyInformation](#):
>
> `sudo apt update && sudo apt upgrade` will update everything

Except node red, which has to be done via the`npm` command.

---

<div class="post-metadata">

**Author:** ![xselvasx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/xselvasx/32/38277_2.png) [@xselvasx](https://discourse.nodered.org/u/xselvasx)\
**Post date:** [22 April 2021 13:53 UTC](https://discourse.nodered.org/t/run-raspberry-update-script-from-nodered/42082/8 "2021-04-22T13:53:25Z")

</div>

thanks for yours response but my problem is that when i launch the script from the exec node of nodered the script start but before update nodered the script will kill noderd and also the script will be killed so the result is not the update of node red but only the stop of nodered. i try to use nohup before the command but not work. any other solution?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [22 April 2021 20:00 UTC](https://discourse.nodered.org/t/run-raspberry-update-script-from-nodered/42082/9 "2021-04-22T20:00:09Z")

</div>

You need to launch the script in its own shell so that when Node-RED ends, the sub-shell continues.

---

<div class="post-metadata">

**Author:** ![xselvasx](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/xselvasx/32/38277_2.png) [@xselvasx](https://discourse.nodered.org/u/xselvasx)\
**Post date:** [23 April 2021 12:36 UTC](https://discourse.nodered.org/t/run-raspberry-update-script-from-nodered/42082/10 "2021-04-23T12:36:48Z")

</div>

there is a way to do this from inside node-red?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [23 April 2021 12:45 UTC](https://discourse.nodered.org/t/run-raspberry-update-script-from-nodered/42082/11 "2021-04-23T12:45:13Z")

</div>

Yes. Exec just creates a sub-shell but instead of calling the command directly, you should call sh or bash with the command as a parameter. I can't quite remember whether you need to push it to the background to allow the exec to finish, you may need to experiment a bit.

You may wish to do a bit of reading about Linux shells and how they interact with the OS.

---

<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:** [22 June 2021 12:45 UTC](https://discourse.nodered.org/t/run-raspberry-update-script-from-nodered/42082/12 "2021-06-22T12:45:31Z")

</div>

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