Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Benoît Thébaudeau" <benoit@wsystem.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH v3 13/13] package/dhcp: systemd: add dhcrelay service file
Date: Wed, 4 Nov 2015 14:35:35 +0100	[thread overview]
Message-ID: <563A09A7.10002@wsystem.com> (raw)
In-Reply-To: <CAGduivzruYhUvjMdxw12EB+FaemiJX3p=zsfUra-Ma4dbkEC8g@mail.gmail.com>

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 at 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 at 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

  reply	other threads:[~2015-11-04 13:35 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-25  0:59 [Buildroot] [PATCH v3 01/13] package/dhcp: fix SysV init scripts option passing Benoît Thébaudeau
2015-10-25  0:59 ` [Buildroot] [PATCH v3 02/13] package/dhcp: systemd: rename environment file Benoît Thébaudeau
2015-11-04  9:52   ` Maxime Hadjinlian
2015-11-04  9:54     ` Maxime Hadjinlian
2015-11-04 10:01       ` Benoît Thébaudeau
2015-11-04 10:04         ` Maxime Hadjinlian
2015-11-04 10:07           ` Benoît Thébaudeau
2015-11-04 10:13             ` Maxime Hadjinlian
2015-11-04 10:18     ` Thomas Petazzoni
2015-11-04 10:24       ` Benoît Thébaudeau
2015-11-04 10:25       ` Maxime Hadjinlian
2015-11-04 18:42       ` Gabe Evans
2015-12-24 14:00   ` Thomas Petazzoni
2015-10-25  0:59 ` [Buildroot] [PATCH v3 03/13] package/dhcp/S80dhcp-server: support extra options Benoît Thébaudeau
2015-12-24 14:00   ` Thomas Petazzoni
2015-10-25  0:59 ` [Buildroot] [PATCH v3 04/13] package/dhcp: systemd: " Benoît Thébaudeau
2015-11-04 10:09   ` Maxime Hadjinlian
2015-12-24 14:01   ` Thomas Petazzoni
2015-10-25  0:59 ` [Buildroot] [PATCH v3 05/13] package/dhcp/S80dhcp-server: allow empty INTERFACES Benoît Thébaudeau
2015-12-24 14:02   ` Thomas Petazzoni
2015-10-25  0:59 ` [Buildroot] [PATCH v3 06/13] package/dhcp: systemd: allow missing environment file Benoît Thébaudeau
2015-11-04 10:14   ` Maxime Hadjinlian
2015-12-24 14:03   ` Thomas Petazzoni
2015-10-25  0:59 ` [Buildroot] [PATCH v3 07/13] package/dhcp: fix SysV init scripts output text Benoît Thébaudeau
2015-12-24 14:05   ` Thomas Petazzoni
2015-10-25  0:59 ` [Buildroot] [PATCH v3 08/13] package/dhcp: remove sleep from SysV init scripts restart Benoît Thébaudeau
2015-12-24 14:06   ` Thomas Petazzoni
2015-10-25  0:59 ` [Buildroot] [PATCH v3 09/13] package/dhcp: SysV init scripts: remove PID files after stop Benoît Thébaudeau
2015-12-24 14:26   ` Thomas Petazzoni
2016-01-07 20:40     ` Benoît Thébaudeau
2015-10-25  0:59 ` [Buildroot] [PATCH v3 10/13] package/dhcp/S80dhcp-server: support IPv6 lease file Benoît Thébaudeau
2015-10-25  0:59 ` [Buildroot] [PATCH v3 11/13] package/dhcp: systemd: " Benoît Thébaudeau
2015-11-04 10:21   ` Maxime Hadjinlian
2015-11-04 10:36     ` Benoît Thébaudeau
2015-11-04 10:53       ` Maxime Hadjinlian
2015-11-04 11:15         ` Benoît Thébaudeau
2015-11-04 11:31           ` Maxime Hadjinlian
2015-11-09 10:49             ` Benoît Thébaudeau
2015-11-12 10:42               ` Maxime Hadjinlian
2015-11-15 17:55                 ` Benoît Thébaudeau
2015-10-25  0:59 ` [Buildroot] [PATCH v3 12/13] package/dhcp: SysV init scripts: refactor using functions Benoît Thébaudeau
2015-10-25  0:59 ` [Buildroot] [PATCH v3 13/13] package/dhcp: systemd: add dhcrelay service file Benoît Thébaudeau
2015-11-04 11:24   ` Maxime Hadjinlian
2015-11-04 13:35     ` Benoît Thébaudeau [this message]
2015-11-04 21:26       ` Arnout Vandecappelle
2015-11-15 17:36       ` Benoît Thébaudeau
2015-12-24 13:59 ` [Buildroot] [PATCH v3 01/13] package/dhcp: fix SysV init scripts option passing Thomas Petazzoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=563A09A7.10002@wsystem.com \
    --to=benoit@wsystem.com \
    --cc=buildroot@busybox.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox