summaryrefslogtreecommitdiff
path: root/net/https-dns-proxy/files/https_dns_proxy.init
blob: 9a5f797925f085ee9599a5c939a46782b67f2ac9 (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
47
48
#!/bin/sh /etc/rc.common

START=80

USE_PROCD=1
PROG=/usr/sbin/https_dns_proxy

start_instance() {
	local cfg="$1"
	local listen_addr listen_port user group

	config_get listen_addr "$cfg" listen_addr
	config_get listen_port "$cfg" listen_port
	config_get user "$cfg" user
	config_get group "$cfg" group
	config_get subnet_addr "$cfg" subnet_addr
	config_get proxy_server "$cfg" proxy_server
	config_get url_prefix "$cfg" url_prefix

	if [ -n "$subnet_addr" ]; then
		subnet_param="-e $subnet_addr"
	fi

	if [ -n "$proxy_server" ]; then
		proxy_param="-t $proxy_server"
	fi

	if [ -z "$url_prefix" ]; then
		url_prefix="https://dns.google.com/resolve?"
	fi

	procd_open_instance
	procd_set_param command ${PROG} \
		-a "$listen_addr" -p "$listen_port" \
		-u "$user" -g "$group" $subnet_param $proxy_param \
		-r "$url_prefix"
	procd_set_param respawn
	procd_close_instance
}

service_triggers() {
	procd_add_reload_trigger "https_dns_proxy"
}

start_service() {
	config_load 'https_dns_proxy'
	config_foreach start_instance 'https_dns_proxy'
}