summaryrefslogtreecommitdiffstats
path: root/debian/knot-resolver.kresd.init
blob: b1361fd57ea550823317cf5d0ea2afcf4295ff9a (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
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
    if [ -x /lib/init/init-d-script ]; then
	set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
    else
	set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /usr/lib/knot-resolver/init-d-script
    fi
fi
### BEGIN INIT INFO
# Provides:          kresd
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Knot Resolver
# Description:       Knot Resolver
### END INIT INFO

# Author: Ondřej Surý <ondrej@debian.org>

NAME=kresd
DESC="Knot Resolver"
DAEMON=/usr/sbin/kresd
START_ARGS="--background --make-pidfile"

do_tmpfiles() {
    local tmpfile type path mode user group age argument
    tmpfile=/usr/lib/tmpfiles.d/$1.conf
    if [ -r "$tmpfile" ]; then
	if [ -x /bin/systemd-tmpfiles ]; then
	    /bin/systemd-tmpfiles --create "$tmpfile"
	else
	    while read type path mode user group age argument; do
		case "$type" in
		    d)
			mkdir -p "$path";
			chmod "$mode" "$path";
			chown "$user:$group" "$path";
			;;
		    L)
			if [ ! -e "$path" ]; then ln -s "$argument" "$path"; fi
			;;
		    \#*)
			;;
		    *)
			log_warning_msg "tmpfile.d type '$type' is not supported yet"
			;;
		esac
	    done < "$tmpfile"
	fi
    else
	log_warning_msg "tmpfiles.d file '$1' doesn't exist or is not readable"
    fi
}

do_start_prepare() {
    do_tmpfiles knot-resolver
}