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
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
USER=${SUDO_USER:-$(whoami)}
|
|
||||||
|
|
||||||
# Function to prompt for a Yes/no answer
|
# Function to prompt for a Yes/no answer
|
||||||
yes_no_prompt() {
|
yes_no_prompt() {
|
||||||
local prompt="$1"
|
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
|
apt-get update && apt-get upgrade
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Clone repository
|
# Clone repository & set permissions
|
||||||
if [ ! -d "/opt" ]; then
|
if [ ! -d "/opt" ]; then
|
||||||
mkdir -p /opt
|
mkdir -p /opt
|
||||||
echo "📂 '/opt' has been created"
|
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
|
if [ ! -d "UFW-AbuseIPDB-Reporter" ]; then
|
||||||
echo "📥 Cloning the UFW-AbuseIPDB-Reporter repository..."
|
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
|
else
|
||||||
echo "✨ The UFW-AbuseIPDB-Reporter repository already exists!"
|
echo "✨ The UFW-AbuseIPDB-Reporter repository already exists!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
sudo chown "$USER":"$USER" /opt/UFW-AbuseIPDB-Reporter -R
|
||||||
|
|
||||||
echo "📥 Pulling latest changes..."
|
echo "📥 Pulling latest changes..."
|
||||||
cd UFW-AbuseIPDB-Reporter || { echo "❌ Failed to change directory to 'UFW-AbuseIPDB-Reporter'. Exiting..."; exit 1; }
|
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; }
|
git pull || { echo "❌ Failed to pull the latest changes. Exiting..."; exit 1; }
|
||||||
|
|
||||||
# Install npm dependencies
|
# Install npm dependencies
|
||||||
echo "📦 Installing npm dependencies..."
|
echo "📦 Installing npm dependencies..."
|
||||||
npm install --silent
|
npm install
|
||||||
|
|
||||||
# Copy configuration file
|
# Copy configuration file
|
||||||
echo "📑 Copying default.config.js to config.js..."
|
echo "📑 Copying default.config.js to config.js..."
|
||||||
@@ -168,32 +168,32 @@ chmod 644 "$ufw_log_path"
|
|||||||
|
|
||||||
# Uninstall corepack
|
# Uninstall corepack
|
||||||
echo "🗑️ Uninstalling corepack..."
|
echo "🗑️ Uninstalling corepack..."
|
||||||
npm uninstall corepack -g --silent
|
sudo npm uninstall corepack -g
|
||||||
|
|
||||||
# Install pm2
|
# Install pm2
|
||||||
echo "📦 Installing PM2..."
|
echo "📦 Installing PM2..."
|
||||||
npm install pm2 -g --silent
|
sudo npm install pm2 -g
|
||||||
|
|
||||||
# Create logs directory
|
# Create logs directory
|
||||||
echo "📂 Creating /var/log/ufw-abuseipdb directory..."
|
echo "📂 Creating /var/log/ufw-abuseipdb directory..."
|
||||||
mkdir -p /var/log/ufw-abuseipdb
|
sudo mkdir -p /var/log/ufw-abuseipdb
|
||||||
chown "$USER":"$USER" /var/log/ufw-abuseipdb -R
|
sudo chown "$USER":"$USER" /var/log/ufw-abuseipdb -R
|
||||||
|
|
||||||
# Configure pm2
|
# Configure pm2
|
||||||
echo "⚙️ Configuring PM2..."
|
echo "⚙️ Configuring PM2..."
|
||||||
sudo -u "$USER" pm2 start
|
pm2 start
|
||||||
sudo -u "$USER" pm2 startup
|
pm2 startup
|
||||||
|
|
||||||
# Execute the command generated by pm2 startup
|
# Execute the command generated by pm2 startup
|
||||||
echo "🔧 Complete pm2 startup configuration (for $USER):"
|
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 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
|
# Final
|
||||||
echo -e "\n\n🌌 Checking PM2 status..."
|
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."
|
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