Fixes
This commit is contained in:
1 parent
6254d47426
commit
51ec6f451c
1 file changed
+13
-13
+13
-13
@@ -1,7 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
USER=${SUDO_USER:-$(whoami)}
|
||||
|
||||
# Function to prompt for a Yes/no answer
|
||||
yes_no_prompt() {
|
||||
local prompt="$1"
|
||||
@@ -121,7 +119,7 @@ if yes_no_prompt "🛠️ Do you want the script to run apt update and apt upgra
|
||||
apt-get update && apt-get upgrade
|
||||
fi
|
||||
|
||||
# Clone repository
|
||||
# Clone repository & set permissions
|
||||
if [ ! -d "/opt" ]; then
|
||||
mkdir -p /opt
|
||||
echo "📂 '/opt' has been created"
|
||||
@@ -133,18 +131,20 @@ cd /opt || { echo "❌ Failed to change directory to '/opt'. Exiting..."; exit 1
|
||||
|
||||
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 || { echo "❌ Failed to clone the repository. Exiting..."; exit 1; }
|
||||
sudo git clone https://github.com/sefinek/UFW-AbuseIPDB-Reporter.git --branch node.js || { echo "❌ Failed to clone the repository. Exiting..."; exit 1; }
|
||||
else
|
||||
echo "✨ The UFW-AbuseIPDB-Reporter repository already exists!"
|
||||
fi
|
||||
|
||||
sudo chown "$USER":"$USER" /opt/UFW-AbuseIPDB-Reporter -R
|
||||
|
||||
echo "📥 Pulling latest changes..."
|
||||
cd UFW-AbuseIPDB-Reporter || { echo "❌ Failed to change directory to 'UFW-AbuseIPDB-Reporter'. Exiting..."; exit 1; }
|
||||
git pull || { echo "❌ Failed to pull the latest changes. Exiting..."; exit 1; }
|
||||
|
||||
# Install npm dependencies
|
||||
echo "📦 Installing npm dependencies..."
|
||||
npm install --silent
|
||||
npm install
|
||||
|
||||
# Copy configuration file
|
||||
echo "📑 Copying default.config.js to config.js..."
|
||||
@@ -168,32 +168,32 @@ chmod 644 "$ufw_log_path"
|
||||
|
||||
# Uninstall corepack
|
||||
echo "🗑️ Uninstalling corepack..."
|
||||
npm uninstall corepack -g --silent
|
||||
sudo npm uninstall corepack -g
|
||||
|
||||
# Install pm2
|
||||
echo "📦 Installing PM2..."
|
||||
npm install pm2 -g --silent
|
||||
sudo npm install pm2 -g
|
||||
|
||||
# Create logs directory
|
||||
echo "📂 Creating /var/log/ufw-abuseipdb directory..."
|
||||
mkdir -p /var/log/ufw-abuseipdb
|
||||
chown "$USER":"$USER" /var/log/ufw-abuseipdb -R
|
||||
sudo mkdir -p /var/log/ufw-abuseipdb
|
||||
sudo chown "$USER":"$USER" /var/log/ufw-abuseipdb -R
|
||||
|
||||
# Configure pm2
|
||||
echo "⚙️ Configuring PM2..."
|
||||
sudo -u "$USER" pm2 start
|
||||
sudo -u "$USER" pm2 startup
|
||||
pm2 start
|
||||
pm2 startup
|
||||
|
||||
# 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"
|
||||
|
||||
sudo -u "$USER" pm2 save
|
||||
pm2 save
|
||||
|
||||
|
||||
# Final
|
||||
echo -e "\n\n🌌 Checking PM2 status..."
|
||||
sudo -u "$USER" pm2 status
|
||||
pm2 status
|
||||
|
||||
echo -e "\n🎉 Installation and configuration completed! Use the 'pm2 logs' command to monitor logs in real time."
|
||||
|
||||
|
||||
Reference in new issue
Block a user