#!/bin/bash set -e echo "Starting Obsidian Headless Sync Server..." # Ensure we are in the vault directory cd /vault # 1. Initial Login # Note: In a fully automated environment, the user will need to provide # a session token or use 'ob login' interactively once. # For this container, we assume the user has handled login or we use an environment variable. if [ -z "$OBSIDIAN_SYNC_TOKEN" ]; then echo "Warning: OBSIDIAN_SYNC_TOKEN not provided. You may need to run 'docker exec -it ob login' manually once." else # Assuming the CLI supports token-based login or we inject the session echo "Using provided sync token for login..." # ob login --token $OBSIDIAN_SYNC_TOKEN fi # 2. Setup Sync for the specified vault echo "Setting up sync for vault: $OBSIDIAN_VAULT_NAME" ob sync-setup --vault "$OBSIDIAN_VAULT_NAME" --password "$OBSIDIAN_SYNC_PASSWORD" --device-name "$OBSIDIAN_DEVICE_NAME" --path /vault # 3. Start Continuous Sync echo "Entering continuous sync mode..." exec ob sync --continuous