diff --git a/manage b/manage index 1b6eb7b..e16b895 100755 --- a/manage +++ b/manage @@ -20,23 +20,40 @@ function install_tools() { # Perform updates if [ "$DISTRO" == "Ubuntu" ]; then echo -e "${COLOR_BLUE}Updating package lists...${COLOR_RESET}" - sudo apt-get update - echo -e "${COLOR_GREEN}Done.${COLOR_RESET}" + # shellcheck disable=SC2024 + sudo apt-get update >> install.log + echo -e "${COLOR_GREEN}Done.${COLOR_RESET}\n" elif [ "$DISTRO" == "Arch Linux" ]; then echo -e "${COLOR_BLUE}Updating package lists...${COLOR_RESET}" - sudo pacman -Sy - echo -e "${COLOR_GREEN}Done.${COLOR_RESET}" + # shellcheck disable=SC2024 + sudo pacman -Sy >> install.log + echo -e "${COLOR_GREEN}Done.${COLOR_RESET}\n" + fi + + # Check for curl, and install if not found + if ! command_exists curl; then + echo -e "${COLOR_RED}curl is not installed. Installing now...${COLOR_RESET}" + if [ "$DISTRO" == "Ubuntu" ]; then + sudo apt-get install curl -y >> install.log + elif [ "$DISTRO" == "Arch Linux" ]; then + sudo pacman -S --noconfirm curl >> install.log + fi + echo -e "\n${COLOR_GREEN}curl installed successfully.${COLOR_RESET}\n" + else + echo -e "${COLOR_GREEN}curl is installed.${COLOR_RESET}" fi # Check for NodeJS, and install if not found if ! command_exists node; then echo -e "${COLOR_RED}NodeJS is not installed. Installing now...${COLOR_RESET}" - echo -e "${COLOR_YELLOW}You may need to enter your sudo password.${COLOR_RESET}\n" - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash + curl -o .install.sh https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh >> install.log + chmod +x .install.sh + bash .install.sh >> install.log + rm .install.sh # cleanup # shellcheck disable=SC2155 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 23 + nvm install 23 >> install.log echo -e "\n${COLOR_GREEN}NodeJS installed successfully.${COLOR_RESET}\n" else echo -e "${COLOR_GREEN}NodeJS is installed. Version: $(node -v)${COLOR_RESET}" @@ -45,30 +62,37 @@ function install_tools() { # Check for Netcat, and install if not found if ! command_exists nc; then echo -e "${COLOR_RED}Netcat is not installed. Installing now...${COLOR_RESET}" - echo -e "${COLOR_YELLOW}You may need to enter your sudo password.${COLOR_RESET}\n" if [ "$DISTRO" == "Ubuntu" ]; then - sudo apt-get install netcat-traditional -y + sudo apt-get install netcat-traditional -y >> install.log elif [ "$DISTRO" == "Arch Linux" ]; then - sudo pacman -S --noconfirm netcat + sudo pacman -S --noconfirm netcat >> install.log fi echo -e "\n${COLOR_GREEN}Netcat installed successfully.${COLOR_RESET}\n" else echo -e "${COLOR_GREEN}Netcat is installed.${COLOR_RESET}" fi + # Check for lsof, and install if not found + if ! command_exists lsof && [ "$DISTRO" == "Arch Linux" ]; then + echo -e "${COLOR_RED}lsof is not installed. Installing now...${COLOR_RESET}" + sudo pacman -S --noconfirm lsof >> install.log + echo -e "\n${COLOR_GREEN}lsof installed successfully.${COLOR_RESET}\n" + else + echo -e "${COLOR_GREEN}lsof is installed.${COLOR_RESET}" + fi + # Check for NPM, and install if not found if ! command_exists npm; then echo -e "${COLOR_RED}NPM is not installed. Installing now...${COLOR_RESET}" - echo -e "${COLOR_YELLOW}You may need to enter your sudo password.${COLOR_RESET}\n" if [ "$DISTRO" == "Ubuntu" ]; then - sudo apt-get install npm -y + sudo apt-get install npm -y >> install.log elif [ "$DISTRO" == "Arch Linux" ]; then - sudo pacman -S --noconfirm npm + sudo pacman -S --noconfirm npm >> install.log fi if [ ! -f "config.json" ]; then echo -e "${COLOR_BLUE}Copying config file...${COLOR_RESET}" if [ ! -f "config.json.example" ]; then - echo "Couldn't find example config file" + echo "${COLOR_RED}[!] Couldn't find example config file${COLOR_RESET}" else cp config.json.example config.json fi @@ -76,7 +100,7 @@ function install_tools() { echo -e "${COLOR_GREEN}config file already exists, skipping.${COLOR_RESET}" fi echo -e "${COLOR_BLUE}Installing NPM deps...${COLOR_RESET}" - npm install + npm install >> install.log echo -e "\n${COLOR_GREEN}NPM installed successfully.${COLOR_RESET}\n" touch $SETUP_FILE else @@ -339,19 +363,24 @@ function setup() { read -n 1 -s -r -p "" clear - echo -e "${COLOR_BLUE}This script requires Node.js, NPM, and Netcat to be installed on your system.${COLOR_RESET}" + echo -e "${COLOR_BLUE}This script requires Node.js, NPM, curl, lsof, and Netcat to be installed on your system.${COLOR_RESET}" echo -e "${COLOR_BLUE}It will attempt to install all of the required dependencies, although this might not work every time.${COLOR_RESET}" + echo -e "${COLOR_YELLOW}You may need to enter your sudo password.${COLOR_RESET}" echo -e "\nPress any key to continue with tool installation..." read -n 1 -s -r -p "" clear # Execute install tool script install_tools - # Install NPM dependencies - npm install - echo -e "\n${COLOR_GREEN}Dependency installation complete!${COLOR_RESET}" - echo -e "\n${COLOR_BLUE}If you would like to view the install logs, please do so, or click [ENTER] to continue to the next step.${COLOR_RESET}\n" + # Install NPM dependencies + echo -e "\n${COLOR_BLUE}Installing NPM dependencies...${COLOR_RESET}" + npm install >> install.log + echo -e "${COLOR_GREEN}Done.${COLOR_RESET}" + + echo -e "\n\n${COLOR_GREEN}Dependency installation complete!${COLOR_RESET}" + echo -e "${COLOR_BLUE}You can view the complete log of the installation process in the install.log file${COLOR_RESET}" + echo -e "\nPress [ENTER] to continue to the next step." read -n 1 -s -r -p "" clear