feat: add upgrade script (for major releases), node log script

refactor: better run script
master
Kebler Network System Administrator 2022-01-02 19:21:21 -08:00
parent e4d19d0e09
commit 3acf88c918
7 changed files with 20 additions and 13 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/node_modules/

View File

@ -1,5 +1,6 @@
#!/bin/bash
sudo rm /etc/systemd/system/node-red@.service
sudo rm /etc/systemd/system/node-red.service
sudo ln -s /opt/node-red-run/node-red.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable node-red

1
node-red-log Executable file
View File

@ -0,0 +1 @@
journalctl -f -u node-red

View File

@ -3,9 +3,8 @@ Description=Node-RED
After=syslog.target network.target
[Service]
# uncomment environment and set for alternative user directory, default is /opt/node-red
# run > sudo systemctl daemon-reload
# Environment=NODE_RED_USER_DIR=/opt/node-red
# uncomment environment and set for alternative user directory, default is /data/node-red
# Environment=NODE_RED_USER_DIR=
ExecStart=/bin/bash /opt/node-red-run/run ${NODE_RED_USER_DIR}
Restart=on-failure
KillSignal=SIGINT
@ -15,7 +14,7 @@ SyslogIdentifier=node-red
StandardOutput=syslog
# non-root user to run as
WorkingDirectory=/opt/node-red
# WorkingDirectory=${NODE_RED_USER_DIR}
User=sysadmin
Group=sysadmin

10
run
View File

@ -1,8 +1,6 @@
#!/bin/bash
GDIR="/usr/lib/node_modules" # global install
GDIR="/usr/lib/node_modules" # global install, default global install directory
DIR=${1:-$NODE_RED_USER_DIR}
echo any dir set? $DIR
DIR=${DIR:-/opt/node-red}
echo any dir set? $DIR
echo Starting Node Red with instance directory $DIR
/usr/bin/node -r $GDIR/esm $GDIR/node-red/red.js --userDir $DIR
[[ !$DIR ]] && echo using default user directory /data/node-red && DIR=/data/node-red
echo Starting Node Red with user instance directory $DIR
/usr/bin/node $GDIR/node-red/red.js --userDir $DIR

6
update
View File

@ -1,6 +1,6 @@
#!/bin/bash
# run global update on node-red and esm
sudo npm install -g --unsafe-perm node-red
sudo npm install -g esm
# run global update on node-red
sudo systemctl stop nodered
sudo npm install -g --unsafe-perm --prefix /usr node-red
sudo systemctl daemon-reload
sudo systemctl restart node-red

7
upgrade Executable file
View File

@ -0,0 +1,7 @@
#!/bin/bash
# run global update on node-red
sudo systemctl stop nodered
sudo npm uninstall -g --prefix /usr node-red
sudo npm install -g --unsafe-perm --prefix /usr node-red
sudo systemctl daemon-reload
sudo systemctl restart node-red