summaryrefslogtreecommitdiffstats
path: root/net/shunt/files/shunt.init
blob: 004257026cf9992bf4635a00d173c2d93d643390 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh /etc/rc.common
# shunt - policy based routing
#
# SPDX-License-Identifier: GPL-3.0-or-later
# Copyright (c) 2026 Dirk Brenken (dev@brenken.org)

START=95
USE_PROCD=1

shunt_init="/etc/init.d/shunt"

if [ -z "${IPKG_INSTROOT}" ]; then
	case "${action}" in
	"stop")
		"${shunt_init}" running || exit 0
		;;
	"restart" | "reload")
		if ! "${shunt_init}" running; then
			exec "${shunt_init}" start
		fi
		;;
	esac
fi

start_service() {
	if "${shunt_init}" enabled; then
		procd_open_instance "shunt"
		procd_set_param command /usr/sbin/shunt run
		procd_set_param respawn 300 5 3
		procd_set_param stdout 0
		procd_set_param stderr 1
		procd_close_instance
	fi
}

stop_service() {
	/usr/sbin/shunt flush 2>/dev/null
}

service_triggers() {
	procd_add_reload_trigger "shunt"
}

reload_service() {
	restart
}