Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/pigpio: add sysv and systemd init scripts
@ 2019-11-11 15:05 Grzegorz Blach
  2020-09-03 20:07 ` Thomas Petazzoni
  0 siblings, 1 reply; 3+ messages in thread
From: Grzegorz Blach @ 2019-11-11 15:05 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Grzegorz Blach <grzegorz@blach.pl>
---
 package/pigpio/S50pigpio      | 40 +++++++++++++++++++++++++++++++++++
 package/pigpio/pigpio.mk      | 13 ++++++++++++
 package/pigpio/pigpio.service | 10 +++++++++
 3 files changed, 63 insertions(+)
 create mode 100644 package/pigpio/S50pigpio
 create mode 100644 package/pigpio/pigpio.service

diff --git a/package/pigpio/S50pigpio b/package/pigpio/S50pigpio
new file mode 100644
index 0000000000..7b2e979600
--- /dev/null
+++ b/package/pigpio/S50pigpio
@@ -0,0 +1,40 @@
+#!/bin/sh
+#
+# Starts pigpio daemon.
+#
+
+# Allow a few customizations from a config file
+test -r /etc/default/pigpio && . /etc/default/pigpio
+
+start() {
+	printf "Starting pigpio daemon: "
+	umask 077
+	pigpiod $PIGPIOD_ARGS
+	[ $? = 0 ] && echo "OK" || echo "FAIL"
+}
+stop() {
+	printf "Stopping pigpio daemon: "
+	start-stop-daemon -K -q -p /var/run/pigpio.pid
+	[ $? = 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/pigpio/pigpio.mk b/package/pigpio/pigpio.mk
index 1cf8f50afc..e8c37621d9 100644
--- a/package/pigpio/pigpio.mk
+++ b/package/pigpio/pigpio.mk
@@ -38,4 +38,17 @@ define PIGPIO_INSTALL_STAGING_CMDS
 	ln -sf libpigpiod_if2.so.1 $(STAGING_DIR)/usr/lib/libpigpiod_if2.so
 endef
 
+define PIGPIO_INSTALL_INIT_SYSV
+        $(INSTALL) -D -m 755 package/pigpio/S50pigpio \
+                $(TARGET_DIR)/etc/init.d/S50pigpio
+endef
+
+define PIGPIO_INSTALL_INIT_SYSTEMD
+        $(INSTALL) -D -m 644 package/pigpio/pigpio.service \
+                $(TARGET_DIR)/usr/lib/systemd/system/pigpio.service
+        mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+        ln -fs ../../../../usr/lib/systemd/system/pigpio.service \
+                $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/pigpio.service
+endef
+
 $(eval $(generic-package))
diff --git a/package/pigpio/pigpio.service b/package/pigpio/pigpio.service
new file mode 100644
index 0000000000..135624cc43
--- /dev/null
+++ b/package/pigpio/pigpio.service
@@ -0,0 +1,10 @@
+[Unit]
+Description=Pigpio daemon
+After=network.target
+
+[Service]
+EnvironmentFile=-/etc/default/pigpio
+ExecStart=/usr/bin/pigpiod -g $PIGPIOD_ARGS
+
+[Install]
+WantedBy=multi-user.target
-- 
2.24.0

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

* [Buildroot] [PATCH 1/1] package/pigpio: add sysv and systemd init scripts
  2019-11-11 15:05 [Buildroot] [PATCH 1/1] package/pigpio: add sysv and systemd init scripts Grzegorz Blach
@ 2020-09-03 20:07 ` Thomas Petazzoni
  2020-09-07  9:38   ` Grzegorz Blach
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni @ 2020-09-03 20:07 UTC (permalink / raw)
  To: buildroot

Hello Grzegorz,

Sorry for the long delay in not getting back to you. A few comments
below.

On Mon, 11 Nov 2019 15:05:34 +0000
Grzegorz Blach <grzegorz@blach.pl> wrote:

> diff --git a/package/pigpio/S50pigpio b/package/pigpio/S50pigpio
> new file mode 100644
> index 0000000000..7b2e979600
> --- /dev/null
> +++ b/package/pigpio/S50pigpio
> @@ -0,0 +1,40 @@
> +#!/bin/sh
> +#
> +# Starts pigpio daemon.
> +#

Could you use package/busybox/S01syslogd as a template for this init
script, and model yours to be as similar as possible ?

> +
> +# Allow a few customizations from a config file
> +test -r /etc/default/pigpio && . /etc/default/pigpio
> +
> +start() {
> +	printf "Starting pigpio daemon: "
> +	umask 077

Why do you need this umask ?

> +	pigpiod $PIGPIOD_ARGS

Could you use start-stop-daemon for starting the daemon?

Other than these comments, the whole thing looks pretty good. If you
respin soon, I promise to apply quickly!

Thanks!

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

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

* [Buildroot] [PATCH 1/1] package/pigpio: add sysv and systemd init scripts
  2020-09-03 20:07 ` Thomas Petazzoni
@ 2020-09-07  9:38   ` Grzegorz Blach
  0 siblings, 0 replies; 3+ messages in thread
From: Grzegorz Blach @ 2020-09-07  9:38 UTC (permalink / raw)
  To: buildroot

Hello,

I've just sent an updated patch.


On 03/09/2020 22:07, Thomas Petazzoni wrote:
> Hello Grzegorz,
> 
> Sorry for the long delay in not getting back to you. A few comments
> below.
> 
> On Mon, 11 Nov 2019 15:05:34 +0000
> Grzegorz Blach <grzegorz@blach.pl> wrote:
> 
>> diff --git a/package/pigpio/S50pigpio b/package/pigpio/S50pigpio
>> new file mode 100644
>> index 0000000000..7b2e979600
>> --- /dev/null
>> +++ b/package/pigpio/S50pigpio
>> @@ -0,0 +1,40 @@
>> +#!/bin/sh
>> +#
>> +# Starts pigpio daemon.
>> +#
> 
> Could you use package/busybox/S01syslogd as a template for this init
> script, and model yours to be as similar as possible ?

Done

>> +
>> +# Allow a few customizations from a config file
>> +test -r /etc/default/pigpio && . /etc/default/pigpio
>> +
>> +start() {
>> +	printf "Starting pigpio daemon: "
>> +	umask 077
> 
> Why do you need this umask ?

I don't remember, probably I just copied this line from another init.d 
script.

>> +	pigpiod $PIGPIOD_ARGS
> 
> Could you use start-stop-daemon for starting the daemon?

Done

> Other than these comments, the whole thing looks pretty good. If you
> respin soon, I promise to apply quickly!
> 
> Thanks!
> 
> Thomas
> 

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

end of thread, other threads:[~2020-09-07  9:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-11-11 15:05 [Buildroot] [PATCH 1/1] package/pigpio: add sysv and systemd init scripts Grzegorz Blach
2020-09-03 20:07 ` Thomas Petazzoni
2020-09-07  9:38   ` Grzegorz Blach

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox