diff --git a/install.sh b/install.sh index caaac2b..c0327d1 100644 --- a/install.sh +++ b/install.sh @@ -170,11 +170,16 @@ git pull || { echo "❌ Failed to pull the latest changes. Exiting..."; exit 1; # Install npm dependencies echo "📦 Installing npm dependencies..." -npm install +npm install -silent # Copy configuration file -echo "📑 Copying default.config.js to config.js..." -cp default.config.js config.js +echo "📑 Checking if config.js exists..." +if [ -e config.js ]; then + echo "⚠️ config.js already exists. Skipping copy..." +else + echo "📑 Copying default.config.js to config.js..." + cp default.config.js config.js +fi # Update config.js with API token, Server ID, and UFW log path config_file="config.js" @@ -205,15 +210,18 @@ sudo npm uninstall corepack -g -silent echo "📦 Installing PM2..." sudo npm install pm2 -g -silent + # Configure PM2 echo "⚙️ Adding PM2 to autostart..." startup_command=$(pm2 startup | grep "sudo env PATH" | sed 's/^[^s]*sudo/sudo/') if [ -n "$startup_command" ]; then - echo "⚙️ $startup_command..." - eval "$startup_command" + echo "⚙️ Executing: $startup_command" + eval "$startup_command" &>/dev/null || { + echo "❌ Failed to execute the startup command!" + } else - echo "❌ Failed to find the command generated by 'pm2 startup'! PM2 was not added to autostart." + echo "❌ Failed to find the command generated by pm2 startup! PM2 was not added to autostart." fi echo "⚙️ Running PM2 save..."