Update install_netdata

Added support for NVM setup on first installation.
This commit is contained in:
LPJon
2023-08-31 01:34:03 -05:00
committed by GitHub
parent f615be5acd
commit ad1b671915

View File

@@ -7,24 +7,25 @@
# ToDo:
# Automatic activate on boot
# NEW CODE
# Check if NVM and Node.JS is already installed and if it is skip it's installation
# ToDo:
# Add NVM support
if [ -e "$HOME/.nvm" ]; then
echo "NVM for Node.JS is installed...Skipping RPM Package Installation!"
nodejs=""
else
nodejs="nodejs"
fi
# NEW CODE------------
# Use NVM for node.js installation management. Options are "y" or "n" DEFAULT = n
usenvm=n
# Version of Node.js to install. DEFAULT = 16.18.1
nodeversion=16.18.1
function getsystemnodeversion {
if [ -e "/usr/bin/node" ]; then
/usr/bin/node -v
fi
}
# ---------------------
# Check centos version
centosversion=$(rpm -qa \*-release | grep -Ei "oracle|redhat|centos|cloudlinux" | cut -d"-" -f3 | cut -d"." -f 1 | head -n 1)
if [[ "$centosversion" -eq "8" ]];then
yum -y install 'dnf-command(config-manager)'
yum -y install http://repo.okay.com.mx/centos/8/x86_64/release/okay-release-1-3.el8.noarch.rpm
yum -y install curl gcc make autoconf autoconf-archive autogen automake --enablerepo=epel --enablerepo=powertools
yum -y install MySQL-python python python-yaml python-psycopg2 $nodejs lm_sensors --enablerepo=epel --enablerepo=powertools
yum -y install MySQL-python python python-yaml python-psycopg2 nodejs lm_sensors --enablerepo=epel --enablerepo=powertools
yum -y install nmap-ncat git zlib-devel libuuid-devel --enablerepo=epel --enablerepo=powertools
yum -y install libmnl-devel libuv-devel --enablerepo=epel --enablerepo=powertools
yum -y install json-c-devel libatomic libyaml-devel lz4-devel systemd-devel
@@ -43,6 +44,33 @@ if [[ "$centosversion" -eq "8" ]];then
make
make install
else
# NEW CODE--------
if [ "$usenvm" == "n" ]; then
if [ -e "$HOME/.nvm" ]; then
echo "NVM for Node.JS is installed...Skipping RPM Package Installation!"
nodejs=""
else
nodejs="nodejs"
fi
elif [ "$usenvm" == "y" ]; then
if [ -e "$HOME/.nvm" ];then
source $HOME/.bashrc
nvm install $nodeversion
nvm use $nodeversion
if [ "$(getsystemnodeversion)" != "v$nodeversion" ]; then
ln -sf /root/.nvm/versions/node/v"$nodeversion"/bin/node /usr/bin/node
fi
fi
if [ ! -e "$HOME/.nvm" ]; then
yum -y install curl
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
source $HOME/.bashrc
nvm install "$nodeversion"
nvm use "$nodeversion"
ln -sf /root/.nvm/versions/node/v"$nodeversion"/bin/node /usr/bin/node
fi
fi
# ------------
yum -y install curl gcc make autoconf autoconf-archive autogen automake --enablerepo=epel
yum -y install MySQL-python python python-yaml python-psycopg2 $nodejs lm_sensors --enablerepo=epel
yum -y install nmap-ncat git zlib-devel libuuid-devel --enablerepo=epel