aboutsummaryrefslogtreecommitdiffstats
path: root/main/nsd/nsd.initd
diff options
context:
space:
mode:
authorJakub Jirutka <jakub@jirutka.cz>2019-12-01 18:13:44 +0100
committerJakub Jirutka <jakub@jirutka.cz>2019-12-01 18:17:12 +0100
commit76c25930120acf72b7e9ff32dd69cf4736075aa2 (patch)
tree9161b2e1c77630615ead6f88de7635788f39257b /main/nsd/nsd.initd
parenta63cdbe663916777f0e31641823a2fae7ae559f5 (diff)
main/nsd: improve init script
Diffstat (limited to 'main/nsd/nsd.initd')
-rw-r--r--main/nsd/nsd.initd54
1 files changed, 42 insertions, 12 deletions
diff --git a/main/nsd/nsd.initd b/main/nsd/nsd.initd
index 9eab2852388..c869b102005 100644
--- a/main/nsd/nsd.initd
+++ b/main/nsd/nsd.initd
@@ -1,12 +1,23 @@
#!/sbin/openrc-run
-description="NSD is an authoritative-only, high performance, open source name server"
-checkconf=/usr/sbin/nsd-checkconf
-cfgfile=${NSD_CONFIG:-/etc/nsd/nsd.conf}
-pidfile=$($checkconf -o pidfile $cfgfile)
-pidfile=${pidfile:-/var/run/nsd/nsd.pid}
-command=/usr/sbin/nsd
-command_args=""
+name="NSD"
+
+extra_commands="checkconfig"
+extra_started_commands="reload reopen"
+
+description="An authoritative-only, high performance, open source name server"
+description_checkconfig="Checks NSD configuration file for errors"
+description_reload="Reloads NSD config file and modified zone files from disk"
+description_reopen="Reopen NSD log file (for logrotate)"
+
+: ${cfgfile:=${NSD_CONFIG:-"/etc/nsd/nsd.conf"}} # NSD_CONFIG is for backward compatibility
+
+command="/usr/sbin/nsd"
+command_args="-c $cfgfile -d -P '' ${command_args:-}"
+command_background="yes"
+pidfile="/run/$RC_SVCNAME.pid"
+start_stop_daemon_args="--wait 50"
+
required_files="$cfgfile"
depend() {
@@ -15,10 +26,29 @@ depend() {
}
start_pre() {
- ebegin
- checkpath --directory --owner nsd:nsd ${pidfile%/*}
- $checkconf $cfgfile
- [ "$cfgfile" = "/etc/nsd/nsd.conf" ] || command_args="$command_args -c $cfgfile"
- [ "$pidfile" = "/var/run/nsd/nsd.pid" ] || command_args="$command_args -P $pidfile"
+ checkconfig || return 1
+
+ local i; for i in $(/usr/sbin/nsd-checkconf -o control-interface "$cfgfile"); do
+ case "$i" in
+ */*) test -d "$i" || checkpath -d -m 750 -o nsd:nsd "$(dirname "$i")" || return 1
+ esac
+ done
+}
+
+checkconfig() {
+ ebegin "Checking $name config file"
+ /usr/sbin/nsd-checkconf "$cfgfile"
+ eend $?
+}
+
+reload() {
+ ebegin "Reloading $name config file and all zones"
+ /usr/sbin/nsd-control reconfig && /usr/sbin/nsd-control reload
+ eend $?
+}
+
+reopen() {
+ ebegin "Reopening $name log file"
+ /usr/sbin/nsd-control log_reopen
eend $?
}