All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH] dhcp: add systemd service file
@ 2014-09-15 21:04 Eric Le Bihan
  2014-09-21 20:44 ` Yann E. MORIN
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Eric Le Bihan @ 2014-09-15 21:04 UTC (permalink / raw)
  To: buildroot

Add a systemd service file to start dhcpd.

The network interfaces to listen on can be set via the variable
INTERFACES in /etc/default/dhcpd.conf. Example:

  INTERFACES="eth0 eth1"

Also install a tmpfiles.d file to create /var/lib/dhcp/dhcpd.leases
(needed at dhcpd start-up).

Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
---
 package/dhcp/dhcp.mk       | 15 +++++++++++++++
 package/dhcp/dhcpd.service | 13 +++++++++++++
 2 files changed, 28 insertions(+)
 create mode 100644 package/dhcp/dhcpd.service

diff --git a/package/dhcp/dhcp.mk b/package/dhcp/dhcp.mk
index 9251185..1b914a8 100644
--- a/package/dhcp/dhcp.mk
+++ b/package/dhcp/dhcp.mk
@@ -74,6 +74,21 @@ define DHCP_INSTALL_INIT_SYSV
 		$(TARGET_DIR)/etc/init.d/S80dhcp-relay
 endef
 
+define DHCP_INSTALL_INIT_SYSTEMD
+	$(INSTALL) -D -m 644 package/dhcp/dhcpd.service \
+		$(TARGET_DIR)/lib/systemd/system/dhcpd.service
+
+	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+
+	ln -sf ../../../../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
+endef
+
 define DHCP_INSTALL_TARGET_CMDS
 	$(DHCP_INSTALL_RELAY)
 	$(DHCP_INSTALL_SERVER)
diff --git a/package/dhcp/dhcpd.service b/package/dhcp/dhcpd.service
new file mode 100644
index 0000000..7b265cb
--- /dev/null
+++ b/package/dhcp/dhcpd.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=DHCP server
+After=network.target
+
+[Service]
+Type=forking
+PIDFile=/run/dhcpd.pid
+ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $INTERFACES
+KillSignal=SIGINT
+EnvironmentFile=/etc/default/dhcpd.conf
+
+[Install]
+WantedBy=multi-user.target
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [Buildroot] [PATCH] dhcp: add systemd service file
  2014-09-15 21:04 [Buildroot] [PATCH] dhcp: add systemd service file Eric Le Bihan
@ 2014-09-21 20:44 ` Yann E. MORIN
  2014-09-22 10:52   ` Eric Le Bihan
  2014-10-26 21:13 ` Thomas Petazzoni
  2014-10-29 22:08 ` Thomas Petazzoni
  2 siblings, 1 reply; 10+ messages in thread
From: Yann E. MORIN @ 2014-09-21 20:44 UTC (permalink / raw)
  To: buildroot

Eric, All,

On 2014-09-15 23:04 +0200, Eric Le Bihan spake thusly:
> Add a systemd service file to start dhcpd.
> 
> The network interfaces to listen on can be set via the variable
> INTERFACES in /etc/default/dhcpd.conf. Example:
> 
>   INTERFACES="eth0 eth1"
> 
> Also install a tmpfiles.d file to create /var/lib/dhcp/dhcpd.leases
> (needed at dhcpd start-up).
> 
> Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
> ---
>  package/dhcp/dhcp.mk       | 15 +++++++++++++++
>  package/dhcp/dhcpd.service | 13 +++++++++++++
>  2 files changed, 28 insertions(+)
>  create mode 100644 package/dhcp/dhcpd.service
> 
> diff --git a/package/dhcp/dhcp.mk b/package/dhcp/dhcp.mk
> index 9251185..1b914a8 100644
> --- a/package/dhcp/dhcp.mk
> +++ b/package/dhcp/dhcp.mk
> @@ -74,6 +74,21 @@ define DHCP_INSTALL_INIT_SYSV
>  		$(TARGET_DIR)/etc/init.d/S80dhcp-relay
>  endef
>  
> +define DHCP_INSTALL_INIT_SYSTEMD
> +	$(INSTALL) -D -m 644 package/dhcp/dhcpd.service \
> +		$(TARGET_DIR)/lib/systemd/system/dhcpd.service
> +
> +	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
> +
> +	ln -sf ../../../../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

I'm not sure to understand those two. Are they needed on the target?

They suspiciously look like our 'makedev' syntax. Does systemd recognise
this too?

Regards,
Yann E. MORIN.

> +endef
> +
>  define DHCP_INSTALL_TARGET_CMDS
>  	$(DHCP_INSTALL_RELAY)
>  	$(DHCP_INSTALL_SERVER)
> diff --git a/package/dhcp/dhcpd.service b/package/dhcp/dhcpd.service
> new file mode 100644
> index 0000000..7b265cb
> --- /dev/null
> +++ b/package/dhcp/dhcpd.service
> @@ -0,0 +1,13 @@
> +[Unit]
> +Description=DHCP server
> +After=network.target
> +
> +[Service]
> +Type=forking
> +PIDFile=/run/dhcpd.pid
> +ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $INTERFACES
> +KillSignal=SIGINT
> +EnvironmentFile=/etc/default/dhcpd.conf
> +
> +[Install]
> +WantedBy=multi-user.target
> -- 
> 1.9.3
> 
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Buildroot] [PATCH] dhcp: add systemd service file
  2014-09-21 20:44 ` Yann E. MORIN
@ 2014-09-22 10:52   ` Eric Le Bihan
  2014-09-22 17:34     ` Yann E. MORIN
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Le Bihan @ 2014-09-22 10:52 UTC (permalink / raw)
  To: buildroot

Hi!

On Sun, Sep 21, 2014 at 10:44:45PM +0200, Yann E. MORIN wrote:
> Eric, All,
>
> On 2014-09-15 23:04 +0200, Eric Le Bihan spake thusly:
> > Add a systemd service file to start dhcpd.
> >
> > The network interfaces to listen on can be set via the variable
> > INTERFACES in /etc/default/dhcpd.conf. Example:
> >
> >   INTERFACES="eth0 eth1"
> >
> > Also install a tmpfiles.d file to create /var/lib/dhcp/dhcpd.leases
> > (needed at dhcpd start-up).
> >
> > Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
> > ---
> >  package/dhcp/dhcp.mk       | 15 +++++++++++++++
> >  package/dhcp/dhcpd.service | 13 +++++++++++++
> >  2 files changed, 28 insertions(+)
> >  create mode 100644 package/dhcp/dhcpd.service
> >
> > diff --git a/package/dhcp/dhcp.mk b/package/dhcp/dhcp.mk
> > index 9251185..1b914a8 100644
> > --- a/package/dhcp/dhcp.mk
> > +++ b/package/dhcp/dhcp.mk
> > @@ -74,6 +74,21 @@ define DHCP_INSTALL_INIT_SYSV
> >  		$(TARGET_DIR)/etc/init.d/S80dhcp-relay
> >  endef
> >
> > +define DHCP_INSTALL_INIT_SYSTEMD
> > +	$(INSTALL) -D -m 644 package/dhcp/dhcpd.service \
> > +		$(TARGET_DIR)/lib/systemd/system/dhcpd.service
> > +
> > +	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
> > +
> > +	ln -sf ../../../../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
>
> I'm not sure to understand those two. Are they needed on the target?
>
> They suspiciously look like our 'makedev' syntax. Does systemd recognise
> this too?

Among the zillion of tools provided by systemd, there is 'systemd-tmpfiles'
[1]. This program creates, deletes, and cleans up volatile and temporary
files and directories based on configuration files stored in
/usr/lib/tmpfiles.d and /etc/tmpfiles.d.

It is true that these files follow a syntax similar to makedev [2]. But unlike
'makedev' which sets the proper access rights for / entries at build time,
'systemd-tmpfiles' creates the files at runtime if they are missing.

In the current default skeleton used by Buildroot, parts of /var are
tmpfs-based and thus get cleaned at each reboot. 'systemd-tmpfiles' can
recreate them.

For some reasons, when using systemd, dhcpd complains at start-up about
/var/lib/dhcp/dhcpd.leases not being accessible. So the Makefile installs a
file named /usr/lib/tmpfiles.d/dhcp.conf, which contains "instructions" for
creating the missing file with the proper access rights.

I know that a package named 'foo' can add system users via FOO_USERS, thanks
to 'mkusers'. Can the same be done with 'makedev'? This would allow a package
to create files with the proper owner and access rights without having to
provide additional files.

Side note: since version 215, systemd provides systemd-sysusers, which creates
system users and groups in /etc/passwd and /etc/group based on the
configuration files in /usr/lib/sysusers.d/. It is said to be useful for
systems where /etc can be "reset" to a default version. I still haven't found
a useful use case for it in an embedded system, though.

[1] http://www.freedesktop.org/software/systemd/man/systemd-tmpfiles.html
[2] http://www.freedesktop.org/software/systemd/man/tmpfiles.d.html

Best regards,
ELB

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Buildroot] [PATCH] dhcp: add systemd service file
  2014-09-22 10:52   ` Eric Le Bihan
@ 2014-09-22 17:34     ` Yann E. MORIN
  2014-10-27 12:04       ` Eric Le Bihan
  0 siblings, 1 reply; 10+ messages in thread
From: Yann E. MORIN @ 2014-09-22 17:34 UTC (permalink / raw)
  To: buildroot

Eric, All,

On 2014-09-22 12:52 +0200, Eric Le Bihan spake thusly:
> On Sun, Sep 21, 2014 at 10:44:45PM +0200, Yann E. MORIN wrote:
> > On 2014-09-15 23:04 +0200, Eric Le Bihan spake thusly:
> > > Add a systemd service file to start dhcpd.
[--SNIP--]
> > > +	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
> >
> > I'm not sure to understand those two. Are they needed on the target?
> >
> > They suspiciously look like our 'makedev' syntax. Does systemd recognise
> > this too?
> 
> Among the zillion of tools provided by systemd, there is 'systemd-tmpfiles'
> [1]. This program creates, deletes, and cleans up volatile and temporary
> files and directories based on configuration files stored in
> /usr/lib/tmpfiles.d and /etc/tmpfiles.d.
> 
> It is true that these files follow a syntax similar to makedev [2]. But unlike
> 'makedev' which sets the proper access rights for / entries at build time,
> 'systemd-tmpfiles' creates the files at runtime if they are missing.
> 
> In the current default skeleton used by Buildroot, parts of /var are
> tmpfs-based and thus get cleaned at each reboot. 'systemd-tmpfiles' can
> recreate them.
> 
> For some reasons, when using systemd, dhcpd complains at start-up about
> /var/lib/dhcp/dhcpd.leases not being accessible. So the Makefile installs a
> file named /usr/lib/tmpfiles.d/dhcp.conf, which contains "instructions" for
> creating the missing file with the proper access rights.

Thanks for the thorough explanations!

> I know that a package named 'foo' can add system users via FOO_USERS, thanks
> to 'mkusers'. Can the same be done with 'makedev'?

Yes, it is possible, see:
    http://nightly.buildroot.org/#_infrastructure_for_packages_with_specific_build_systems
and:
    http://nightly.buildroot.org/#makedev-syntax

You'd need something like:

    define LIBFOO_PERMISSIONS
        /var/lib/dhcp d 0755 0 0 - - - - -
        /var/lib/dhcp/dhcpd.leases f 0600 0 0 - - - - -
    endef

> This would allow a package
> to create files with the proper owner and access rights without having to
> provide additional files.

Problem is /var/lib/dhcp/dhcpd.leases should be on a RW filesystem, and
the only one Buildroot gurantees to be RW is /tmp (which is a tmpfs).

But /var/lib does not point to a subdir in /tmp so whether we use
systemd's feature to create missing files, or the makedev above, we'd
still need to make /var/lib/dhcp a symling to somewhere in /tmp.

Regards,
Yann E. MORIN.

> Side note: since version 215, systemd provides systemd-sysusers, which creates
> system users and groups in /etc/passwd and /etc/group based on the
> configuration files in /usr/lib/sysusers.d/. It is said to be useful for
> systems where /etc can be "reset" to a default version. I still haven't found
> a useful use case for it in an embedded system, though.
> 
> [1] http://www.freedesktop.org/software/systemd/man/systemd-tmpfiles.html
> [2] http://www.freedesktop.org/software/systemd/man/tmpfiles.d.html
> 
> Best regards,
> ELB

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Buildroot] [PATCH] dhcp: add systemd service file
  2014-09-15 21:04 [Buildroot] [PATCH] dhcp: add systemd service file Eric Le Bihan
  2014-09-21 20:44 ` Yann E. MORIN
@ 2014-10-26 21:13 ` Thomas Petazzoni
  2014-10-27 17:14   ` Eric Le Bihan
  2014-10-29 22:08 ` Thomas Petazzoni
  2 siblings, 1 reply; 10+ messages in thread
From: Thomas Petazzoni @ 2014-10-26 21:13 UTC (permalink / raw)
  To: buildroot

Dear Eric Le Bihan,

On Mon, 15 Sep 2014 23:04:43 +0200, Eric Le Bihan wrote:
> Add a systemd service file to start dhcpd.
> 
> The network interfaces to listen on can be set via the variable
> INTERFACES in /etc/default/dhcpd.conf. Example:
> 
>   INTERFACES="eth0 eth1"
> 
> Also install a tmpfiles.d file to create /var/lib/dhcp/dhcpd.leases
> (needed at dhcpd start-up).
> 
> Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
> ---
>  package/dhcp/dhcp.mk       | 15 +++++++++++++++
>  package/dhcp/dhcpd.service | 13 +++++++++++++
>  2 files changed, 28 insertions(+)
>  create mode 100644 package/dhcp/dhcpd.service

What is the status of this patch? Yann made some comments, which
apparently you agreed on. Is a new version of the patch needed?

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Buildroot] [PATCH] dhcp: add systemd service file
  2014-09-22 17:34     ` Yann E. MORIN
@ 2014-10-27 12:04       ` Eric Le Bihan
  0 siblings, 0 replies; 10+ messages in thread
From: Eric Le Bihan @ 2014-10-27 12:04 UTC (permalink / raw)
  To: buildroot

On Mon, Sep 22, 2014 at 07:34:47PM +0200, Yann E. MORIN wrote:
> Eric, All,
>
> On 2014-09-22 12:52 +0200, Eric Le Bihan spake thusly:
> > On Sun, Sep 21, 2014 at 10:44:45PM +0200, Yann E. MORIN wrote:
> > > On 2014-09-15 23:04 +0200, Eric Le Bihan spake thusly:
> > > > Add a systemd service file to start dhcpd.
> [--SNIP--]
> > > > +	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
> > >
> > > I'm not sure to understand those two. Are they needed on the target?
> > >
> > > They suspiciously look like our 'makedev' syntax. Does systemd recognise
> > > this too?
> >
> > Among the zillion of tools provided by systemd, there is 'systemd-tmpfiles'
> > [1]. This program creates, deletes, and cleans up volatile and temporary
> > files and directories based on configuration files stored in
> > /usr/lib/tmpfiles.d and /etc/tmpfiles.d.
> >
> > It is true that these files follow a syntax similar to makedev [2]. But unlike
> > 'makedev' which sets the proper access rights for / entries at build time,
> > 'systemd-tmpfiles' creates the files at runtime if they are missing.
> >
> > In the current default skeleton used by Buildroot, parts of /var are
> > tmpfs-based and thus get cleaned at each reboot. 'systemd-tmpfiles' can
> > recreate them.
> >
> > For some reasons, when using systemd, dhcpd complains at start-up about
> > /var/lib/dhcp/dhcpd.leases not being accessible. So the Makefile installs a
> > file named /usr/lib/tmpfiles.d/dhcp.conf, which contains "instructions" for
> > creating the missing file with the proper access rights.
>
> Thanks for the thorough explanations!
>
> > I know that a package named 'foo' can add system users via FOO_USERS, thanks
> > to 'mkusers'. Can the same be done with 'makedev'?
>
> Yes, it is possible, see:
>     http://nightly.buildroot.org/#_infrastructure_for_packages_with_specific_build_systems
> and:
>     http://nightly.buildroot.org/#makedev-syntax
>
> You'd need something like:
>
>     define LIBFOO_PERMISSIONS
>         /var/lib/dhcp d 0755 0 0 - - - - -
>         /var/lib/dhcp/dhcpd.leases f 0600 0 0 - - - - -
>     endef
>
> > This would allow a package
> > to create files with the proper owner and access rights without having to
> > provide additional files.
>
> Problem is /var/lib/dhcp/dhcpd.leases should be on a RW filesystem, and
> the only one Buildroot gurantees to be RW is /tmp (which is a tmpfs).
>
> But /var/lib does not point to a subdir in /tmp so whether we use
> systemd's feature to create missing files, or the makedev above, we'd
> still need to make /var/lib/dhcp a symling to somewhere in /tmp.
>

I re-read dhcp.mk: we can see that, when installing the program in the
target directory, /var/lib/dhcp is created as a symlink to /tmp, which is
good. Besides the Busybox/SysV init script S80dhcp-server creates
/var/lib/dhcp/dhcpd.leases if it does not exist. Great!

So the problem is already solved when using Busybox/SysV and for systemd,
it is solved via the proposed patch :-)

Best regards
ELB

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Buildroot] [PATCH] dhcp: add systemd service file
  2014-10-26 21:13 ` Thomas Petazzoni
@ 2014-10-27 17:14   ` Eric Le Bihan
  0 siblings, 0 replies; 10+ messages in thread
From: Eric Le Bihan @ 2014-10-27 17:14 UTC (permalink / raw)
  To: buildroot

Hi!

On Sun, Oct 26, 2014 at 10:13:07PM +0100, Thomas Petazzoni wrote:
> Dear Eric Le Bihan,
>
> On Mon, 15 Sep 2014 23:04:43 +0200, Eric Le Bihan wrote:
> > Add a systemd service file to start dhcpd.
> >
> > The network interfaces to listen on can be set via the variable
> > INTERFACES in /etc/default/dhcpd.conf. Example:
> >
> >   INTERFACES="eth0 eth1"
> >
> > Also install a tmpfiles.d file to create /var/lib/dhcp/dhcpd.leases
> > (needed at dhcpd start-up).
> >
> > Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
> > ---
> >  package/dhcp/dhcp.mk       | 15 +++++++++++++++
> >  package/dhcp/dhcpd.service | 13 +++++++++++++
> >  2 files changed, 28 insertions(+)
> >  create mode 100644 package/dhcp/dhcpd.service
>
> What is the status of this patch? Yann made some comments, which
> apparently you agreed on. Is a new version of the patch needed?

As explained in my reply to Yann, there is no need for a new version of the
patch.

Best regards
ELB

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Buildroot] [PATCH] dhcp: add systemd service file
  2014-09-15 21:04 [Buildroot] [PATCH] dhcp: add systemd service file Eric Le Bihan
  2014-09-21 20:44 ` Yann E. MORIN
  2014-10-26 21:13 ` Thomas Petazzoni
@ 2014-10-29 22:08 ` Thomas Petazzoni
  2 siblings, 0 replies; 10+ messages in thread
From: Thomas Petazzoni @ 2014-10-29 22:08 UTC (permalink / raw)
  To: buildroot

Dear Eric Le Bihan,

On Mon, 15 Sep 2014 23:04:43 +0200, Eric Le Bihan wrote:
> Add a systemd service file to start dhcpd.
> 
> The network interfaces to listen on can be set via the variable
> INTERFACES in /etc/default/dhcpd.conf. Example:
> 
>   INTERFACES="eth0 eth1"
> 
> Also install a tmpfiles.d file to create /var/lib/dhcp/dhcpd.leases
> (needed at dhcpd start-up).
> 
> Signed-off-by: Eric Le Bihan <eric.le.bihan.dev@free.fr>
> ---
>  package/dhcp/dhcp.mk       | 15 +++++++++++++++
>  package/dhcp/dhcpd.service | 13 +++++++++++++
>  2 files changed, 28 insertions(+)
>  create mode 100644 package/dhcp/dhcpd.service

Applied, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Buildroot] [PATCH] dhcp: add systemd service file
  2014-09-15 20:38 Eric Le Bihan
@ 2014-09-15 21:08 ` Eric Le Bihan
  0 siblings, 0 replies; 10+ messages in thread
From: Eric Le Bihan @ 2014-09-15 21:08 UTC (permalink / raw)
  To: buildroot

I also forgot the "Signed-off-by" line here: will resend.

Best regards,
ELB

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [Buildroot] [PATCH] dhcp: add systemd service file
@ 2014-09-15 20:38 Eric Le Bihan
  2014-09-15 21:08 ` Eric Le Bihan
  0 siblings, 1 reply; 10+ messages in thread
From: Eric Le Bihan @ 2014-09-15 20:38 UTC (permalink / raw)
  To: buildroot

Add a systemd service file to start dhcpd.

The network interfaces to listen on can be set via the variable
INTERFACES in /etc/default/dhcpd.conf. Example:

  INTERFACES="eth0 eth1"

Also install a tmpfiles.d file to create /var/lib/dhcp/dhcpd.leases
(needed at dhcpd start-up).
---
 package/dhcp/dhcp.mk       | 15 +++++++++++++++
 package/dhcp/dhcpd.service | 13 +++++++++++++
 2 files changed, 28 insertions(+)
 create mode 100644 package/dhcp/dhcpd.service

diff --git a/package/dhcp/dhcp.mk b/package/dhcp/dhcp.mk
index 9251185..1b914a8 100644
--- a/package/dhcp/dhcp.mk
+++ b/package/dhcp/dhcp.mk
@@ -74,6 +74,21 @@ define DHCP_INSTALL_INIT_SYSV
 		$(TARGET_DIR)/etc/init.d/S80dhcp-relay
 endef
 
+define DHCP_INSTALL_INIT_SYSTEMD
+	$(INSTALL) -D -m 644 package/dhcp/dhcpd.service \
+		$(TARGET_DIR)/lib/systemd/system/dhcpd.service
+
+	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+
+	ln -sf ../../../../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
+endef
+
 define DHCP_INSTALL_TARGET_CMDS
 	$(DHCP_INSTALL_RELAY)
 	$(DHCP_INSTALL_SERVER)
diff --git a/package/dhcp/dhcpd.service b/package/dhcp/dhcpd.service
new file mode 100644
index 0000000..7b265cb
--- /dev/null
+++ b/package/dhcp/dhcpd.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=DHCP server
+After=network.target
+
+[Service]
+Type=forking
+PIDFile=/run/dhcpd.pid
+ExecStart=/usr/sbin/dhcpd -q -pf /run/dhcpd.pid $INTERFACES
+KillSignal=SIGINT
+EnvironmentFile=/etc/default/dhcpd.conf
+
+[Install]
+WantedBy=multi-user.target
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2014-10-29 22:08 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-15 21:04 [Buildroot] [PATCH] dhcp: add systemd service file Eric Le Bihan
2014-09-21 20:44 ` Yann E. MORIN
2014-09-22 10:52   ` Eric Le Bihan
2014-09-22 17:34     ` Yann E. MORIN
2014-10-27 12:04       ` Eric Le Bihan
2014-10-26 21:13 ` Thomas Petazzoni
2014-10-27 17:14   ` Eric Le Bihan
2014-10-29 22:08 ` Thomas Petazzoni
  -- strict thread matches above, loose matches on Subject: below --
2014-09-15 20:38 Eric Le Bihan
2014-09-15 21:08 ` Eric Le Bihan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.