From a39d0093188a3dcf72c5ee2545c8f4749b6c7ee0 Mon Sep 17 00:00:00 2001 From: Dj Merrill Date: Tue, 30 Apr 2024 21:41:29 -0400 Subject: [PATCH] Remove dependency on distro supplied nodejs. Installs nodejs v 20 in ~/.npm --- tools/Linux/install-freedata-linux.sh | 36 ++++++++++++++++++++++++--- tools/Linux/run-freedata-linux.sh | 18 ++++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/tools/Linux/install-freedata-linux.sh b/tools/Linux/install-freedata-linux.sh index a1eebfe8..99b91e9f 100755 --- a/tools/Linux/install-freedata-linux.sh +++ b/tools/Linux/install-freedata-linux.sh @@ -3,7 +3,7 @@ # Simple script to install FreeDATA in Linux # Dj Merrill - 25 Apr 2024 # -# Currently supports Debian 12, Ubuntu 24.04 LTS +# Currently supports Debian [11,12], Ubuntu [24.04] # # args: nothing or "main" (use main branch of FreeDATA) # "develop" (use develop branch of FreeDATA) @@ -34,8 +34,8 @@ echo "*************************************************************************" case $osname in "Debian GNU/Linux") case $osversion in - "12 (bookworm)") - sudo apt install --upgrade -y libhamlib-utils libhamlib-dev libhamlib4 fonts-noto-color-emoji git build-essential cmake npm nodejs python3 portaudio19-dev python3-pyaudio python3-pip python3-colorama + "11 (bullseye)" | "12 (bookworm)") + sudo apt install --upgrade -y libhamlib-utils libhamlib-dev libhamlib4 fonts-noto-color-emoji git build-essential cmake python3 portaudio19-dev python3-pyaudio python3-pip python3-colorama python3-venv wget ;; *) @@ -53,7 +53,7 @@ case $osname in "Ubuntu") case $osversion in "24.04 LTS (Noble Numbat)") - sudo apt install --upgrade -y libhamlib-utils libhamlib-dev libhamlib4 fonts-noto-color-emoji git build-essential cmake npm nodejs python3 portaudio19-dev python3-pyaudio python3-pip python3-colorama python3-venv + sudo apt install --upgrade -y libhamlib-utils libhamlib-dev libhamlib4 fonts-noto-color-emoji git build-essential cmake python3 portaudio19-dev python3-pyaudio python3-pip python3-colorama python3-venv curl wget ;; *) @@ -75,6 +75,34 @@ case $osname in ;; esac +echo "*************************************************************************" +echo "Installing nvm and node v 20 into ~/.nvm" +echo "*************************************************************************" +wget https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh +if [ -f "install.sh" ]; +then + XDG_CONFIG_HOME="" + chmod 750 install.sh + ./install.sh +else + echo "Something went wrong. npm install.sh not downloaded." + exit 1 +fi + +if [ -f "$HOME/.nvm/bash_completion" ]; +then + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" + nvm install 20 + echo "nvm is version" `npm -v` + echo "node is version" `node -v` + rm install.sh +else + echo "Something went wrong. $HOME/.nvm environment not created properly." + exit 1 +fi + echo "*************************************************************************" echo "Checking for old FreeDATA directories" echo "*************************************************************************" diff --git a/tools/Linux/run-freedata-linux.sh b/tools/Linux/run-freedata-linux.sh index 2a02825a..141d4b36 100755 --- a/tools/Linux/run-freedata-linux.sh +++ b/tools/Linux/run-freedata-linux.sh @@ -74,6 +74,24 @@ else fi cd $guidir + +if [ -f "$HOME/.nvm/bash_completion" ]; +then + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" +else + echo "Something went wrong. $HOME/.nvm environment not created properly." + exit 1 +fi + +checknpm=`which npm` +if [ -z "$checknpm" ]; +then + echo "Something went wrong. npm not found." + exit 1 +fi + npm start > ../../FreeDATA-client.log 2>&1 # If we are this far, then we have just quit the GUI, so let's clean up the