36 lines
769 B
Bash
36 lines
769 B
Bash
|
|
#!/bin/bash
|
||
|
|
# Setup Nginx configuration
|
||
|
|
|
||
|
|
set -e
|
||
|
|
|
||
|
|
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||
|
|
DEPLOYMENT_DIR="$( cd "$SCRIPT_DIR/.." && pwd )"
|
||
|
|
|
||
|
|
echo "Setting up Nginx configuration..."
|
||
|
|
|
||
|
|
# Install Nginx if not installed
|
||
|
|
if ! command -v nginx &> /dev/null; then
|
||
|
|
apt update
|
||
|
|
apt install -y nginx
|
||
|
|
fi
|
||
|
|
|
||
|
|
# Copy configuration
|
||
|
|
cp "$DEPLOYMENT_DIR/nginx/explorer.conf" /etc/nginx/sites-available/explorer
|
||
|
|
|
||
|
|
# Enable site
|
||
|
|
ln -sf /etc/nginx/sites-available/explorer /etc/nginx/sites-enabled/
|
||
|
|
|
||
|
|
# Remove default site
|
||
|
|
rm -f /etc/nginx/sites-enabled/default
|
||
|
|
|
||
|
|
# Test configuration
|
||
|
|
if nginx -t; then
|
||
|
|
echo "Nginx configuration is valid"
|
||
|
|
systemctl reload nginx
|
||
|
|
echo "Nginx reloaded"
|
||
|
|
else
|
||
|
|
echo "ERROR: Nginx configuration test failed"
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|