184 lines
6.1 KiB
Bash
Executable File
184 lines
6.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# filepath: check-postfixadmin-paths.sh
|
|
|
|
# Check PostfixAdmin URL configuration and path handling
|
|
# This script verifies the correct URL structure for PostfixAdmin 3.3.11
|
|
|
|
set -euo pipefail
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
info() {
|
|
echo -e "${BLUE}INFO: $1${NC}"
|
|
}
|
|
|
|
success() {
|
|
echo -e "${GREEN}SUCCESS: $1${NC}"
|
|
}
|
|
|
|
warning() {
|
|
echo -e "${YELLOW}WARNING: $1${NC}"
|
|
}
|
|
|
|
error() {
|
|
echo -e "${RED}ERROR: $1${NC}" >&2
|
|
}
|
|
|
|
echo -e "${BLUE}=== PostfixAdmin Path Configuration Analysis ===${NC}"
|
|
echo
|
|
|
|
info "Analyzing setup script configuration..."
|
|
|
|
WEBROOT="/var/www/postfixadmin"
|
|
NGINX_CONFIG="/etc/nginx/sites-available/postfixadmin.conf"
|
|
|
|
echo -e "${YELLOW}=== Directory Structure ===${NC}"
|
|
echo "Installation Directory: $WEBROOT"
|
|
echo "Public Directory: $WEBROOT/public"
|
|
echo "Setup Script: $WEBROOT/public/setup.php"
|
|
echo "Main Interface: $WEBROOT/public/index.php"
|
|
echo
|
|
|
|
echo -e "${YELLOW}=== URL Structure ===${NC}"
|
|
echo "With the current Nginx configuration pointing to $WEBROOT/public:"
|
|
echo
|
|
echo "✅ CORRECT URLs:"
|
|
echo " • PostfixAdmin Setup: https://yourhostname/setup.php"
|
|
echo " • PostfixAdmin Main: https://yourhostname/"
|
|
echo " • PostfixAdmin Login: https://yourhostname/login.php"
|
|
echo
|
|
echo "❌ INCORRECT URLs (would result in 404):"
|
|
echo " • https://yourhostname/postfixadmin/setup.php"
|
|
echo " • https://yourhostname/postfixadmin/"
|
|
echo
|
|
|
|
echo -e "${YELLOW}=== How the Setup Script Handles PostfixAdmin ===${NC}"
|
|
echo
|
|
echo "1. **Installation**:"
|
|
echo " - Downloads PostfixAdmin 3.3.11 to $WEBROOT"
|
|
echo " - Creates templates_c directory for Smarty templates"
|
|
echo " - Sets proper permissions (www-data:www-data)"
|
|
echo
|
|
echo "2. **Nginx Configuration**:"
|
|
echo " - Document root points to: $WEBROOT/public"
|
|
echo " - This is correct for PostfixAdmin 3.3.11+ structure"
|
|
echo " - PHP files are processed through PHP-FPM"
|
|
echo
|
|
echo "3. **PostfixAdmin Configuration (config.local.php)**:"
|
|
echo " - configured = false (allows setup wizard)"
|
|
echo " - Proper database credentials"
|
|
echo " - Encryption: dovecot:SHA512-CRYPT (compatible)"
|
|
echo " - Templates directory: $WEBROOT/templates_c"
|
|
echo
|
|
echo "4. **Setup Process**:"
|
|
echo " - User visits: https://hostname/setup.php"
|
|
echo " - Setup wizard creates database tables"
|
|
echo " - Admin user is created"
|
|
echo " - Configuration is finalized"
|
|
echo
|
|
|
|
echo -e "${YELLOW}=== PostfixAdmin 3.3.11 Directory Structure ===${NC}"
|
|
echo "PostfixAdmin 3.3.11 uses this structure:"
|
|
echo "$WEBROOT/"
|
|
echo "├── public/ # Web-accessible files"
|
|
echo "│ ├── index.php # Main interface"
|
|
echo "│ ├── setup.php # Setup wizard"
|
|
echo "│ ├── login.php # Login page"
|
|
echo "│ ├── css/ # Stylesheets"
|
|
echo "│ ├── js/ # JavaScript"
|
|
echo "│ └── images/ # Images"
|
|
echo "├── templates/ # Smarty templates"
|
|
echo "├── templates_c/ # Compiled templates (writable)"
|
|
echo "├── model/ # Application logic"
|
|
echo "├── languages/ # Translation files"
|
|
echo "└── config.local.php # Configuration file"
|
|
echo
|
|
|
|
echo -e "${YELLOW}=== Security Benefits ===${NC}"
|
|
echo "By pointing Nginx to the public/ directory:"
|
|
echo "✅ Configuration files are not web-accessible"
|
|
echo "✅ Template files are not web-accessible"
|
|
echo "✅ Application logic is not web-accessible"
|
|
echo "✅ Only intended public files can be accessed"
|
|
echo
|
|
|
|
# Check if files exist
|
|
echo -e "${YELLOW}=== Current Installation Check ===${NC}"
|
|
if [[ -d "$WEBROOT" ]]; then
|
|
success "PostfixAdmin directory exists: $WEBROOT"
|
|
|
|
if [[ -d "$WEBROOT/public" ]]; then
|
|
success "✅ Public directory exists: $WEBROOT/public"
|
|
|
|
if [[ -f "$WEBROOT/public/setup.php" ]]; then
|
|
success "✅ Setup script exists: $WEBROOT/public/setup.php"
|
|
else
|
|
warning "⚠️ Setup script not found: $WEBROOT/public/setup.php"
|
|
fi
|
|
|
|
if [[ -f "$WEBROOT/public/index.php" ]]; then
|
|
success "✅ Main interface exists: $WEBROOT/public/index.php"
|
|
else
|
|
warning "⚠️ Main interface not found: $WEBROOT/public/index.php"
|
|
fi
|
|
else
|
|
error "❌ Public directory missing: $WEBROOT/public"
|
|
echo " This indicates PostfixAdmin was not extracted correctly"
|
|
fi
|
|
|
|
if [[ -f "$WEBROOT/config.local.php" ]]; then
|
|
success "✅ Configuration file exists: $WEBROOT/config.local.php"
|
|
else
|
|
warning "⚠️ Configuration file not found: $WEBROOT/config.local.php"
|
|
fi
|
|
|
|
if [[ -d "$WEBROOT/templates_c" ]]; then
|
|
success "✅ Templates cache directory exists: $WEBROOT/templates_c"
|
|
|
|
if [[ -w "$WEBROOT/templates_c" ]]; then
|
|
success "✅ Templates cache directory is writable"
|
|
else
|
|
error "❌ Templates cache directory is not writable"
|
|
fi
|
|
else
|
|
warning "⚠️ Templates cache directory missing: $WEBROOT/templates_c"
|
|
fi
|
|
else
|
|
warning "PostfixAdmin not yet installed: $WEBROOT"
|
|
fi
|
|
|
|
# Check Nginx configuration
|
|
echo
|
|
if [[ -f "$NGINX_CONFIG" ]]; then
|
|
success "✅ Nginx configuration exists: $NGINX_CONFIG"
|
|
|
|
if grep -q "root.*public" "$NGINX_CONFIG"; then
|
|
success "✅ Nginx points to public directory"
|
|
else
|
|
warning "⚠️ Nginx may not be pointing to public directory"
|
|
fi
|
|
|
|
if [[ -L "/etc/nginx/sites-enabled/postfixadmin.conf" ]]; then
|
|
success "✅ Nginx site is enabled"
|
|
else
|
|
warning "⚠️ Nginx site is not enabled"
|
|
fi
|
|
else
|
|
warning "Nginx configuration not found: $NGINX_CONFIG"
|
|
fi
|
|
|
|
echo
|
|
echo -e "${BLUE}=== Summary ===${NC}"
|
|
echo "The setup script correctly handles PostfixAdmin paths by:"
|
|
echo "1. Installing to $WEBROOT"
|
|
echo "2. Configuring Nginx to serve from $WEBROOT/public"
|
|
echo "3. Making setup.php accessible at https://hostname/setup.php"
|
|
echo "4. Ensuring proper security by hiding non-public files"
|
|
echo
|
|
echo -e "${GREEN}Path configuration is correct for PostfixAdmin 3.3.11!${NC}"
|