# Installing kb_exfiltrator on Kobo

## Prerequisites

1. **NickelMenu** installed on your Kobo (usually comes with KOReader)
2. SSH access to your Kobo
3. Kobo connected to WiFi

## Installation

### 1. Copy files to Kobo

```bash
# Copy the binary
scp kb_exfiltrator-kobo-arm root@192.168.88.110:/usr/local/bin/kb_exfiltrator

# Copy the wrapper script
scp sync_highlights.sh root@192.168.88.110:/usr/local/bin/sync_highlights.sh

# Copy NickelMenu config
scp nickel_menu_config root@192.168.88.110:/mnt/onboard/.adds/nm/kb_exfiltrator
```

### 2. Set permissions via SSH

```bash
ssh root@192.168.88.110

chmod +x /usr/local/bin/kb_exfiltrator
chmod +x /usr/local/bin/sync_highlights.sh
```

### 3. Update the endpoint URL

Edit the script on the Kobo to use your server's IP/hostname:

```bash
vi /usr/local/bin/sync_highlights.sh
# Change: ENDPOINT="http://192.168.88.69:42070/api/highlights"
# To your actual server URL
```

### 4. Restart Kobo

The NickelMenu config is read on boot, so restart your Kobo:
```bash
reboot
```

## Usage

After rebooting, you'll see "Sync Highlights" in:
- Main menu (press the top-left Kobo icon)
- Reader menu (while reading a book)

Tap it to sync your highlights to your server!

## Logs

Check sync logs at: `/mnt/onboard/.adds/kb_exfiltrator.log`

## Manual Usage (via SSH)

```bash
ssh root@192.168.88.110
/usr/local/bin/kb_exfiltrator /mnt/onboard/.kobo/KoboReader.sqlite http://yourserver:42070/api/highlights
```

## Troubleshooting

### Menu item doesn't appear
- Check `/mnt/onboard/.adds/nm/kb_exfiltrator` exists
- Restart Kobo
- Check NickelMenu is installed

### Sync fails
- Check log: `cat /mnt/onboard/.adds/kb_exfiltrator.log`
- Verify WiFi is connected
- Test manually via SSH
- Verify server is running: `curl http://192.168.88.69:42070/`

### "No route to host"
- Kobo WiFi disconnected
- Server IP changed
- Edit `/usr/local/bin/sync_highlights.sh` with correct IP
