#!/bin/sh /etc/rc.common

START=95
STOP=10
USE_PROCD=1

SERVICE_BIN="/usr/sbin/rustdeskctl"

start_service() {
	local enabled
	config_load rustdesk
	config_get enabled server enabled 0

	[ "$enabled" = "1" ] || return 0

	procd_open_instance
	procd_set_param command "$SERVICE_BIN" service-run
	procd_set_param respawn 3600 5 5
	procd_close_instance
}

stop_service() {
	"$SERVICE_BIN" service-stop >/dev/null 2>&1
}

reload_service() {
	stop
	start
}

service_triggers() {
	procd_add_reload_trigger "rustdesk"
}
