# Setting Up Independent System (No Windows Server Dependency)

## Current Situation

✅ **Database**: Already independent (MySQL on localhost)  
❌ **Contentstore**: Still configured for Windows share (10.10.10.3)

## Goal

Make the application completely independent - no dependency on Windows server at 10.10.10.3.

## Solution Options

### Option 1: Local Contentstore Directory (Recommended)

**Steps:**

1. **Create local contentstore directory:**
   ```bash
   sudo mkdir -p /opt/aumentum/contentstore
   sudo chown $USER:$USER /opt/aumentum/contentstore
   ```

2. **Set environment variable:**
   ```bash
   export CONTENTSTORE_BASE=/opt/aumentum/contentstore
   # Add to ~/.bashrc for persistence:
   echo 'export CONTENTSTORE_BASE=/opt/aumentum/contentstore' >> ~/.bashrc
   ```

3. **Copy files from Windows server (one-time):**
   ```bash
   # If you have access to copy files:
   rsync -avz //10.10.10.3/LRS_STORAGE/contentstore/ /opt/aumentum/contentstore/
   # OR use scp, samba, etc.
   ```

4. **Update application to use local path:**
   - The application already checks `CONTENTSTORE_BASE` environment variable
   - No code changes needed!

### Option 2: Use Existing Local Directory

If you already have contentstore files somewhere locally:

```bash
# Find where your files are
find / -type d -name "contentstore" 2>/dev/null | head -5

# Set environment variable to that path
export CONTENTSTORE_BASE=/path/to/your/local/contentstore
```

### Option 3: Start Fresh (No Historical Files)

If you don't need old files and will only process new documents:

```bash
# Create empty contentstore
mkdir -p ~/aumentum_contentstore
export CONTENTSTORE_BASE=~/aumentum_contentstore
```

## Quick Setup Script

Create a setup script:

```bash
#!/bin/bash
# setup_independent_system.sh

# 1. Create local contentstore directory
CONTENTSTORE_DIR="/opt/aumentum/contentstore"
sudo mkdir -p "$CONTENTSTORE_DIR"
sudo chown $USER:$USER "$CONTENTSTORE_DIR"

# 2. Set environment variable
export CONTENTSTORE_BASE="$CONTENTSTORE_DIR"
echo "export CONTENTSTORE_BASE=$CONTENTSTORE_DIR" >> ~/.bashrc

# 3. Verify
echo "✅ Contentstore directory created: $CONTENTSTORE_DIR"
echo "✅ Environment variable set: CONTENTSTORE_BASE=$CONTENTSTORE_DIR"
echo ""
echo "Next steps:"
echo "1. Copy files from Windows server (if needed)"
echo "2. Restart your application"
echo "3. Verify with: ls $CONTENTSTORE_DIR"
```

## Verification

After setup, verify:

```bash
# Check environment variable
echo $CONTENTSTORE_BASE

# Check directory exists
ls -la $CONTENTSTORE_BASE

# Test application
source venv/bin/activate
python3 -c "from aumentum_browser_service import DEFAULT_CONTENTSTORE_BASE; import os; print('Contentstore:', DEFAULT_CONTENTSTORE_BASE); print('Exists:', os.path.exists(DEFAULT_CONTENTSTORE_BASE))"
```

## Database vs Contentstore

Remember:
- **Database (MySQL)**: Stores metadata (document numbers, paths) ✅ Already independent
- **Contentstore**: Stores actual files (.bin images) ❌ Needs to be made local

## Migration Strategy

If you need to migrate files from Windows server:

1. **One-time copy** (if you have access):
   ```bash
   # Mount Windows share temporarily
   sudo mkdir -p /mnt/temp_windows
   sudo mount -t cifs //10.10.10.3/LRS_STORAGE /mnt/temp_windows \
     -o username=Administrator,password=YOURPASS
   
   # Copy files
   rsync -avz --progress /mnt/temp_windows/contentstore/ /opt/aumentum/contentstore/
   
   # Unmount
   sudo umount /mnt/temp_windows
   ```

2. **Or use existing backup** if you have one

3. **Or start fresh** if historical files aren't needed

## Application Configuration

The application will automatically use `CONTENTSTORE_BASE` environment variable. No code changes needed!

