mirror of
https://github.com/DeNNiiInc/Advanced-Smtp-Tester.git
synced 2026-04-19 18:25:59 +00:00
Add deployment scripts and config
This commit is contained in:
50
scripts/setup-server.sh
Normal file
50
scripts/setup-server.sh
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Exit on error
|
||||
set -e
|
||||
|
||||
APP_NAME="Advanced-Smtp-Tester"
|
||||
APP_DIR="/var/www/$APP_NAME"
|
||||
|
||||
echo "🚀 Starting Server Setup for $APP_NAME..."
|
||||
|
||||
# 1. Install Dependencies
|
||||
echo "📦 Installing system dependencies..."
|
||||
apt-get update
|
||||
# Note: nodejs and npm should be present in the TurnKey Node.js template
|
||||
apt-get install -y git nginx curl build-essential
|
||||
|
||||
# Install PM2 globally if not exists
|
||||
if ! command -v pm2 &> /dev/null; then
|
||||
echo "📦 Installing PM2..."
|
||||
npm install -g pm2
|
||||
fi
|
||||
|
||||
# 2. Setup Nginx
|
||||
echo "⚙️ Configuring Nginx..."
|
||||
cp "$APP_DIR/config/nginx.conf.template" "/etc/nginx/sites-available/$APP_NAME"
|
||||
# Remove default site if exists
|
||||
rm -f /etc/nginx/sites-enabled/default
|
||||
rm -f /etc/nginx/sites-enabled/nodejs # Common in TurnKey
|
||||
# Enable site
|
||||
ln -sf "/etc/nginx/sites-available/$APP_NAME" "/etc/nginx/sites-enabled/"
|
||||
# Test and Reload
|
||||
nginx -t && systemctl reload nginx
|
||||
|
||||
# 3. Setup PM2
|
||||
echo "⚙️ Configuring PM2..."
|
||||
cd "$APP_DIR"
|
||||
pm2 start ecosystem.config.js
|
||||
pm2 save
|
||||
pm2 startup systemd -u root --hp /root
|
||||
|
||||
# 4. Setup Cron Job for Auto-Sync (Every 5 minutes)
|
||||
echo "⏰ Setting up Auto-Sync Cron Job..."
|
||||
SCRIPT_PATH="$APP_DIR/scripts/sync-and-restart.sh"
|
||||
chmod +x "$SCRIPT_PATH"
|
||||
|
||||
# Add to crontab if not already there
|
||||
(crontab -l 2>/dev/null; echo "*/5 * * * * $SCRIPT_PATH") | awk '!x[$0]++' | crontab -
|
||||
|
||||
echo "✅ Setup Complete! Application is running and auto-sync is enabled."
|
||||
echo "🌐 Access your app at http://<YOUR_SERVER_IP>"
|
||||
Reference in New Issue
Block a user