#!/bin/sh /etc/rc.common
# MMPM - MagicMirror Package Manager service

START=96
STOP=09
USE_PROCD=1

PROG=/usr/sbin/mmpmctl

start_service() {
	local enabled
	config_load mmpm
	config_get enabled main enabled '0'

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

	procd_open_instance
	procd_set_param command "$PROG" service-run
	procd_set_param respawn ${respawn_threshold:-3600} ${respawn_timeout:-5} ${respawn_retry:-5}
	procd_set_param stdout 1
	procd_set_param stderr 1
	procd_close_instance
}

stop_service() {
	"$PROG" service-stop
}

reload_service() {
	stop
	start
}

service_triggers() {
	procd_add_reload_trigger "mmpm"
}
