#!/bin/bash

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

case "${1:-}" in
  start)
    if docker container inspect cmsingbox-fnos >/dev/null 2>&1; then
      docker start cmsingbox-fnos >/dev/null
    else
      . "$(dirname "$0")/network_lib"
      deploy_cmsingbox || exit 1
    fi
    exit 0
    ;;
  stop)
    docker stop cmsingbox-fnos >/dev/null 2>&1 || true
    exit 0
    ;;
  status)
    if is_running; then exit 0; else exit 3; fi
    ;;
  *)
    echo "不支持的操作: ${1:-}" > "${TRIM_TEMP_LOGFILE:-/tmp/cmsingbox-fnos.log}"
    exit 1
    ;;
esac
