# Troubleshooting Deployment Issues

## CIFS Mount Permission Denied

If you get `mount error(13): Permission denied`, try these solutions:

### Solution 1: Use Credentials File (Recommended)

```bash
# Create credentials file
sudo nano /root/.smb_credentials
```

Add:
```
username=Administrator
password=YOUR_PASSWORD
domain=
```

```bash
# Set permissions
sudo chmod 600 /root/.smb_credentials

# Mount with credentials file
sudo mount -t cifs //10.10.10.5/LRS_STORAGE /mnt/aumentum_contentstore \
  -o credentials=/root/.smb_credentials,uid=$(id -u plagis),gid=$(id -g plagis),iocharset=utf8,file_mode=0777,dir_mode=0777,vers=3.0
```

### Solution 2: Use Different SMB Version

```bash
# Try SMB version 2.0
sudo mount -t cifs //10.10.10.5/LRS_STORAGE /mnt/aumentum_contentstore \
  -o username=Administrator,password=YOURPASS,uid=$(id -u plagis),gid=$(id -g plagis),vers=2.0

# Or try SMB version 1.0 (less secure, but sometimes needed)
sudo mount -t cifs //10.10.10.5/LRS_STORAGE /mnt/aumentum_contentstore \
  -o username=Administrator,password=YOURPASS,uid=$(id -u plagis),gid=$(id -g plagis),vers=1.0
```

### Solution 3: Check Network and Permissions

```bash
# Test network connectivity
ping 10.10.10.5

# Test SMB port
telnet 10.10.10.5 445

# Check if share is accessible
smbclient -L //10.10.10.5 -U Administrator

# Check kernel messages
dmesg | tail -20
```

### Solution 4: Use Automated Script

```bash
sudo bash scripts/fix_mount_permissions.sh
```

## Service Not Starting

### Check Service Status

```bash
sudo systemctl status plagis-aumentum-api
```

### View Logs

```bash
# Systemd logs
sudo journalctl -u plagis-aumentum-api -f

# Application logs
sudo tail -f /var/log/plagis/api.log
sudo tail -f /var/log/plagis/api-error.log
```

### Common Issues

1. **Wrong paths in service file**: Update paths if app is not in `/opt/plagis_aumentum`
2. **Database connection failed**: Check FreeTDS configuration
3. **Contentstore not mounted**: Mount the share first
4. **Permission issues**: Check file ownership and permissions

## Database Connection Issues

### Test FreeTDS Connection

```bash
tsql -S MSSQL_LRS43_PROD -U sa -P 'Plagis$registry'
```

### Test ODBC Connection

```bash
isql -v MSSQL_LRS43_PROD sa 'Plagis$registry'
```

### Check FreeTDS Configuration

```bash
cat /etc/freetds/freetds.conf | grep -A 5 MSSQL_LRS43_PROD
```

Should show:
```
[MSSQL_LRS43_PROD]
    host = 10.10.10.5
    port = 1433
    tds version = 7.4
```

## Microsoft Package GPG Error

This is a warning and won't block deployment. To fix:

```bash
curl https://packages.microsoft.com/keys/microsoft.asc | sudo apt-key add -
sudo apt-get update
```

Or disable the repository if not needed:
```bash
sudo rm /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-get update
```

