#!/bin/bash
# OpenList wrapper script
# Automatically adds --force-bin-dir to all commands

BINARY="/var/lib/openlist/openlist"

# Check if the binary exists
if [ ! -x "$BINARY" ]; then
    echo "Error: OpenList binary not found at $BINARY"
    exit 1
fi

# Check if --force-bin-dir is already present in arguments
if [[ "$*" != *"--force-bin-dir"* ]]; then
    # Add --force-bin-dir to all commands
    exec "$BINARY" "$@" --force-bin-dir
else
    # --force-bin-dir already present, pass through as-is
    exec "$BINARY" "$@"
fi
