Message ID | 1445734779-7212-13-git-send-email-benoit.thebaudeau.dev@gmail.com |
---|---|
State | Changes Requested |
Headers | show |
Hi Benoit, all On Sun, Oct 25, 2015 at 2:59 AM, Benoît Thébaudeau < benoit.thebaudeau.dev@gmail.com> wrote: > Add a systemd service file to start dhcrelay. > > The network interfaces to listen on must be set via the variable IFCMD > in /etc/default/dhcrelay, e.g.: > > IFCMD="-i eth0 -i eth1" > > The "upstream" servers to pass the queries along to must be set via the > variable SERVERS in the same file, e.g.: > > SERVERS="server0 server1" > > Extra command line options can be set via the variable OPTIONS in the > same file. > > Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com> > > --- > Changes v2 -> v3: new patch. > --- > package/dhcp/dhcp.mk | 45 > ++++++++++++++++++++++++++++--------------- > package/dhcp/dhcrelay.service | 13 +++++++++++++ > 2 files changed, 42 insertions(+), 16 deletions(-) > create mode 100644 package/dhcp/dhcrelay.service > > diff --git a/package/dhcp/dhcp.mk b/package/dhcp/dhcp.mk > index 3aa1577..4ba302b 100644 > --- a/package/dhcp/dhcp.mk > +++ b/package/dhcp/dhcp.mk > @@ -37,6 +37,23 @@ define DHCP_INSTALL_SERVER > $(INSTALL) -m 0644 -D package/dhcp/dhcpd.conf \ > $(TARGET_DIR)/etc/dhcp/dhcpd.conf > endef > + > +define DHCP_INSTALL_SERVER_INIT_SYSTEMD > + $(INSTALL) -D -m 644 package/dhcp/dhcpd.service \ > + $(TARGET_DIR)/usr/lib/systemd/system/dhcpd.service > + > + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants > + > + ln -sf ../../../../usr/lib/systemd/system/dhcpd.service \ > + > $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcpd.service > + > + echo "d /var/lib/dhcp 0755 - - - -" > \ > + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf > + echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ > + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf > + echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ > + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf > +endef > endif > > ifeq ($(BR2_PACKAGE_DHCP_RELAY),y) > @@ -46,6 +63,16 @@ define DHCP_INSTALL_RELAY > $(INSTALL) -m 0755 -D $(DHCP_DIR)/relay/dhcrelay \ > $(TARGET_DIR)/usr/sbin/dhcrelay > endef > + > +define DHCP_INSTALL_RELAY_INIT_SYSTEMD > + $(INSTALL) -D -m 644 package/dhcp/dhcrelay.service \ > + $(TARGET_DIR)/usr/lib/systemd/system/dhcrelay.service > + > + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants > + > + ln -sf ../../../../usr/lib/systemd/system/dhcrelay.service \ > + > $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcrelay.service > +endef > endif > > ifeq ($(BR2_PACKAGE_DHCP_CLIENT),y) > @@ -69,24 +96,10 @@ define DHCP_INSTALL_INIT_SYSV > $(TARGET_DIR)/etc/init.d/S80dhcp-relay > endef > > -ifeq ($(BR2_PACKAGE_DHCP_SERVER),y) > define DHCP_INSTALL_INIT_SYSTEMD > - $(INSTALL) -D -m 644 package/dhcp/dhcpd.service \ > - $(TARGET_DIR)/usr/lib/systemd/system/dhcpd.service > - > - mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants > - > - ln -sf ../../../../usr/lib/systemd/system/dhcpd.service \ > - > $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcpd.service > - > - echo "d /var/lib/dhcp 0755 - - - -" > \ > - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf > - echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ > - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf > - echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ > - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf > + $(DHCP_INSTALL_SERVER_INIT_SYSTEMD) > + $(DHCP_INSTALL_RELAY_INIT_SYSTEMD) > endef > -endif > > define DHCP_INSTALL_TARGET_CMDS > $(DHCP_INSTALL_RELAY) > diff --git a/package/dhcp/dhcrelay.service b/package/dhcp/dhcrelay.service > new file mode 100644 > index 0000000..5a1410e > --- /dev/null > +++ b/package/dhcp/dhcrelay.service > @@ -0,0 +1,13 @@ > +[Unit] > +Description=DHCP relay > +After=network.target > + > +[Service] > +Type=forking > +PIDFile=/run/dhcrelay.pid > +ExecStart=/usr/sbin/dhcrelay -q -pf /run/dhcrelay.pid $OPTIONS $IFCMD > $SERVERS > Why don't we want /var/run/dhcrelay.pid which is the default ? > +KillSignal=SIGINT > I did not try to run it, but it doesn't react to SIGTERM ? I did not see anything in the code to prevent it but I only looked at it pretty quickly. > +EnvironmentFile=/etc/default/dhcrelay > Should be 'EnvironmentFile=-/etc/default/dhcrelay' > + > +[Install] > +WantedBy=multi-user.target > -- > 2.1.4 > >
Hi Maxime, all, On 04/11/2015 12:24, Maxime Hadjinlian wrote: > On Sun, Oct 25, 2015 at 2:59 AM, Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com <mailto:benoit.thebaudeau.dev@gmail.com>> wrote: > > Add a systemd service file to start dhcrelay. > > The network interfaces to listen on must be set via the variable IFCMD > in /etc/default/dhcrelay, e.g.: > > IFCMD="-i eth0 -i eth1" > > The "upstream" servers to pass the queries along to must be set via the > variable SERVERS in the same file, e.g.: > > SERVERS="server0 server1" > > Extra command line options can be set via the variable OPTIONS in the > same file. > > Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com <mailto:benoit.thebaudeau.dev@gmail.com>> > > --- > Changes v2 -> v3: new patch. > --- > package/dhcp/dhcp.mk <http://dhcp.mk> | 45 ++++++++++++++++++++++++++++--------------- > package/dhcp/dhcrelay.service | 13 +++++++++++++ > 2 files changed, 42 insertions(+), 16 deletions(-) > create mode 100644 package/dhcp/dhcrelay.service > > diff --git a/package/dhcp/dhcp.mk <http://dhcp.mk> b/package/dhcp/dhcp.mk <http://dhcp.mk> > index 3aa1577..4ba302b 100644 > --- a/package/dhcp/dhcp.mk <http://dhcp.mk> > +++ b/package/dhcp/dhcp.mk <http://dhcp.mk> > @@ -37,6 +37,23 @@ define DHCP_INSTALL_SERVER > $(INSTALL) -m 0644 -D package/dhcp/dhcpd.conf \ > $(TARGET_DIR)/etc/dhcp/dhcpd.conf > endef > + > +define DHCP_INSTALL_SERVER_INIT_SYSTEMD > + $(INSTALL) -D -m 644 package/dhcp/dhcpd.service \ > + $(TARGET_DIR)/usr/lib/systemd/system/dhcpd.service > + > + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants > + > + ln -sf ../../../../usr/lib/systemd/system/dhcpd.service \ > + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcpd.service > + > + echo "d /var/lib/dhcp 0755 - - - -" > \ > + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf > + echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ > + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf > + echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ > + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf > +endef > endif > > ifeq ($(BR2_PACKAGE_DHCP_RELAY),y) > @@ -46,6 +63,16 @@ define DHCP_INSTALL_RELAY > $(INSTALL) -m 0755 -D $(DHCP_DIR)/relay/dhcrelay \ > $(TARGET_DIR)/usr/sbin/dhcrelay > endef > + > +define DHCP_INSTALL_RELAY_INIT_SYSTEMD > + $(INSTALL) -D -m 644 package/dhcp/dhcrelay.service \ > + $(TARGET_DIR)/usr/lib/systemd/system/dhcrelay.service > + > + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants > + > + ln -sf ../../../../usr/lib/systemd/system/dhcrelay.service \ > + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcrelay.service > +endef > endif > > ifeq ($(BR2_PACKAGE_DHCP_CLIENT),y) > @@ -69,24 +96,10 @@ define DHCP_INSTALL_INIT_SYSV > $(TARGET_DIR)/etc/init.d/S80dhcp-relay > endef > > -ifeq ($(BR2_PACKAGE_DHCP_SERVER),y) > define DHCP_INSTALL_INIT_SYSTEMD > - $(INSTALL) -D -m 644 package/dhcp/dhcpd.service \ > - $(TARGET_DIR)/usr/lib/systemd/system/dhcpd.service > - > - mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants > - > - ln -sf ../../../../usr/lib/systemd/system/dhcpd.service \ > - $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcpd.service > - > - echo "d /var/lib/dhcp 0755 - - - -" > \ > - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf > - echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ > - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf > - echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ > - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf > + $(DHCP_INSTALL_SERVER_INIT_SYSTEMD) > + $(DHCP_INSTALL_RELAY_INIT_SYSTEMD) > endef > -endif > > define DHCP_INSTALL_TARGET_CMDS > $(DHCP_INSTALL_RELAY) > diff --git a/package/dhcp/dhcrelay.service b/package/dhcp/dhcrelay.service > new file mode 100644 > index 0000000..5a1410e > --- /dev/null > +++ b/package/dhcp/dhcrelay.service > @@ -0,0 +1,13 @@ > +[Unit] > +Description=DHCP relay > +After=network.target > + > +[Service] > +Type=forking > +PIDFile=/run/dhcrelay.pid > +ExecStart=/usr/sbin/dhcrelay -q -pf /run/dhcrelay.pid $OPTIONS $IFCMD $SERVERS > > Why don't we want /var/run/dhcrelay.pid which is the default ? I did that to be consistent with what had been done for dhcpd.service. /run is the new norm, but Buildroot configures the dhcp package to use /var/run as the default, and the SysV init scripts stick to that. I don't know Buildroot's rules about that if any. Maybe dhcp.mk should just be updated to use /run. Thomas? > +KillSignal=SIGINT > > I did not try to run it, but it doesn't react to SIGTERM ? I did not see anything in the code to prevent it but I only looked at it pretty quickly. It's also from dhcpd.service. I've searched around and I've not found a good reason for it, but there must be one. I'll try and dig more. > +EnvironmentFile=/etc/default/dhcrelay > > Should be 'EnvironmentFile=-/etc/default/dhcrelay' This is on purpose. This file is required because IFCMD and SERVERS are required too. > + > +[Install] > +WantedBy=multi-user.target > -- > 2.1.4 Best regards, Benoît
On 04-11-15 14:35, Benoît Thébaudeau wrote: > Hi Maxime, all, > > On 04/11/2015 12:24, Maxime Hadjinlian wrote: >> On Sun, Oct 25, 2015 at 2:59 AM, Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com <mailto:benoit.thebaudeau.dev@gmail.com>> wrote: [snip] >> +ExecStart=/usr/sbin/dhcrelay -q -pf /run/dhcrelay.pid $OPTIONS $IFCMD $SERVERS >> >> Why don't we want /var/run/dhcrelay.pid which is the default ? > > I did that to be consistent with what had been done for dhcpd.service. > > /run is the new norm, but Buildroot configures the dhcp package to use /var/run > as the default, and the SysV init scripts stick to that. > > I don't know Buildroot's rules about that if any. Maybe dhcp.mk should just be > updated to use /run. Thomas? Since /var/run is currently a symlink to /run, it would be good to update dhcp.mk as you propose. Or perhaps even remove those configures since I think they're the default anyway. Regards, Arnout > >> +KillSignal=SIGINT >> >> I did not try to run it, but it doesn't react to SIGTERM ? I did not see anything in the code to prevent it but I only looked at it pretty quickly. > > It's also from dhcpd.service. I've searched around and I've not found a good > reason for it, but there must be one. I'll try and dig more. > >> +EnvironmentFile=/etc/default/dhcrelay >> >> Should be 'EnvironmentFile=-/etc/default/dhcrelay' > > This is on purpose. This file is required because IFCMD and SERVERS are required > too. > >> + >> +[Install] >> +WantedBy=multi-user.target >> -- >> 2.1.4 > > Best regards, > Benoît > > _______________________________________________ > buildroot mailing list > buildroot@busybox.net > http://lists.busybox.net/mailman/listinfo/buildroot >
Hi Maxime, all, On Wed, Nov 4, 2015 at 2:35 PM, Benoît Thébaudeau <benoit@wsystem.com> wrote: > On 04/11/2015 12:24, Maxime Hadjinlian wrote: >> On Sun, Oct 25, 2015 at 2:59 AM, Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com <mailto:benoit.thebaudeau.dev@gmail.com>> wrote: [...] >> diff --git a/package/dhcp/dhcrelay.service b/package/dhcp/dhcrelay.service >> new file mode 100644 >> index 0000000..5a1410e >> --- /dev/null >> +++ b/package/dhcp/dhcrelay.service >> @@ -0,0 +1,13 @@ >> +[Unit] >> +Description=DHCP relay >> +After=network.target >> + >> +[Service] >> +Type=forking >> +PIDFile=/run/dhcrelay.pid >> +ExecStart=/usr/sbin/dhcrelay -q -pf /run/dhcrelay.pid $OPTIONS $IFCMD $SERVERS [...] >> +KillSignal=SIGINT >> >> I did not try to run it, but it doesn't react to SIGTERM ? I did not see anything in the code to prevent it but I only looked at it pretty quickly. > > It's also from dhcpd.service. I've searched around and I've not found a good > reason for it, but there must be one. I'll try and dig more. There is a reference to it in this very old thread: http://www.gossamer-threads.com/lists/gentoo/dev/31150 Here too: https://kb.isc.org/article/AA-01043/0/Recommendations-for-restarting-a-DHCP-failover-pair.html But this has been implemented in 4.2.0 according to: https://kb.isc.org/article/AA-01297 But includes/site.h advises against using this feature. This SIGINT seems to have been copied from Arch Linux for dhcpd.service. This originates from the following commit, which wants to make a difference between reload and stop, but without giving any reason: https://projects.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/dhcp&id=f60fc1997126ce5f104335d8f09a317300ce8323 Then this commit removed the reload thing: https://projects.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/dhcp&id=4d45b1bb254995199386eb2c1c8ab703c738d9d6 Looking at the sources, neither 4.1-ESV-R12 nor 4.3.3 seem to make any difference between SIGTERM and SIGINT. Also, contrary to Arch Linux, Ubuntu does not use SIGINT at all for dhcpd or dhcrelay, and it's not because of something in its patches. So I would be in favor of not using SIGINT in Buildroot too. >> +EnvironmentFile=/etc/default/dhcrelay [...] >> + >> +[Install] >> +WantedBy=multi-user.target [...] Best regards, Benoît
diff --git a/package/dhcp/dhcp.mk b/package/dhcp/dhcp.mk index 3aa1577..4ba302b 100644 --- a/package/dhcp/dhcp.mk +++ b/package/dhcp/dhcp.mk @@ -37,6 +37,23 @@ define DHCP_INSTALL_SERVER $(INSTALL) -m 0644 -D package/dhcp/dhcpd.conf \ $(TARGET_DIR)/etc/dhcp/dhcpd.conf endef + +define DHCP_INSTALL_SERVER_INIT_SYSTEMD + $(INSTALL) -D -m 644 package/dhcp/dhcpd.service \ + $(TARGET_DIR)/usr/lib/systemd/system/dhcpd.service + + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + + ln -sf ../../../../usr/lib/systemd/system/dhcpd.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcpd.service + + echo "d /var/lib/dhcp 0755 - - - -" > \ + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf + echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf + echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ + $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf +endef endif ifeq ($(BR2_PACKAGE_DHCP_RELAY),y) @@ -46,6 +63,16 @@ define DHCP_INSTALL_RELAY $(INSTALL) -m 0755 -D $(DHCP_DIR)/relay/dhcrelay \ $(TARGET_DIR)/usr/sbin/dhcrelay endef + +define DHCP_INSTALL_RELAY_INIT_SYSTEMD + $(INSTALL) -D -m 644 package/dhcp/dhcrelay.service \ + $(TARGET_DIR)/usr/lib/systemd/system/dhcrelay.service + + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + + ln -sf ../../../../usr/lib/systemd/system/dhcrelay.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcrelay.service +endef endif ifeq ($(BR2_PACKAGE_DHCP_CLIENT),y) @@ -69,24 +96,10 @@ define DHCP_INSTALL_INIT_SYSV $(TARGET_DIR)/etc/init.d/S80dhcp-relay endef -ifeq ($(BR2_PACKAGE_DHCP_SERVER),y) define DHCP_INSTALL_INIT_SYSTEMD - $(INSTALL) -D -m 644 package/dhcp/dhcpd.service \ - $(TARGET_DIR)/usr/lib/systemd/system/dhcpd.service - - mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants - - ln -sf ../../../../usr/lib/systemd/system/dhcpd.service \ - $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/dhcpd.service - - echo "d /var/lib/dhcp 0755 - - - -" > \ - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf - echo "f /var/lib/dhcp/dhcpd.leases - - - - -" >> \ - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf - echo "f /var/lib/dhcp/dhcpd6.leases - - - - -" >> \ - $(TARGET_DIR)/usr/lib/tmpfiles.d/dhcpd.conf + $(DHCP_INSTALL_SERVER_INIT_SYSTEMD) + $(DHCP_INSTALL_RELAY_INIT_SYSTEMD) endef -endif define DHCP_INSTALL_TARGET_CMDS $(DHCP_INSTALL_RELAY) diff --git a/package/dhcp/dhcrelay.service b/package/dhcp/dhcrelay.service new file mode 100644 index 0000000..5a1410e --- /dev/null +++ b/package/dhcp/dhcrelay.service @@ -0,0 +1,13 @@ +[Unit] +Description=DHCP relay +After=network.target + +[Service] +Type=forking +PIDFile=/run/dhcrelay.pid +ExecStart=/usr/sbin/dhcrelay -q -pf /run/dhcrelay.pid $OPTIONS $IFCMD $SERVERS +KillSignal=SIGINT +EnvironmentFile=/etc/default/dhcrelay + +[Install] +WantedBy=multi-user.target
Add a systemd service file to start dhcrelay. The network interfaces to listen on must be set via the variable IFCMD in /etc/default/dhcrelay, e.g.: IFCMD="-i eth0 -i eth1" The "upstream" servers to pass the queries along to must be set via the variable SERVERS in the same file, e.g.: SERVERS="server0 server1" Extra command line options can be set via the variable OPTIONS in the same file. Signed-off-by: Benoît Thébaudeau <benoit.thebaudeau.dev@gmail.com> --- Changes v2 -> v3: new patch. --- package/dhcp/dhcp.mk | 45 ++++++++++++++++++++++++++++--------------- package/dhcp/dhcrelay.service | 13 +++++++++++++ 2 files changed, 42 insertions(+), 16 deletions(-) create mode 100644 package/dhcp/dhcrelay.service