[OE-core] [PATCH] watchdog: enable systemd support

rongqing.li at windriver.com rongqing.li at windriver.com
Fri Nov 27 06:27:18 UTC 2015


From: Roy Li <rongqing.li at windriver.com>

1. inherit systemd, and add two unit files
2. auto load soft dog kernel module

Signed-off-by: Roy Li <rongqing.li at windriver.com>
---
 .../watchdog/watchdog/watchdog-ping.service            | 12 ++++++++++++
 .../watchdog/watchdog/watchdog.service                 | 12 ++++++++++++
 meta/recipes-extended/watchdog/watchdog_5.14.bb        | 18 ++++++++++++++++--
 3 files changed, 40 insertions(+), 2 deletions(-)
 create mode 100644 meta/recipes-extended/watchdog/watchdog/watchdog-ping.service
 create mode 100644 meta/recipes-extended/watchdog/watchdog/watchdog.service

diff --git a/meta/recipes-extended/watchdog/watchdog/watchdog-ping.service b/meta/recipes-extended/watchdog/watchdog/watchdog-ping.service
new file mode 100644
index 0000000..da403c9
--- /dev/null
+++ b/meta/recipes-extended/watchdog/watchdog/watchdog-ping.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=watchdog daemon for use with ping test / network dependency
+After=network.target
+Conflicts=watchdog.service
+
+[Service]
+Type=forking
+ExecStart=/usr/sbin/watchdog
+ControlGroup=cpu:/
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta/recipes-extended/watchdog/watchdog/watchdog.service b/meta/recipes-extended/watchdog/watchdog/watchdog.service
new file mode 100644
index 0000000..3c36a08
--- /dev/null
+++ b/meta/recipes-extended/watchdog/watchdog/watchdog.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=watchdog daemon
+# man systemd.special
+# auto added After=basic.target
+
+[Service]
+Type=forking
+ExecStart=/usr/sbin/watchdog
+ControlGroup=cpu:/
+
+[Install]
+WantedBy=multi-user.target
diff --git a/meta/recipes-extended/watchdog/watchdog_5.14.bb b/meta/recipes-extended/watchdog/watchdog_5.14.bb
index 9ec0a8e..743a36a 100644
--- a/meta/recipes-extended/watchdog/watchdog_5.14.bb
+++ b/meta/recipes-extended/watchdog/watchdog_5.14.bb
@@ -12,19 +12,33 @@ SRC_URI = "${SOURCEFORGE_MIRROR}/watchdog/watchdog-${PV}.tar.gz \
            file://fixsepbuild.patch \
 	   file://fix-ping-failure.patch \
 	   file://watchdog-init.patch \
-	   file://watchdog-conf.patch"
+	   file://watchdog-conf.patch \
+	   file://watchdog-ping.service \
+	   file://watchdog.service \
+"
 
 SRC_URI[md5sum] = "5b2dba0c593942f4acc100bca0d560c4"
 SRC_URI[sha256sum] = "620b2f49e9879f2e85c73d4c1f422f9101e6b38e824fea2414befd8bb6866ad1"
 
 inherit autotools
-inherit update-rc.d
+inherit update-rc.d systemd
 
 INITSCRIPT_NAME = "watchdog.sh"
 INITSCRIPT_PARAMS = "start 15 1 2 3 4 5 . stop 85 0 6 ."
 
 RRECOMMENDS_${PN} = "kernel-module-softdog"
 
+SYSTEMD_SERVICE_${PN} = "watchdog.service"
+
 do_install_append() {
 	install -D ${S}/redhat/watchdog.init ${D}/${sysconfdir}/init.d/watchdog.sh
+	install -d ${D}${systemd_unitdir}/system
+	install -m 0644 ${WORKDIR}/watchdog*.service ${D}${systemd_unitdir}/system
+
+	if ${@bb.utils.contains('DISTRO_FEATURES','systemd','true','false',d)}; then
+		install -d ${D}${sysconfdir}/modules-load.d
+		echo "softdog" > ${D}${sysconfdir}/modules-load.d/softdog.conf
+	fi
 }
+
+FILES_${PN} += "${systemd_unitdir}/system/*"
-- 
1.9.1




More information about the Openembedded-core mailing list