#!/bin/sh
### BEGIN INIT INFO
# Provides:          opendance-api
# Required-Start:    $network $remote_fs $local_fs
# Required-Stop:     $network $remote_fs $local_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: OpenDance Studio Web 管理服务端
# Description:       OpenDance Studio Web 管理服务端（NestJS + TypeORM）
### END INIT INFO
#
# SysVinit / LSB 启动脚本。实际启停逻辑复用 deploy/ctl.sh，
# 避免 systemd / SysV / 纯进程三种模式各写一份。
#
# 也可以直接手动调用：
#   /etc/init.d/opendance-api start|stop|restart|status

APP_DIR="__APP_DIR__"
SERVICE_USER="__SERVICE_USER__"

export APP_DIR SERVICE_USER

case "$1" in
  start|stop|restart|status)
    ;;
  reload|force-reload)
    set -- restart
    ;;
  *)
    echo "用法: $0 {start|stop|restart|status}" >&2
    exit 2
    ;;
esac

exec /bin/bash "$APP_DIR/deploy/ctl.sh" "$1"
