summaryrefslogtreecommitdiffstats
path: root/net/hev-socks5-tunnel/files/hev-socks5-tunnel.init
blob: 70939345ff90162fc7135d472691ced69ce24117 (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
#!/bin/sh /etc/rc.common

USE_PROCD=1
START=99

CONF="hev-socks5-tunnel"
PROG="/usr/bin/hev-socks5-tunnel"

start_instance() {
	local enabled conffile
	config_get_bool enabled "$1" enabled 0
	[ "$enabled" -eq 1 ] || return 0
	config_get conffile "$1" conffile

	if [ ! -f "$conffile" ]; then
		logger -t "$CONF" -p daemon.err "instance '$1' not started, conffile not found: '$conffile'"
		return 1
	fi

	procd_open_instance "$1"
	procd_set_param command "$PROG" "$conffile"
	procd_set_param file "$conffile"
	procd_set_param limits core="unlimited"
	procd_set_param limits nofile="1000000 1000000"
	procd_set_param stdout 1
	procd_set_param stderr 1
	procd_set_param respawn
	procd_close_instance
}

start_service() {
	config_load "$CONF"
	config_foreach start_instance instance
}

service_triggers() {
	procd_add_reload_trigger "$CONF"
}