]> granicus.if.org Git - pdns/commitdiff
Generate and install virtual hosting unit file
authorPieter Lexis <pieter.lexis@powerdns.com>
Thu, 26 May 2016 11:07:38 +0000 (13:07 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Fri, 27 May 2016 09:10:39 +0000 (11:10 +0200)
Idea and some changes taken from @ekohl, thanks!

Closes: #2563
build-scripts/build-auth-debian
build-scripts/build-auth-rpm
build-scripts/debian-authoritative/pdns-server.install
docs/markdown/authoritative/running.md
pdns/.gitignore
pdns/Makefile.am

index 251d8bba23e1c0d311c9310d00e8aa757e8739df..e9448df2bb2bc04659bc6a3bf0d23f6a74b156cd 100755 (executable)
@@ -44,7 +44,7 @@ export ID="${ID}"
 export VERSION_ID="${VERSION_ID}"
 
 if [ ${ID} = "ubuntu" -a ${VERSION_ID} = "14.04" ]; then
-  sed -i '/lib\/systemd\/system\/pdns\.service/d' debian/pdns-server.install
+  sed -i '/lib\/systemd\/system\/pdns@\?\.service/d' debian/pdns-server.install
 fi
 
 fakeroot debian/rules debian/control
index fa79415c87e96e8636b7d91fd6b8c6037641694f..d90dd662609f6e0bb79eec749d9954404ba62f47 100755 (executable)
@@ -502,6 +502,7 @@ exit 0
 %{_mandir}/man1/pdns-zone2ldap.1.gz
 %{_mandir}/man1/pdnsutil.1.gz
 %{_unitdir}/pdns.service
+%{_unitdir}/pdns@.service
 %dir %{_libdir}/%{name}/
 %{_libdir}/%{name}/librandombackend.so
 %dir %{_sysconfdir}/%{name}/
@@ -761,6 +762,7 @@ exit 0
 %{_mandir}/man1/pdns-zone2ldap.1.gz
 %{_mandir}/man1/pdnsutil.1.gz
 %{_unitdir}/pdns.service
+%{_unitdir}/pdns@.service
 %dir %{_libdir}/%{name}/
 %{_libdir}/%{name}/librandombackend.so
 %dir %{_sysconfdir}/%{name}/
index 79ea031e21f430d6a37eb32af921e27831a75c6d..084d23a8f9aa7a6b755663b2246ca94d2e42d7bb 100644 (file)
@@ -10,3 +10,4 @@ debian/config/pdns.simplebind.conf usr/share/pdns-server/
 debian/resolvconf/pdns etc/resolvconf/update.d/
 debian/insserv.d/pdns-server etc/insserv.d/
 lib/systemd/system/pdns.service
+lib/systemd/system/pdns@.service
index 33f764ad589b2857622487db9af0b7e256cff8a9..d3bae4769f0622a873162ca82dcb74eb358488f6 100644 (file)
@@ -98,13 +98,17 @@ It may be advantageous to run multiple separate PowerDNS installations on a
 single host, for example to make sure that different customers cannot affect
 each others zones. PowerDNS fully supports running multiple instances on one host.
 
-To generate additional PowerDNS instances, copy the init.d script `pdns` to
-`pdns-name`, where `name` is the name of your virtual configuration. Must not
-contain a - as this will confuse the script.
+To generate additional PowerDNS instances, create a `pdns-NAME.conf` in your
+configuration directory (usually `/etc/powerdns`), where `NAME` is the name of
+your virtual configuration.
 
-When you launch PowerDNS via this renamed script, it will seek configuration
-instructions not in `pdns.conf` but in `pdns-name.conf`, allowing for separate
-specification of parameters.
+Following one of the following instructions, PowerDNS will read its configuration
+from the `pdns-NAME.conf` instead of `pdns.conf`.
+
+## Starting virtual instances with Sysv init-scripts
+Symlink the init.d script `pdns` to `pdns-NAME`, where `NAME` is the name of your
+virtual configuration. **Note**: `NAME` must not contain a '-' as this will
+confuse the script.
 
 Internally, the init script calls the binary with the
 [`config-name`](settings.md#config-name) option set to `name`, setting in motion
@@ -116,7 +120,18 @@ When you launch a virtual instance of PowerDNS, the pid-file is saved inside
 **Warning**: Be aware however that the init.d `force-stop` will kill all
 PowerDNS instances!
 
-**Warning**: For systems running systemd, virtual hosting is not yet supported.
+## Starting virtual instances with systemd
+With systemd it is as simple as calling the correct service instance. Assuming your
+instance is called `myinstance` and `pdns-myinstance.conf` exists in the configuration
+directory, the following command will start the service:
+```
+systemctl start pdns@myinstance.service
+```
+
+Similarly you can enable it at boot:
+```
+systemctl enable pdns@myinstance.service
+```
 
 # Internals
 ## How PowerDNS translates DNS queries into backend queries
index 7ab50604503597863ac387390b7dbd1f7e3645ca..2f5bc3fa639f5c63bb355151780ba408b4fca6ba 100644 (file)
@@ -58,5 +58,6 @@ effective_tld_names.dat
 /dnsmessage.pb.cc
 /dnsmessage.pb.h
 /pdns.service
+/pdns@.service
 /pdns.conf-dist
 /stubquery
index 4742c0b1a7d80d3aa82869a853358a158207dd06..7332a7c80f28efed14356366e8e2a188443eb55a 100644 (file)
@@ -1213,8 +1213,14 @@ if HAVE_SYSTEMD
 pdns.service: pdns.service.in
        $(AM_V_GEN)sed -e 's![@]sbindir[@]!$(sbindir)!' < $< > $@
 
+pdns@.service: pdns.service
+       $(AM_V_GEN)sed -e 's!/pdns_server!& --config-name=%i!' \
+         -e 's!Authoritative Server!& %i!' \
+         < $< > $@
+
 systemdsystemunitdir = $(SYSTEMD_DIR)
 
 systemdsystemunit_DATA = \
-       pdns.service
+       pdns.service \
+       pdns@.service
 endif