#!/bin/bash
# unraid-api-handler

# shellcheck source=/dev/null
source /etc/profile

flash="/boot/config/plugins/dynamix.my.servers"
[[ ! -d "${flash}" ]] && echo "Please reinstall the Unraid Connect plugin" && exit 1
[[ ! -f "${flash}/env" ]] && echo 'env=production' >"${flash}/env"
unraid_binary_path="/usr/local/bin/unraid-api"

install() {
  true;
}
uninstall() {
  true;
}

case "$1" in
'install')
  install "$2"
  ;;
'reload')
  restart
  ;;
'uninstall')
  uninstall
  ;;
*)
  # Pass all other commands to unraid-api
  "${unraid_binary_path}" "$@"
  ;;
esac
