* [Buildroot] [PATCH v2 1/1] package/collectd: add init script for SysV
@ 2019-10-26 7:19 Asaf Kahlon
2019-10-26 7:19 ` [Buildroot] [PATCH v2 1/1] package/uvw: new package Asaf Kahlon
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Asaf Kahlon @ 2019-10-26 7:19 UTC (permalink / raw)
To: buildroot
Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
---
v1->v2: use start-stop-daemon
---
package/collectd/S90collectd | 36 ++++++++++++++++++++++++++++++++++++
package/collectd/collectd.mk | 5 +++++
2 files changed, 41 insertions(+)
create mode 100644 package/collectd/S90collectd
diff --git a/package/collectd/S90collectd b/package/collectd/S90collectd
new file mode 100644
index 0000000000..3c5af17674
--- /dev/null
+++ b/package/collectd/S90collectd
@@ -0,0 +1,36 @@
+#!/bin/sh
+
+DAEMON="collectd"
+PIDFILE="/var/run/$DAEMON.pid"
+
+start() {
+ printf "Starting collectd... "
+ start-stop-daemon -b -m -S -q -p $PIDFILE -x "/usr/sbin/$DAEMON"
+ [ $? = 0 ] && echo "OK" || echo "FAIL"
+}
+stop() {
+ printf "Stopping collectd... "
+ start-stop-daemon -K -q -p $PIDFILE
+ [ $? = 0 ] && echo "OK" || echo "FAIL"
+}
+restart() {
+ stop
+ start
+}
+
+case "$1" in
+ start)
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ restart|reload)
+ restart
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart}"
+ exit 1
+esac
+
+exit $?
diff --git a/package/collectd/collectd.mk b/package/collectd/collectd.mk
index 5d94dec46d..1bce196e7e 100644
--- a/package/collectd/collectd.mk
+++ b/package/collectd/collectd.mk
@@ -218,4 +218,9 @@ define COLLECTD_INSTALL_INIT_SYSTEMD
$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/collectd.service
endef
+define COLLECTD_INSTALL_INIT_SYSV
+ $(INSTALL) -D -m 0755 package/collectd/S90collectd \
+ $(TARGET_DIR)/etc/init.d/S90collectd
+endef
+
$(eval $(autotools-package))
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH v2 1/1] package/uvw: new package
2019-10-26 7:19 [Buildroot] [PATCH v2 1/1] package/collectd: add init script for SysV Asaf Kahlon
@ 2019-10-26 7:19 ` Asaf Kahlon
2019-10-26 12:31 ` Gilles Talis
2019-10-26 7:23 ` [Buildroot] [PATCH v2 1/1] package/collectd: add init script for SysV Thomas Petazzoni
2019-10-28 18:37 ` Carlos Santos
2 siblings, 1 reply; 7+ messages in thread
From: Asaf Kahlon @ 2019-10-26 7:19 UTC (permalink / raw)
To: buildroot
A header-only libuv wrapper in C++.
A patch is added to enable in-tree build, which is
checked and prevented by the package and fails the build.
Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
---
v1->v2: add missing entry in DEVELOPERS
---
DEVELOPERS | 1 +
package/Config.in | 1 +
...-CMakeLists.txt-allow-in-place-build.patch | 32 +++++++++++++++++++
package/uvw/Config.in | 16 ++++++++++
package/uvw/uvw.hash | 3 ++
package/uvw/uvw.mk | 15 +++++++++
6 files changed, 68 insertions(+)
create mode 100644 package/uvw/0001-CMakeLists.txt-allow-in-place-build.patch
create mode 100644 package/uvw/Config.in
create mode 100644 package/uvw/uvw.hash
create mode 100644 package/uvw/uvw.mk
diff --git a/DEVELOPERS b/DEVELOPERS
index ec4f50a79e..b9e6881419 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -239,6 +239,7 @@ F: package/python*
F: package/snmpclitools/
F: package/spdlog/
F: package/uftp/
+F: package/uvw/
F: package/zeromq/
N: Ash Charles <ashcharles@gmail.com>
diff --git a/package/Config.in b/package/Config.in
index d78b4c444b..901c25fe02 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -1805,6 +1805,7 @@ endif
source "package/tinycbor/Config.in"
source "package/tz/Config.in"
source "package/tzdata/Config.in"
+ source "package/uvw/Config.in"
source "package/xapian/Config.in"
endmenu
diff --git a/package/uvw/0001-CMakeLists.txt-allow-in-place-build.patch b/package/uvw/0001-CMakeLists.txt-allow-in-place-build.patch
new file mode 100644
index 0000000000..01068d0427
--- /dev/null
+++ b/package/uvw/0001-CMakeLists.txt-allow-in-place-build.patch
@@ -0,0 +1,32 @@
+From 1d784a0067b7123971c834c77f4f137acca56ae6 Mon Sep 17 00:00:00 2001
+From: Asaf Kahlon <asafka7@gmail.com>
+Date: Fri, 25 Oct 2019 19:09:14 +0300
+Subject: [PATCH 1/1] CMakeLists.txt: allow in-tree build
+
+Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
+---
+ CMakeLists.txt | 8 --------
+ 1 file changed, 8 deletions(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 9fc5538..4aaabf7 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -4,14 +4,6 @@
+
+ cmake_minimum_required(VERSION 3.2)
+
+-#
+-# Building in-tree is not allowed (we take care of your craziness).
+-#
+-
+-if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
+- message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the source code and call cmake from there. Thank you.")
+-endif()
+-
+ #
+ # Project configuration
+ #
+--
+2.20.1
+
diff --git a/package/uvw/Config.in b/package/uvw/Config.in
new file mode 100644
index 0000000000..58e68392af
--- /dev/null
+++ b/package/uvw/Config.in
@@ -0,0 +1,16 @@
+config BR2_PACKAGE_UVW
+ bool "uvw"
+ depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL # libuv
+ depends on BR2_USE_MMU # libuv
+ depends on !BR2_STATIC_LIBS # libuv
+ depends on BR2_TOOLCHAIN_HAS_SYNC_4 # libuv
+ help
+ Header-only, event based, tiny and easy to use
+ libuv wrapper in modern C++.
+
+ https://github.com/skypjack/uvw
+
+comment "uvw needs a toolchain w/ NPTL, dynamic library"
+ depends on !BR2_TOOLCHAIN_HAS_THREADS_NPTL || BR2_STATIC_LIBS
+ depends on BR2_USE_MMU
+ depends on BR2_TOOLCHAIN_HAS_SYNC_4
diff --git a/package/uvw/uvw.hash b/package/uvw/uvw.hash
new file mode 100644
index 0000000000..e6129e559d
--- /dev/null
+++ b/package/uvw/uvw.hash
@@ -0,0 +1,3 @@
+# Locally calculated
+sha256 266a354f0c64a8e85f29b10f20f4d08a35bc1e8caa7cc94a8afecf9ca43f4442 uvw-2.2.0_libuv-v1.33.tar.gz
+sha256 ea786619b4d1b2ba0a188e923111122dfefea1d01c86e37f9e8c80bdbc3ea400 LICENSE
diff --git a/package/uvw/uvw.mk b/package/uvw/uvw.mk
new file mode 100644
index 0000000000..6b3621e55d
--- /dev/null
+++ b/package/uvw/uvw.mk
@@ -0,0 +1,15 @@
+################################################################################
+#
+# uvw
+#
+################################################################################
+
+UVW_VERSION = 2.2.0_libuv-v1.33
+UVW_SITE = $(call github,skypjack,uvw,v$(UVW_VERSION))
+UVW_INSTALL_STAGING = YES
+UVW_INSTALL_TARGET = NO
+UVW_DEPENDENCIES = libuv
+UVW_LICENSE = MIT
+UVW_LICENSE_FILES = LICENSE
+
+$(eval $(cmake-package))
--
2.20.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH v2 1/1] package/collectd: add init script for SysV
2019-10-26 7:19 [Buildroot] [PATCH v2 1/1] package/collectd: add init script for SysV Asaf Kahlon
2019-10-26 7:19 ` [Buildroot] [PATCH v2 1/1] package/uvw: new package Asaf Kahlon
@ 2019-10-26 7:23 ` Thomas Petazzoni
2019-10-26 7:31 ` Asaf Kahlon
2019-10-28 18:37 ` Carlos Santos
2 siblings, 1 reply; 7+ messages in thread
From: Thomas Petazzoni @ 2019-10-26 7:23 UTC (permalink / raw)
To: buildroot
Hello Asaf,
On Sat, 26 Oct 2019 10:19:04 +0300
Asaf Kahlon <asafka7@gmail.com> wrote:
> Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
> ---
> v1->v2: use start-stop-daemon
> ---
> package/collectd/S90collectd | 36 ++++++++++++++++++++++++++++++++++++
> package/collectd/collectd.mk | 5 +++++
> 2 files changed, 41 insertions(+)
> create mode 100644 package/collectd/S90collectd
>
> diff --git a/package/collectd/S90collectd b/package/collectd/S90collectd
> new file mode 100644
> index 0000000000..3c5af17674
> --- /dev/null
> +++ b/package/collectd/S90collectd
> @@ -0,0 +1,36 @@
> +#!/bin/sh
> +
> +DAEMON="collectd"
> +PIDFILE="/var/run/$DAEMON.pid"
> +
> +start() {
> + printf "Starting collectd... "
> + start-stop-daemon -b -m -S -q -p $PIDFILE -x "/usr/sbin/$DAEMON"
Does this actually works? In your v1, you were just starting the
collectd daemon, without anything to put it in the background, so it
suppose it would automatically fork itself and go in the background.
This would not play very well with start-stop-daemon, so I was assuming
you would need to pass some collectd option to keep it in the
foreground, and let start-stop-daemon do the daemonization.
Did you test your v2 on the target ? Does the pidfile really contains
the PID of the daemon that is running ? Does the stop action actually
works ?
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH v2 1/1] package/collectd: add init script for SysV
2019-10-26 7:23 ` [Buildroot] [PATCH v2 1/1] package/collectd: add init script for SysV Thomas Petazzoni
@ 2019-10-26 7:31 ` Asaf Kahlon
0 siblings, 0 replies; 7+ messages in thread
From: Asaf Kahlon @ 2019-10-26 7:31 UTC (permalink / raw)
To: buildroot
Hello,
On Sat, Oct 26, 2019 at 10:23 AM Thomas Petazzoni
<thomas.petazzoni@bootlin.com> wrote:
>
> Hello Asaf,
>
> On Sat, 26 Oct 2019 10:19:04 +0300
> Asaf Kahlon <asafka7@gmail.com> wrote:
>
> > Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
> > ---
> > v1->v2: use start-stop-daemon
> > ---
> > package/collectd/S90collectd | 36 ++++++++++++++++++++++++++++++++++++
> > package/collectd/collectd.mk | 5 +++++
> > 2 files changed, 41 insertions(+)
> > create mode 100644 package/collectd/S90collectd
> >
> > diff --git a/package/collectd/S90collectd b/package/collectd/S90collectd
> > new file mode 100644
> > index 0000000000..3c5af17674
> > --- /dev/null
> > +++ b/package/collectd/S90collectd
> > @@ -0,0 +1,36 @@
> > +#!/bin/sh
> > +
> > +DAEMON="collectd"
> > +PIDFILE="/var/run/$DAEMON.pid"
> > +
> > +start() {
> > + printf "Starting collectd... "
> > + start-stop-daemon -b -m -S -q -p $PIDFILE -x "/usr/sbin/$DAEMON"
>
> Does this actually works? In your v1, you were just starting the
> collectd daemon, without anything to put it in the background, so it
> suppose it would automatically fork itself and go in the background.
> This would not play very well with start-stop-daemon, so I was assuming
> you would need to pass some collectd option to keep it in the
> foreground, and let start-stop-daemon do the daemonization.
>
> Did you test your v2 on the target ? Does the pidfile really contains
> the PID of the daemon that is running ? Does the stop action actually
> works ?
Yes, I loaded the image with qemu and the daemon was started.
The pid on /var/run/collectd.pid was the pid of collectd. After that, I manually
run "/etc/init.d/S90collectd stop", made sure the process died and the
/var/run/collectd.pid file was removed. The logs also looked fine and
stated normal
start/stop of the daemon.
>
> Thanks!
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com
Asaf.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH v2 1/1] package/uvw: new package
2019-10-26 7:19 ` [Buildroot] [PATCH v2 1/1] package/uvw: new package Asaf Kahlon
@ 2019-10-26 12:31 ` Gilles Talis
2019-10-26 13:39 ` Asaf Kahlon
0 siblings, 1 reply; 7+ messages in thread
From: Gilles Talis @ 2019-10-26 12:31 UTC (permalink / raw)
To: buildroot
Hello Asaf,
thanks for your contribution. A few comments below.
Le sam. 26 oct. 2019 ? 09:19, Asaf Kahlon <asafka7@gmail.com> a ?crit :
>
> A header-only libuv wrapper in C++.
>
> A patch is added to enable in-tree build, which is
> checked and prevented by the package and fails the build.
>
> Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
> ---
> v1->v2: add missing entry in DEVELOPERS
> ---
> DEVELOPERS | 1 +
> package/Config.in | 1 +
> ...-CMakeLists.txt-allow-in-place-build.patch | 32 +++++++++++++++++++
> package/uvw/Config.in | 16 ++++++++++
> package/uvw/uvw.hash | 3 ++
> package/uvw/uvw.mk | 15 +++++++++
> 6 files changed, 68 insertions(+)
> create mode 100644 package/uvw/0001-CMakeLists.txt-allow-in-place-build.patch
> create mode 100644 package/uvw/Config.in
> create mode 100644 package/uvw/uvw.hash
> create mode 100644 package/uvw/uvw.mk
>
> diff --git a/DEVELOPERS b/DEVELOPERS
> index ec4f50a79e..b9e6881419 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -239,6 +239,7 @@ F: package/python*
> F: package/snmpclitools/
> F: package/spdlog/
> F: package/uftp/
> +F: package/uvw/
> F: package/zeromq/
>
> N: Ash Charles <ashcharles@gmail.com>
> diff --git a/package/Config.in b/package/Config.in
> index d78b4c444b..901c25fe02 100644
> --- a/package/Config.in
> +++ b/package/Config.in
> @@ -1805,6 +1805,7 @@ endif
> source "package/tinycbor/Config.in"
> source "package/tz/Config.in"
> source "package/tzdata/Config.in"
> + source "package/uvw/Config.in"
> source "package/xapian/Config.in"
> endmenu
>
> diff --git a/package/uvw/0001-CMakeLists.txt-allow-in-place-build.patch b/package/uvw/0001-CMakeLists.txt-allow-in-place-build.patch
> new file mode 100644
> index 0000000000..01068d0427
> --- /dev/null
> +++ b/package/uvw/0001-CMakeLists.txt-allow-in-place-build.patch
> @@ -0,0 +1,32 @@
> +From 1d784a0067b7123971c834c77f4f137acca56ae6 Mon Sep 17 00:00:00 2001
> +From: Asaf Kahlon <asafka7@gmail.com>
> +Date: Fri, 25 Oct 2019 19:09:14 +0300
> +Subject: [PATCH 1/1] CMakeLists.txt: allow in-tree build
> +
> +Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
> +---
> + CMakeLists.txt | 8 --------
> + 1 file changed, 8 deletions(-)
> +
> +diff --git a/CMakeLists.txt b/CMakeLists.txt
> +index 9fc5538..4aaabf7 100644
> +--- a/CMakeLists.txt
> ++++ b/CMakeLists.txt
> +@@ -4,14 +4,6 @@
> +
> + cmake_minimum_required(VERSION 3.2)
> +
> +-#
> +-# Building in-tree is not allowed (we take care of your craziness).
> +-#
> +-
> +-if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
> +- message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the source code and call cmake from there. Thank you.")
> +-endif()
> +-
> + #
> + # Project configuration
> + #
> +--
> +2.20.1
> +
> diff --git a/package/uvw/Config.in b/package/uvw/Config.in
> new file mode 100644
> index 0000000000..58e68392af
> --- /dev/null
> +++ b/package/uvw/Config.in
> @@ -0,0 +1,16 @@
> +config BR2_PACKAGE_UVW
> + bool "uvw"
> + depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL # libuv
There's also a dependendy on the toolchain version. The package author
mentioned "a compiler that supports at least C++17"
> + depends on BR2_USE_MMU # libuv
> + depends on !BR2_STATIC_LIBS # libuv
> + depends on BR2_TOOLCHAIN_HAS_SYNC_4 # libuv
What about selecting libuv here? I think this would be convenient for
the user to enable libuv through uvw.
Also, as there's seems to be such a dependency between this package
and libuv, I would add a comment in package/libuv/libuv.mk to instruct
the developer to bump uvw along with libuv.
thanks
regards
Gilles.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH v2 1/1] package/uvw: new package
2019-10-26 12:31 ` Gilles Talis
@ 2019-10-26 13:39 ` Asaf Kahlon
0 siblings, 0 replies; 7+ messages in thread
From: Asaf Kahlon @ 2019-10-26 13:39 UTC (permalink / raw)
To: buildroot
Hello Gilles.
On Sat, Oct 26, 2019 at 3:31 PM Gilles Talis <gilles.talis@gmail.com> wrote:
>
> Hello Asaf,
>
> thanks for your contribution. A few comments below.
>
> Le sam. 26 oct. 2019 ? 09:19, Asaf Kahlon <asafka7@gmail.com> a ?crit :
> >
> > A header-only libuv wrapper in C++.
> >
> > A patch is added to enable in-tree build, which is
> > checked and prevented by the package and fails the build.
> >
> > Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
> > ---
> > v1->v2: add missing entry in DEVELOPERS
> > ---
> > DEVELOPERS | 1 +
> > package/Config.in | 1 +
> > ...-CMakeLists.txt-allow-in-place-build.patch | 32 +++++++++++++++++++
> > package/uvw/Config.in | 16 ++++++++++
> > package/uvw/uvw.hash | 3 ++
> > package/uvw/uvw.mk | 15 +++++++++
> > 6 files changed, 68 insertions(+)
> > create mode 100644 package/uvw/0001-CMakeLists.txt-allow-in-place-build.patch
> > create mode 100644 package/uvw/Config.in
> > create mode 100644 package/uvw/uvw.hash
> > create mode 100644 package/uvw/uvw.mk
> >
> > diff --git a/DEVELOPERS b/DEVELOPERS
> > index ec4f50a79e..b9e6881419 100644
> > --- a/DEVELOPERS
> > +++ b/DEVELOPERS
> > @@ -239,6 +239,7 @@ F: package/python*
> > F: package/snmpclitools/
> > F: package/spdlog/
> > F: package/uftp/
> > +F: package/uvw/
> > F: package/zeromq/
> >
> > N: Ash Charles <ashcharles@gmail.com>
> > diff --git a/package/Config.in b/package/Config.in
> > index d78b4c444b..901c25fe02 100644
> > --- a/package/Config.in
> > +++ b/package/Config.in
> > @@ -1805,6 +1805,7 @@ endif
> > source "package/tinycbor/Config.in"
> > source "package/tz/Config.in"
> > source "package/tzdata/Config.in"
> > + source "package/uvw/Config.in"
> > source "package/xapian/Config.in"
> > endmenu
> >
> > diff --git a/package/uvw/0001-CMakeLists.txt-allow-in-place-build.patch b/package/uvw/0001-CMakeLists.txt-allow-in-place-build.patch
> > new file mode 100644
> > index 0000000000..01068d0427
> > --- /dev/null
> > +++ b/package/uvw/0001-CMakeLists.txt-allow-in-place-build.patch
> > @@ -0,0 +1,32 @@
> > +From 1d784a0067b7123971c834c77f4f137acca56ae6 Mon Sep 17 00:00:00 2001
> > +From: Asaf Kahlon <asafka7@gmail.com>
> > +Date: Fri, 25 Oct 2019 19:09:14 +0300
> > +Subject: [PATCH 1/1] CMakeLists.txt: allow in-tree build
> > +
> > +Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
> > +---
> > + CMakeLists.txt | 8 --------
> > + 1 file changed, 8 deletions(-)
> > +
> > +diff --git a/CMakeLists.txt b/CMakeLists.txt
> > +index 9fc5538..4aaabf7 100644
> > +--- a/CMakeLists.txt
> > ++++ b/CMakeLists.txt
> > +@@ -4,14 +4,6 @@
> > +
> > + cmake_minimum_required(VERSION 3.2)
> > +
> > +-#
> > +-# Building in-tree is not allowed (we take care of your craziness).
> > +-#
> > +-
> > +-if(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
> > +- message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the source code and call cmake from there. Thank you.")
> > +-endif()
> > +-
> > + #
> > + # Project configuration
> > + #
> > +--
> > +2.20.1
> > +
> > diff --git a/package/uvw/Config.in b/package/uvw/Config.in
> > new file mode 100644
> > index 0000000000..58e68392af
> > --- /dev/null
> > +++ b/package/uvw/Config.in
> > @@ -0,0 +1,16 @@
> > +config BR2_PACKAGE_UVW
> > + bool "uvw"
> > + depends on BR2_TOOLCHAIN_HAS_THREADS_NPTL # libuv
> There's also a dependendy on the toolchain version. The package author
> mentioned "a compiler that supports at least C++17"
>
> > + depends on BR2_USE_MMU # libuv
> > + depends on !BR2_STATIC_LIBS # libuv
> > + depends on BR2_TOOLCHAIN_HAS_SYNC_4 # libuv
> What about selecting libuv here? I think this would be convenient for
> the user to enable libuv through uvw.
>
> Also, as there's seems to be such a dependency between this package
> and libuv, I would add a comment in package/libuv/libuv.mk to instruct
> the developer to bump uvw along with libuv.
>
Thanks for the review!
I sent a v3.
> thanks
> regards
> Gilles.
Regards,
Asaf.
^ permalink raw reply [flat|nested] 7+ messages in thread
* [Buildroot] [PATCH v2 1/1] package/collectd: add init script for SysV
2019-10-26 7:19 [Buildroot] [PATCH v2 1/1] package/collectd: add init script for SysV Asaf Kahlon
2019-10-26 7:19 ` [Buildroot] [PATCH v2 1/1] package/uvw: new package Asaf Kahlon
2019-10-26 7:23 ` [Buildroot] [PATCH v2 1/1] package/collectd: add init script for SysV Thomas Petazzoni
@ 2019-10-28 18:37 ` Carlos Santos
2 siblings, 0 replies; 7+ messages in thread
From: Carlos Santos @ 2019-10-28 18:37 UTC (permalink / raw)
To: buildroot
On Sat, Oct 26, 2019 at 4:19 AM Asaf Kahlon <asafka7@gmail.com> wrote:
>
> Signed-off-by: Asaf Kahlon <asafka7@gmail.com>
> ---
> v1->v2: use start-stop-daemon
> ---
> package/collectd/S90collectd | 36 ++++++++++++++++++++++++++++++++++++
> package/collectd/collectd.mk | 5 +++++
> 2 files changed, 41 insertions(+)
> create mode 100644 package/collectd/S90collectd
>
> diff --git a/package/collectd/S90collectd b/package/collectd/S90collectd
> new file mode 100644
> index 0000000000..3c5af17674
> --- /dev/null
> +++ b/package/collectd/S90collectd
> @@ -0,0 +1,36 @@
> +#!/bin/sh
> +
> +DAEMON="collectd"
EXEC="/usr/sbin/$DAEMON"
> +PIDFILE="/var/run/$DAEMON.pid"
> +
Leave room to user customizations
COLLECTD_ARGS=""
# shellcheck source=/dev/null
[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
> +start() {
> + printf "Starting collectd... "
> + start-stop-daemon -b -m -S -q -p $PIDFILE -x "/usr/sbin/$DAEMON"
The -b and -m are not necessary here, since collectd daemonizes by
default. The only reason why it "works" is because collectd takes a
few milliseconds to daemonize and override the /var/run/collectd.pid
that was written by start-stop-daemon. Replacing $PIDFILE by
$PIDFILE.x in the line above will show the truth:
# /etc/init.d/S90collectd stop
Stopping collectd... OK
# /etc/init.d/S90collectd start
Starting collectd... OK
# pidof collectd
161
# ls -ltr /var/run/collectd.pid*
-rw-r--r-- 1 root root 4 Oct 28 18:15
/var/run/collectd.pid.x <<-- written by start-stop-daemon
-rw-r--r-- 1 root root 4 Oct 28 18:15
/var/run/collectd.pid <<-- written by collectd
==> /var/run/collectd.pid <==
161 <<-- daemonized correctd
==> /var/run/collectd.pid.x <==
160 <<-- initial collectd process
> + [ $? = 0 ] && echo "OK" || echo "FAIL"]
This leads the function to result the result of the "echo" command on
failure, which will be zero. Use this construction, instead
start() {
printf 'Starting %s: ' "$DAEMON"
# shellcheck disable=SC2086 # we need the word splitting
start-stop-daemon -S -q -p "$PIDFILE" -x "$EXEC" \
-- $COLLECTD_ARGS
status=$?
if [ "$status" -eq 0 ]; then
echo "OK"
else
echo "FAIL"
fi
return "$status"
}
> +}
> +stop() {
> + printf "Stopping collectd... "
> + start-stop-daemon -K -q -p $PIDFILE
> + [ $? = 0 ] && echo "OK" || echo "FAIL"
> +}
Leave a blank line between each function to improve readability
> +restart() {
> + stop
Put a one-second pause here, giving time for the daemon to stop.
> + start
> +}
> +
> +case "$1" in
> + start)
> + start
> + ;;
> + stop)
> + stop
> + ;;
> + restart|reload)
> + restart
> + ;;
> + *)
> + echo "Usage: $0 {start|stop|restart}"
> + exit 1
> +esac
case "$1" in
start|stop|restart)
"$1";;
reload)
restart;;
*)
echo "Usage: $0 {start|stop|restart|reload}"
exit 1
esac
> +exit $?
This is not required. A Shell script exit status is by default the the
same one of the last command.
> diff --git a/package/collectd/collectd.mk b/package/collectd/collectd.mk
> index 5d94dec46d..1bce196e7e 100644
> --- a/package/collectd/collectd.mk
> +++ b/package/collectd/collectd.mk
> @@ -218,4 +218,9 @@ define COLLECTD_INSTALL_INIT_SYSTEMD
> $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/collectd.service
> endef
>
> +define COLLECTD_INSTALL_INIT_SYSV
> + $(INSTALL) -D -m 0755 package/collectd/S90collectd \
> + $(TARGET_DIR)/etc/init.d/S90collectd
> +endef
> +
> $(eval $(autotools-package))
> --
> 2.20.1
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
Refer to package/sysklogd/S01syslogd and package/acpid/S02acpid for examples.
--
Carlos Santos <unixmania@gmail.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2019-10-28 18:37 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-26 7:19 [Buildroot] [PATCH v2 1/1] package/collectd: add init script for SysV Asaf Kahlon
2019-10-26 7:19 ` [Buildroot] [PATCH v2 1/1] package/uvw: new package Asaf Kahlon
2019-10-26 12:31 ` Gilles Talis
2019-10-26 13:39 ` Asaf Kahlon
2019-10-26 7:23 ` [Buildroot] [PATCH v2 1/1] package/collectd: add init script for SysV Thomas Petazzoni
2019-10-26 7:31 ` Asaf Kahlon
2019-10-28 18:37 ` Carlos Santos
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox