From 1c056de3b05aca55183429e99a44475aab665daf Mon Sep 17 00:00:00 2001 From: Sefinek Date: Sat, 18 Jan 2025 03:50:55 +0100 Subject: [PATCH] Fixes --- install.sh | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/install.sh b/install.sh index d36f576..bcb1418 100644 --- a/install.sh +++ b/install.sh @@ -36,9 +36,9 @@ check_dependencies() { for dep in "${missing[@]}"; do if yes_no_prompt "📦 Do you want to install $dep?"; then 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 -f nodesource_setup.sh ;; - git ) add-apt-repository ppa:git-core/ppa && apt-get update && apt-get -y install git ;; + curl ) sudo apt-get install -y curl ;; + node ) curl -fsSL https://deb.nodesource.com/setup_22.x -o nodesource_setup.sh && sudo bash nodesource_setup.sh && sudo apt-get install -y nodejs && rm -f nodesource_setup.sh ;; + git ) sudo add-apt-repository ppa:git-core/ppa && sudo apt-get update && sudo apt-get -y install git ;; esac else echo "❌ Cannot proceed without $dep. Exiting..." @@ -81,7 +81,7 @@ validate_token() { if [[ ! -f /var/log/ufw.log ]]; then 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." + echo "✅ Log file found at $ufw_log_path" else echo "❌ Provided log file path does not exist. Exiting..." exit 1 @@ -116,7 +116,7 @@ done # Prompt for system update and upgrade if yes_no_prompt "🛠️ Do you want the script to run apt update and apt upgrade for you?"; then echo "🔧 Updating and upgrading the system..." - apt-get update && apt-get upgrade + sudo apt-get update && sudo apt-get upgrade fi # Clone repository & set permissions @@ -164,7 +164,7 @@ fi # Change permissions for UFW log file echo "🔒 Changing permissions for $ufw_log_path..." -chmod 644 "$ufw_log_path" +sudo chmod 644 "$ufw_log_path" # Uninstall corepack echo "🗑️ Uninstalling corepack..." @@ -179,14 +179,17 @@ echo "📂 Creating /var/log/ufw-abuseipdb directory..." sudo mkdir -p /var/log/ufw-abuseipdb sudo chown "$USER":"$USER" /var/log/ufw-abuseipdb -R -# Configure pm2 +# Configure PM2 echo "⚙️ Configuring PM2..." -pm2 start -pm2 startup +startup_command=$(pm2 startup | grep "sudo env PATH" | sed 's/^[^s]*sudo/sudo/') -# Execute the command generated by pm2 startup -echo "🔧 Complete pm2 startup configuration (for $USER):" -sudo env PATH="$PATH":/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u "$USER" --hp /opt/"$USER" +if [ -n "$startup_command" ]; then + echo "🔧 Executing PM2 startup command..." + echo "📝 $startup_command" + eval "$startup_command" +else + echo "❌ Failed to find the command generated by 'pm2 startup'! PM2 was not added to autostart." +fi pm2 save