From 34b7be1554d99ad6cb31b01423bdb0dfb8d36fe7 Mon Sep 17 00:00:00 2001
From: Thierry Escande <thierry.escande@huawei.com>
Date: Wed, 10 Aug 2022 02:05:20 +0200
Subject: [PATCH] openharmony-standard-3.0: Add param systemd service

This service starts the param_service server, used to access the
OpenHarmony param, a kind of registry accessible through the network.

The service requires and starts after the openharmony-preinit systemd
service.

Signed-off-by: Thierry Escande <thierry.escande@huawei.com>
---
 recipes-openharmony/openharmony/files/param.service  | 12 ++++++++++++
 .../openharmony/files/param.service.license          |  3 +++
 .../openharmony/openharmony-standard_3.0.bb          |  7 +++++++
 3 files changed, 22 insertions(+)
 create mode 100644 recipes-openharmony/openharmony/files/param.service
 create mode 100644 recipes-openharmony/openharmony/files/param.service.license

diff --git a/recipes-openharmony/openharmony/files/param.service b/recipes-openharmony/openharmony/files/param.service
new file mode 100644
index 00000000..63b63434
--- /dev/null
+++ b/recipes-openharmony/openharmony/files/param.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=OpenHarmony Param Service
+Requires=openharmony-preinit.service
+After=openharmony-preinit.service
+
+[Service]
+Type=exec
+ExecStartPre=install -m 755 -d /dev/unix/socket
+ExecStart=/usr/bin/param_service /system/etc/ohos.para
+
+[Install]
+WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/param.service.license b/recipes-openharmony/openharmony/files/param.service.license
new file mode 100644
index 00000000..98a0b3f4
--- /dev/null
+++ b/recipes-openharmony/openharmony/files/param.service.license
@@ -0,0 +1,3 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: Apache-2.0
diff --git a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
index e66ae548..f03f44e3 100644
--- a/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
+++ b/recipes-openharmony/openharmony/openharmony-standard_3.0.bb
@@ -1496,6 +1496,13 @@ RDEPENDS:${PN}-hdc += "${PN}-libutils ${PN}-syspara libcrypto"
 RDEPENDS:${PN} += "${PN}-hdc"
 
 PACKAGES =+ "${PN}-param-service"
+SYSTEMD_PACKAGES += "${PN}-param-service"
+SYSTEMD_SERVICE:${PN}-param-service = "param.service"
+SRC_URI += "file://param.service"
+do_install:append() {
+    install -d ${D}/${systemd_unitdir}/system
+    install -m 644 ${WORKDIR}/param.service ${D}${systemd_unitdir}/system/
+}
 FILES:${PN}-param-service = " \
     ${bindir}/getparam \
     ${bindir}/setparam \
-- 
GitLab