aboutsummaryrefslogtreecommitdiffstats
path: root/main/dnsmasq/dnsmasq.initd
blob: c92853416db7524f3046069c80991fc726001433 (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
#!/sbin/openrc-run

description="A lightweight DNS, DHCP, RA, TFTP and PXE server"

extra_commands="checkconfig"
description_checkconfig="Check configuration syntax"

extra_started_commands="reload"
description_reload="Clear cache and reload hosts files"

command="/usr/sbin/dnsmasq"
# Tell dnsmasq to not create pidfile, that's responsibility of init system.
command_args="-k --pid-file= $DNSMASQ_OPTS"
command_background="yes"
pidfile="/run/dnsmasq.pid"

depend() {
	provide dns
	need localmount net
	after bootmisc
	use logger
}

start_pre() {
	$command --test 2>/dev/null || $command --test || return 1
	checkpath -m 0644 -o dnsmasq:dnsmasq -f /var/lib/misc/dnsmasq.leases
}

reload() {
	ebegin "Reloading $RC_SVCNAME"

	start_pre || return 1
	start-stop-daemon --signal HUP --pidfile "$pidfile"
	eend $?
}

checkconfig() {
	ebegin "Checking $RC_SVCNAME configuration"

	$command --test
	eend $?
}