#!/bin/sh /etc/rc.common
# OPENWRT / TINA LINUX START (Creality K2 Plus)
START=99
USE_PROCD=1
STOP=01
DEPEND=fstab,mcu_update

_3DPRINTEROS_PID=/tmp/3dprinteros.pid
_3DPRINTEROS_DIR="/mnt/UDISK/3dprinteros/3dprinteros-client"
_3DPRINTEROS_PY=$_3DPRINTEROS_DIR/launcher.py
_3DPRINTEROS_PYTHON=/mnt/UDISK/3dprinteros/3dprinteros-client-env/bin/python3

start_service() {
  procd_open_instance
  procd_set_param env HOME=/root
  procd_set_param pidfile $_3DPRINTEROS_PID
  procd_set_param command $_3DPRINTEROS_PYTHON $_3DPRINTEROS_PY
  procd_close_instance
}

stop_service() {
  if [ -f $_3DPRINTEROS_PID ]; then
      kill `cat $_3DPRINTEROS_PID`
  fi
}
