diff --git a/install.sh b/install.sh index d16f619..7f2da37 100644 --- a/install.sh +++ b/install.sh @@ -12,7 +12,7 @@ check_dependencies() { local missing=() for dependency in "${dependencies[@]}"; do - if ! command -v $dependency &> /dev/null; then + if ! command -v "$dependency" &> /dev/null; then missing+=("$dependency") fi done @@ -20,12 +20,12 @@ check_dependencies() { if [[ ${#missing[@]} -gt 0 ]]; then echo "🚨 Missing dependencies: ${missing[*]}" for dep in "${missing[@]}"; do - read -p "šŸ“¦ Do you want to install $dep? [Yes/No]: " answer + read -r -p "šŸ“¦ Do you want to install $dep? [Yes/No]: " answer case $answer in [Yy]*|[Yy]es ) case $dep in curl ) apt-get install -y curl ;; - node ) curl -fsSL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh && bash nodesource_setup.sh && apt-get install -y nodejs && rm nodesource_setup.sh -f ;; + node ) curl -fsSL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh && bash nodesource_setup.sh && apt-get install -y nodejs && rm -f nodesource_setup.sh ;; git ) add-apt-repository ppa:git-core/ppa && apt-get update && apt-get -y install git ;; esac ;; @@ -64,7 +64,7 @@ validate_token() { # Check for UFW log file if [[ ! -f /var/log/ufw.log ]]; then - read -p "šŸ” /var/log/ufw.log not found. Please enter the path to your log file: " ufw_log_path + read -r -p "šŸ” /var/log/ufw.log not found. Please enter the path to your log file: " ufw_log_path if [[ -f $ufw_log_path ]]; then echo "āœ… Log file found at $ufw_log_path." else @@ -78,7 +78,7 @@ fi # Prompt for AbuseIPDB API token while true; do - read -p "šŸ”‘ Please enter your AbuseIPDB API token: " api_token + read -r -p "šŸ”‘ Please enter your AbuseIPDB API token: " api_token if validate_token "$api_token"; then break fi @@ -86,13 +86,13 @@ while true; do done # Prompt for server ID -read -p "šŸ–„ļø Enter your Server ID (leave blank for null): " server_id +read -r -p "šŸ–„ļø Enter your Server ID (leave blank for null): " server_id if [[ -z $server_id ]]; then server_id=null fi # Prompt for system update and upgrade -read -p "šŸ› ļø Do you want to update and upgrade the system (apt upgrade)? [Yes/No]: " answer +read -r -p "šŸ› ļø Do you want to update and upgrade the system (apt upgrade)? [Yes/No]: " answer case $answer in [Yy]*|[Yy]es ) echo "šŸ”§ Updating and upgrading the system..." @@ -108,13 +108,13 @@ case $answer in esac # Clone repository -cd /home +cd /home || exit if [ ! -d "UFW-AbuseIPDB-Reporter" ]; then echo "šŸ“‚ Cloning the UFW-AbuseIPDB-Reporter repository..." git clone https://github.com/sefinek/UFW-AbuseIPDB-Reporter.git --branch node.js else echo "šŸ“‚ The UFW-AbuseIPDB-Reporter repository already exists. Pulling latest changes..." - cd UFW-AbuseIPDB-Reporter + cd UFW-AbuseIPDB-Reporter || exit git pull fi @@ -166,7 +166,7 @@ sudo env PATH="$PATH":/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd pm2 save -echo "šŸŽ‰ Installation and configuration completed!" +echo -e "\n\nšŸŽ‰ Installation and configuration completed!" # Final