#!/bin/sh /etc/rc.common
# Copyright (C) 2021 Tianling Shen <cnsztl@immortalwrt.org>

USE_PROCD=1
START=99

CONF="uugamebooster"
PROG="/usr/bin/uugamebooster"

UU_CONF="/usr/share/uugamebooster/uu.conf"

start_service() {
	config_load "$CONF"
	local enabled
	config_get_bool enabled "config" "enabled" "0"
	[ "$enabled" -eq "1" ] || return 1

	procd_open_instance "$CONF"

	procd_set_param command "$PROG" "$UU_CONF"

	procd_set_param limits core="unlimited"
	procd_set_param respawn
	procd_set_param stdout 1
	procd_set_param stderr 1

	procd_close_instance
}

reload_service() {
	stop
	start
}

service_triggers() {
	procd_add_reload_trigger "$CONF"
}
