#!/bin/bash
# Fix Permissions Script for Live Server
# Upload this and run: bash fix_permissions.sh

echo "==================================="
echo "Fixing Auriga Portal Permissions"
echo "==================================="

# Get current directory
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$SCRIPT_DIR"

echo ""
echo "Current directory: $(pwd)"
echo ""

# Create directories if they don't exist
echo "Creating directories if missing..."
mkdir -p application/cache
mkdir -p application/logs
mkdir -p uploads/attachments

# Fix directory permissions
echo "Setting directory permissions..."
chmod 777 application/cache
chmod 755 application/logs
chmod 755 uploads/attachments
chmod 755 uploads
chmod 755 application

# Fix file permissions
echo "Setting file permissions..."
chmod 644 index.php
chmod 644 .htaccess 2>/dev/null || echo ".htaccess not found - please upload it!"

# Verify
echo ""
echo "==================================="
echo "Verification:"
echo "==================================="
ls -ld application/cache application/logs uploads/attachments

echo ""
echo "==================================="
echo "DONE! Now test your site:"
echo "https://brandwave.aurigaconsulting.co.in/auth/login"
echo "==================================="
