Skip to content

Commit db77fa3

Browse files
committed
add --on-diet option
and remove 0:0
1 parent bed7545 commit db77fa3

File tree

1 file changed

+34
-7
lines changed

1 file changed

+34
-7
lines changed

deb/update-nodejs-and-nodered

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Options:
4343
--allow-low-ports add capability to bind to ports below 1024 (default is disallow)
4444
--update-nodes run npm update on existing installed nodes (within scope of package.json)
4545
--no-init don't ask to initialise settings if they don't exist
46+
--on-diet bypass DietPi exit and force install Node-RED on DietPi
4647
--nodered-user specify the user to run as, useful for installing as sudo - e.g. --nodered-user=pi
4748
--nodered-version if not set, the latest version is used - e.g. --nodered-version="4.0.2"
4849
--node16 if set, forces install of major version of nodejs 16 LTS
@@ -131,6 +132,10 @@ if [ $# -gt 0 ]; then
131132
INITSET="n"
132133
shift
133134
;;
135+
--on-diet)
136+
ONDIET="y"
137+
shift
138+
;;
134139
--) # end argument parsing
135140
shift
136141
break
@@ -166,10 +171,11 @@ else
166171
fi
167172

168173
echo -ne "\033[2 q"
169-
if [[ -e /mnt/dietpi_userdata ]]; then
170-
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"
174+
if [[ -e /mnt/dietpi_userdata && "$ONDIET" != "y" ]]; then
175+
echo -ne "\n\033[1;32mDietPi\033[0m detected - only going to add the \033[0;36mnode-red-start, -stop, -log\033[0m commands.\n"
171176
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"
172-
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"
177+
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\n"
178+
echo -ne "If you want to force install Node-RED, re-run this script with the \033[0;36m--on-diet\033[0m option.\n\n"
173179
echo "journalctl -f -n 100 -u node-red -o cat" > /usr/bin/node-red-log
174180
chmod +x /usr/bin/node-red-log
175181
echo "systemctl stop node-red" > /usr/bin/node-red-stop
@@ -179,6 +185,27 @@ if [[ -e /mnt/dietpi_userdata ]]; then
179185
chmod +x /usr/bin/node-red-start
180186
else
181187

188+
if [[ -e /mnt/dietpi_userdata && "$ONDIET" == "y" ]]; then
189+
DIETPI="y"
190+
echo -ne "\n\033[1;32mDietPi\033[0m detected but going to force install of Node-RED.\n"
191+
echo -ne "\nThis should only be done if you DO NOT use the dietpi-software\ninstaller to set up nodejs and node-red.\n"
192+
echo -ne "\nTrying to mix both will quite probably break something - Use at your own risk.\n\n"
193+
read -t 10 -p "Are you really sure you want to force install on DietPi ? (y/N) ? " yn
194+
case $yn in
195+
[Yy]* )
196+
;;
197+
* )
198+
echo " "
199+
exit 1
200+
;;
201+
esac
202+
echo -ne "\nOK - fingers crossed.\n\n"
203+
apt install -y python3-rpi.gpio 2>&1 | $SUDO tee -a /var/log/nodered-install.log >>/dev/null
204+
CONFIRM_ROOT="y"
205+
CONFIRM_INSTALL="y"
206+
CONFIRM_PI="y"
207+
fi
208+
182209
if [ "$EUID" == "0" ]; then
183210
# if [[ $SUDO_USER != "" ]]; then
184211
echo -en "\nroot user detected. Typical installs should be done as a regular user.\r\n"
@@ -683,7 +710,7 @@ case $yn in
683710
then
684711
: # silent procedure
685712
else
686-
echo "Customized systemd script found @ $SYSTEMDFILE. To prevent loss of modifications, we'll not recreate the systemd script." | $SUDO tee -a /var/log/nodered-install.log >>/dev/null
713+
echo "Customized systemd script found @ $SYSTEMDFILE. To prevent loss of modifications, we will not recreate the systemd script." | $SUDO tee -a /var/log/nodered-install.log >>/dev/null
687714
echo "If you want the installer to recreate the systemd script, please delete or rename the current script & re-run the installer." | $SUDO tee -a /var/log/nodered-install.log >>/dev/null
688715
CHAR="- Skipped - existing script is customized."
689716
fi
@@ -723,7 +750,7 @@ case $yn in
723750
FAM=$(cat /etc/issue | cut -d ' ' -f 1)
724751
ISS=$(cat /etc/issue | cut -d '/' -f 2 | cut -d ' ' -f 2)
725752
if [[ "$FAM" == *"bian" ]]; then
726-
if (($ISS > 11)); then
753+
if [ $ISS -gt 11 ] && [ "$DIETPI" != "y" ]; then
727754
echo "Replace old rpi.gpio with lgpio" | $SUDO tee -a /var/log/nodered-install.log >>/dev/null
728755
$SUDO apt purge -y python3-rpi.gpio 2>&1 | $SUDO tee -a /var/log/nodered-install.log >>/dev/null
729756
$SUDO apt install -y python3-pip 2>&1 | $SUDO tee -a /var/log/nodered-install.log >>/dev/null
@@ -833,7 +860,7 @@ case $yn in
833860
export HOSTIP=`hostname -I | cut -d ' ' -f 1`
834861
$SUDO chown -Rf $NODERED_USER:$NODERED_GROUP $NODERED_HOME/.node-red 2>&1 >>/dev/null
835862
$SUDOU /usr/bin/node-red admin init
836-
$SUDO chown 0:0 $file
863+
# $SUDO chown 0:0 $file
837864
;;
838865
[Nn]* )
839866
echo "Settings not initialized."
@@ -844,7 +871,7 @@ case $yn in
844871
# exit 1
845872
$SUDO chown -Rf $NODERED_USER:$NODERED_GROUP $NODERED_HOME/.node-red/ 2>&1 >>/dev/null
846873
$SUDOU /usr/bin/node-red admin init
847-
$SUDO chown 0:0 $file
874+
# $SUDO chown 0:0 $file
848875
;;
849876
esac
850877
fi

0 commit comments

Comments
 (0)