From 0101449dda7cb46c2f936a96798980f3e99d9b24 Mon Sep 17 00:00:00 2001
From: tteckster <tteckster@gmail.com>
Date: Mon, 26 Jun 2023 13:11:20 -0400
Subject: [PATCH] Code refactoring

---
 install/cronicle-install.sh    | 9 ++++-----
 install/magicmirror-install.sh | 9 ++++-----
 install/meshcentral-install.sh | 9 ++++-----
 install/n8n-install.sh         | 9 ++++-----
 install/wikijs-install.sh      | 9 ++++-----
 5 files changed, 20 insertions(+), 25 deletions(-)

diff --git a/install/cronicle-install.sh b/install/cronicle-install.sh
index 9f9073c3..a38bcf06 100644
--- a/install/cronicle-install.sh
+++ b/install/cronicle-install.sh
@@ -23,12 +23,11 @@ $STD apt-get install -y g++
 $STD apt-get install -y gcc
 msg_ok "Installed Dependencies"
 
-msg_info "Setting up Node.js Repository"
-$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x)
-msg_ok "Set up Node.js Repository"
-
 msg_info "Installing Node.js"
-$STD apt-get install -y nodejs
+$STD bash <(curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh)
+. ~/.bashrc
+$STD nvm install 16.20.1
+ln -sf /root/.nvm/versions/node/v16.20.1/bin/node /usr/bin/node
 msg_ok "Installed Node.js"
 
 msg_info "Installing Cronicle Primary Server"
diff --git a/install/magicmirror-install.sh b/install/magicmirror-install.sh
index f262b885..52d480b0 100644
--- a/install/magicmirror-install.sh
+++ b/install/magicmirror-install.sh
@@ -20,12 +20,11 @@ $STD apt-get install -y mc
 $STD apt-get install -y git
 msg_ok "Installed Dependencies"
 
-msg_info "Setting up Node.js Repository"
-$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x)
-msg_ok "Set up Node.js Repository"
-
 msg_info "Installing Node.js"
-$STD apt-get install -y nodejs
+$STD bash <(curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh)
+. ~/.bashrc
+$STD nvm install 16.20.1
+ln -sf /root/.nvm/versions/node/v16.20.1/bin/node /usr/bin/node
 msg_ok "Installed Node.js"
 
 msg_info "Setting up MagicMirror Repository"
diff --git a/install/meshcentral-install.sh b/install/meshcentral-install.sh
index bd76b239..ec191bdc 100644
--- a/install/meshcentral-install.sh
+++ b/install/meshcentral-install.sh
@@ -19,12 +19,11 @@ $STD apt-get install -y sudo
 $STD apt-get install -y mc
 msg_ok "Installed Dependencies"
 
-msg_info "Setting up Node.js Repository"
-$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x)
-msg_ok "Set up Node.js Repository"
-
 msg_info "Installing Node.js"
-$STD apt-get install -y nodejs
+$STD bash <(curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh)
+. ~/.bashrc
+$STD nvm install 16.20.1
+ln -sf /root/.nvm/versions/node/v16.20.1/bin/node /usr/bin/node
 msg_ok "Installed Node.js"
 
 msg_info "Installing MeshCentral"
diff --git a/install/n8n-install.sh b/install/n8n-install.sh
index 0c2c1cd2..95a86e73 100644
--- a/install/n8n-install.sh
+++ b/install/n8n-install.sh
@@ -19,12 +19,11 @@ $STD apt-get install -y sudo
 $STD apt-get install -y mc
 msg_ok "Installed Dependencies"
 
-msg_info "Setting up Node.js Repository"
-$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x)
-msg_ok "Set up Node.js Repository"
-
 msg_info "Installing Node.js"
-$STD apt-get install -y nodejs
+$STD bash <(curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh)
+. ~/.bashrc
+$STD nvm install 16.20.1
+ln -sf /root/.nvm/versions/node/v16.20.1/bin/node /usr/bin/node
 msg_ok "Installed Node.js"
 
 msg_info "Installing n8n (Patience)"
diff --git a/install/wikijs-install.sh b/install/wikijs-install.sh
index 32152da6..f6a93f50 100644
--- a/install/wikijs-install.sh
+++ b/install/wikijs-install.sh
@@ -20,12 +20,11 @@ $STD apt-get install -y mc
 $STD apt-get install -y git
 msg_ok "Installed Dependencies"
 
-msg_info "Setting up Node.js Repository"
-$STD bash <(curl -fsSL https://deb.nodesource.com/setup_16.x)
-msg_ok "Set up Node.js Repository"
-
 msg_info "Installing Node.js"
-$STD apt-get install -y nodejs
+$STD bash <(curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.3/install.sh)
+. ~/.bashrc
+$STD nvm install 16.20.1
+ln -sf /root/.nvm/versions/node/v16.20.1/bin/node /usr/bin/node
 msg_ok "Installed Node.js"
 
 msg_info "Installing Wiki.js"