#!/bin/bash
set -u

CONTAINER_NAME="havline"
LOG_FILE="${TRIM_TEMP_LOGFILE:-/dev/stderr}"

log_error() {
  echo "$1" > "$LOG_FILE"
}

is_running() {
  docker inspect "$CONTAINER_NAME" 2>/dev/null | grep -q '"Status": "running"'
}

case "${1:-}" in
  start|stop)
    exit 0
    ;;
  status)
    if is_running; then
      exit 0
    fi
    exit 3
    ;;
  *)
    log_error "Unknown command: ${1:-}"
    exit 1
    ;;
esac
