Update install_netdata

Added support for switching between the RPM nodejs and NVM nodejs globally in the system
This commit is contained in:
LPJon
2023-08-31 02:50:35 -05:00
committed by GitHub
parent 89172ae504
commit 9941996398

View File

@@ -19,15 +19,24 @@ function getsystemnodeversion {
/usr/bin/node -v /usr/bin/node -v
fi fi
} }
function checkfornodejsrpm {
yum list installed nodejs
}
function installnodeJS { function installnodeJS {
if [ "$usenvm" == "n" ]; then if [ "$usenvm" == "n" ]; then
if [ -e "$HOME/.nvm" ]; then if [ -e "$HOME/.nvm" ]; then
echo "NVM for Node.JS is installed...Skipping RPM Package Installation!" echo "NVM for Node.JS is installed...Skipping RPM Package Installation!"
nodejs="" nodejs=""
else else
if [ -z "$(checkfornodejsrpm)" ]; then
rm -f /usr/bin/node
fi
nodejs="nodejs" nodejs="nodejs"
fi fi
elif [ "$usenvm" == "y" ]; then elif [ "$usenvm" == "y" ]; then
if [ -z "$(checkfornodejsrpm)" ]; then
yum -y remove nodejs
fi
if [ -e "$HOME/.nvm" ];then if [ -e "$HOME/.nvm" ];then
export NVM_DIR="$HOME/.nvm" export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
@@ -39,14 +48,14 @@ function installnodeJS {
fi fi
fi fi
if [ ! -e "$HOME/.nvm" ]; then if [ ! -e "$HOME/.nvm" ]; then
yum -y install curl yum -y install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
export NVM_DIR="$HOME/.nvm" export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
nvm install "$nodeversion" nvm install "$nodeversion"
nvm use "$nodeversion" nvm use "$nodeversion"
ln -sf /root/.nvm/versions/node/v"$nodeversion"/bin/node /usr/bin/node ln -sf /root/.nvm/versions/node/v"$nodeversion"/bin/node /usr/bin/node
fi fi
fi fi
} }