pi@raspberrypi:~ $ curl -sL https://raw.githubusercontent.com/node-red/raspbian-deb-package/master/resources/update-nodejs-and-nodered
#!/bin/bash #
Copyright 2016,2018 JS Foundation and other contributors, https://js.foundation/
Copyright 2015,2016 IBM Corp.
#
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
#
http://www.apache.org/licenses/LICENSE-2.0
#
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
echo -ne "\033[2 q" if [[ -e /mnt/dietpi_userdata ]]; then echo -ne "\n\033[1;32mDiet-Pi\033[0m detected - only going to add the \033[0;36mnode-red-start, -stop, -log\033[0m commands.\n" echo -ne "Flow files and other things worth backing up can be found in the \033[0;36m/mnt/dietpi_userdata/node-red\033[0m directory.\n\n" echo -ne "Use the \033[0;36mdietpi-software\033[0m command to un-install and re-install \033[38;5;88mNode-RED\033[0m.\n" echo "journalctl -f -n 25 -u node-red -o cat" > /usr/bin/node-red-log chmod +x /usr/bin/node-red-log echo "dietpi-services node-red stop" > /usr/bin/node-red-stop chmod +x /usr/bin/node-red-stop echo "dietpi-services node-red start" > /usr/bin/node-red-start echo "journalctl -f -n 0 -u node-red -o cat" >> /usr/bin/node-red-start chmod +x /usr/bin/node-red-start else
if [ "$EUID" == "0" ] then echo -en "\nRoot user detected. Typically install as a normal user. No need for sudo.\r\n\r\n" read -p "Are you really sure you want to install as root ? (y/N) ? " yn case $yn in [Yy]* ) ;;
* )
exit
;;
esac fi if [[ $(cat /etc/-release | grep VERSION=) != *"wheezy" ]]; then if [[ "$(uname)" != "Darwin" ]]; then wget -q --spider https://www.npmjs.com/package/node-red if [ $? -eq 0 ]; then echo -e '\033]2;'Node-RED update'\007' echo " " echo "This script will remove versions of Node.js prior to version 6.x, and Node-RED and" echo "if necessary replace them with Node.js 8.x LTS (carbon) and the latest Node-RED from Npm." echo " " echo "It also moves any Node-RED nodes that are globally installed into your user" echo "~/.node-red/node_modules directory, and adds them to your package.json, so that" echo "you can manage them with the palette manager." echo " " echo "It also tries to run 'npm rebuild' to refresh any extra nodes you have installed" echo "that may have a native binary component. While this normally works ok, you need" echo "to check that it succeeds for your combination of installed nodes." echo " " echo "To do all this it runs commands as root - please satisfy yourself that this will" echo "not damage your Pi, or otherwise compromise your configuration." echo "If in doubt please backup your SD card first." echo " "
read -p "Are you really sure you want to do this ? [y/N] ? " yn case $yn in [Yy]* ) echo "" EXTRANODES="" EXTRAW="update" if [ ! -d "/usr/lib/node_modules/node-red-node-serialport" ] && [ ! -d "$HOME/.node-red/node_modules/node-red-node-serialport" ]; then read -r -t 15 -p "Would you like to install the Pi-specific nodes ? [y/N] ? " response if [[ "$response" =~ ^([yY])+$ ]]; then EXTRANODES="node-red-node-random node-red-contrib-ibm-watson-iot node-red-node-ping node-red-contrib-play-audio node-red-node-smooth node-red-node-serialport" EXTRAW="install" fi fi
# this script assumes that $HOME is the folder of the user that runs node-red
# that $USER is the user name and the group name to use when running is the
# primary group of that user
# if this is not correct then edit the lines below
NODERED_HOME=$HOME
NODERED_USER=$USER
NODERED_GROUP=`id -gn`
GLOBAL="true"
TICK='\033[1;32m\u2714\033[0m'
CROSS='\033[1;31m\u2718\033[0m'
cd "$NODERED_HOME" || exit 1
clear
echo "Running Node-RED $EXTRAW for user $USER at $HOME"
time1=$(date)
...