diff options
| author | Jakub Jirutka <jakub@jirutka.cz> | 2019-12-01 18:13:44 +0100 |
|---|---|---|
| committer | Jakub Jirutka <jakub@jirutka.cz> | 2019-12-01 18:17:12 +0100 |
| commit | 76c25930120acf72b7e9ff32dd69cf4736075aa2 (patch) | |
| tree | 9161b2e1c77630615ead6f88de7635788f39257b | |
| parent | a63cdbe663916777f0e31641823a2fae7ae559f5 (diff) | |
| download | aports-76c25930120acf72b7e9ff32dd69cf4736075aa2.tar.bz2 aports-76c25930120acf72b7e9ff32dd69cf4736075aa2.tar.xz | |
main/nsd: improve init script
| -rw-r--r-- | main/nsd/APKBUILD | 8 | ||||
| -rw-r--r-- | main/nsd/config.patch | 28 | ||||
| -rw-r--r-- | main/nsd/nsd.initd | 54 |
3 files changed, 75 insertions, 15 deletions
diff --git a/main/nsd/APKBUILD b/main/nsd/APKBUILD index 9a24fc9e9a..4fda110a54 100644 --- a/main/nsd/APKBUILD +++ b/main/nsd/APKBUILD @@ -5,7 +5,7 @@ # Maintainer: Natanael Copa <ncopa@alpinelinux.org> pkgname=nsd pkgver=4.2.3 -pkgrel=0 +pkgrel=1 pkgdesc="Authoritative only, high performance and simple DNS server" url="https://www.nlnetlabs.nl/projects/nsd" arch="all" @@ -17,6 +17,7 @@ pkgusers="nsd" pkggroups="nsd" source="https://www.nlnetlabs.nl/downloads/nsd/nsd-$pkgver.tar.gz nsd.initd + config.patch " build() { @@ -27,7 +28,7 @@ build() { --sbindir=/usr/sbin \ --mandir=/usr/share/man \ --with-user=nsd \ - --with-pidfile=/var/run/nsd/nsd.pid \ + --with-pidfile=/run/nsd/nsd.pid \ --with-xfrdir=/var/db/nsd make } @@ -48,4 +49,5 @@ package() { } sha512sums="08349375caf96d870a7ba6e8de6342794f4bba356ef75d46f3c3f50462d356317f3e82a252febda21e2fbfe36bf7ad0c53f40079779faf204a4aaebd41fdc965 nsd-4.2.3.tar.gz -0425f606bf102175adab6d198aeb692872576f9c0bfce11b9d9e4145595b4902e5ef3fe2c3ae5d832308f43282618494b8dd27eb76658e79df85cc7798008722 nsd.initd" +6e030a7cecf0545bf4ca12ecad984a60b571daa1592c01eea4bdd17e04d96373933d28a3c59f31676304714ed2b9148b9b004e67ba316f207ff87d105168d2d2 nsd.initd +524adb9f35602555492b041e68154452d11f4411ddd796244ff4c24c7922c1b8dc56e5cb2bc2681baa26448e8e0349f9a72858495f7bfbd6d9871c58cca0fe18 config.patch" diff --git a/main/nsd/config.patch b/main/nsd/config.patch new file mode 100644 index 0000000000..52749a50b0 --- /dev/null +++ b/main/nsd/config.patch @@ -0,0 +1,28 @@ +--- a/nsd.conf.sample.in ++++ b/nsd.conf.sample.in +@@ -79,9 +79,6 @@ + # facility LOG_DAEMON). stderr disappears when daemon goes to bg. + # logfile: "@logfile@" + +- # File to store pid for nsd in. +- # pidfile: "@pidfile@" +- + # The file where secondary zone refresh and expire timeouts are kept. + # If you delete this file, all secondary zones are forced to be + # 'refreshing' (as if nsd got a notify). Set to "" to disable. +@@ -222,11 +219,14 @@ + remote-control: + # Enable remote control with nsd-control(8) here. + # set up the keys and certificates with nsd-control-setup. +- # control-enable: no ++ # (This needs to be enabled to use init script's commands reload and ++ # reopen) ++ control-enable: yes + + # what interfaces are listened to for control, default is on localhost. + # with an absolute path, a unix local named pipe is used for control + # (and key and cert files are not needed, use directory permissions). ++ control-interface: /run/nsd/control.sock + # control-interface: 127.0.0.1 + # control-interface: ::1 + diff --git a/main/nsd/nsd.initd b/main/nsd/nsd.initd index 9eab285238..c869b10200 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 $? } |
