#!/bin/sh
# synopkgland: the SDK steps run in synopkgland_sdk; the App's dsm-scripts/start-stop-status runs from scripts/app/start-stop-status.
synopkgland_sdk() (
if [ "$1" = start ]; then
"${SYNOPKG_PKGDEST:-/var/packages/SynoReclaim/target}/executor/lifecycle" start --package SynoReclaim || exit $?
fi
if [ "$1" = stop ]; then
"${SYNOPKG_PKGDEST:-/var/packages/SynoReclaim/target}/executor/lifecycle" stop --package SynoReclaim || exit $?
exit 0
fi
case "$1" in
  start|stop|status) exit 0 ;;
  *) exit 1 ;;
esac
)
synopkgland_app="$(dirname "$0")/app/start-stop-status"
case "$1" in
  start)
    synopkgland_sdk "$@" || exit $?
    "$synopkgland_app" "$@" && exit 0
    synopkgland_result=$?
    synopkgland_sdk stop
    exit "$synopkgland_result" ;;
  stop|prestop)
    synopkgland_result=0
    "$synopkgland_app" "$@" || synopkgland_result=$?
    synopkgland_sdk "$@" || exit $?
    exit "$synopkgland_result" ;;
  restart)
    "$0" stop || exit $?
    exec "$0" start ;;
  *)
    synopkgland_sdk "$@" || exit $?
    exec "$synopkgland_app" "$@" ;;
esac
