From 8d47428bedbfe1e4f6c5dd46ec000943997c75ad Mon Sep 17 00:00:00 2001 From: lou Date: Sat, 12 Oct 2024 21:43:41 -0400 Subject: [PATCH] clean up, add nodejs management --- manage | 53 +++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 43 insertions(+), 10 deletions(-) mode change 100644 => 100755 manage diff --git a/manage b/manage old mode 100644 new mode 100755 index 2f42ccf..a3f8b33 --- a/manage +++ b/manage @@ -216,22 +216,55 @@ function setup_screen() { read -n 1 -s -r -p "Press any key to continue..." clear - echo -e "\n\nThis script requires Node.js and NPM to be installed on your system." - echo "Please ensure you have them installed before proceeding." - echo - echo -e "\n\nTo install Node.js and NPM, you can visit: https://nodejs.org/" - echo "Follow the instructions for your specific operating system." - echo - read -n 1 -s -r -p "Press any key to continue..." - clear + if command -v node >/dev/null 2>&1; then + echo -e "\nāœ… Node.js is already installed. Version: $(node -v)" + else + echo -e "\nāŒ Node.js is not installed." + fi - echo -e "\n\nThe script will now check if 'screen' is installed." + if command -v npm >/dev/null 2>&1; then + echo -e "āœ… NPM is already installed. Version: $(npm -v)" + else + echo -e "āŒ NPM is not installed." + fi + + if ! command -v node >/dev/null 2>&1 || ! command -v npm >/dev/null 2>&1; then + echo -e "\nThis script requires Node.js and NPM to be installed on your system." + echo "We will now proceed to install it on your system using NVM." + + echo -e "\nWe will be installing Node.js 20.18.0\n" + read -n 1 -s -r -p "Press any key to install NVM and Node.js..." + + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash + export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" + nvm install 20.18.0 + + echo + echo "NodeJS should have been installed." + + read -n 1 -s -r -p "Press any key to continue..." + clear + + echo "We will now install everything required on the NodeJS side." + echo "Press any to confirm you're okay with this." + echo + read -n 1 -s -r -p "Press any key to continue..." + npm install + echo + echo "Hopefully everything installed right!" + else + echo -e "\nAll required dependencies are installed. No further action needed." + fi + + echo -e "\n\nmanage will now check if 'screen' is installed." echo "You may need to enter your sudo password." echo install_tools echo touch $SETUP_FILE - read -n 1 -s -r -p "Press any key to finish..." + read -n 1 -s -r -p "Press any key to continue..." + clear echo "Have a nice day!" echo