Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Grzegorz Blach <grzegorz@blach.pl>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 1/1] package/pigpio: add sysv and systemd init scripts
Date: Mon, 11 Nov 2019 15:05:34 +0000	[thread overview]
Message-ID: <20191111150534.1181-1-grzegorz@blach.pl> (raw)

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

             reply	other threads:[~2019-11-11 15:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-11 15:05 Grzegorz Blach [this message]
2020-09-03 20:07 ` [Buildroot] [PATCH 1/1] package/pigpio: add sysv and systemd init scripts Thomas Petazzoni
2020-09-07  9:38   ` Grzegorz Blach

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=20191111150534.1181-1-grzegorz@blach.pl \
    --to=grzegorz@blach.pl \
    --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