From 33fee543727206f8cd730051a952b85d8305e839 Mon Sep 17 00:00:00 2001
From: Thierry Escande <thierry.escande@huawei.com>
Date: Wed, 28 Sep 2022 16:50:57 +0200
Subject: [PATCH] openharmony-3.0: Turn OpenHarmony systemd units into dummy
 services

This change turns the OpenHarmony systemd services into dummy services
that doesn't start them. Instead, the preinit script will check for
these services state and start the corresponding services if their
systemd unit are enabled.

Signed-off-by: Thierry Escande <thierry.escande@huawei.com>
---
 .../openharmony/files/accountmgr.service               |  8 +++-----
 recipes-openharmony/openharmony/files/appspawn.service | 10 +++-------
 .../openharmony/files/deviceauth.service               |  9 +++------
 .../openharmony/files/distributed_data.service         |  9 +++------
 .../openharmony/files/distributedsched.service         |  8 +++-----
 recipes-openharmony/openharmony/files/dsoftbus.service |  8 +++-----
 .../openharmony/files/faultloggerd.service             |  8 +++-----
 recipes-openharmony/openharmony/files/hilogd.service   |  9 +++------
 recipes-openharmony/openharmony/files/huks.service     |  8 +++-----
 .../openharmony/files/inputmethod.service              |  8 +++-----
 recipes-openharmony/openharmony/files/installs.service |  9 +++------
 recipes-openharmony/openharmony/files/param.service    |  8 +++-----
 recipes-openharmony/openharmony/files/samgr.service    |  8 +++-----
 recipes-openharmony/openharmony/files/time.service     |  8 +++-----
 14 files changed, 42 insertions(+), 76 deletions(-)

diff --git a/recipes-openharmony/openharmony/files/accountmgr.service b/recipes-openharmony/openharmony/files/accountmgr.service
index d10e896d..8de6abe0 100644
--- a/recipes-openharmony/openharmony/files/accountmgr.service
+++ b/recipes-openharmony/openharmony/files/accountmgr.service
@@ -1,12 +1,10 @@
 [Unit]
 Description=OpenHarmony Account Manager service
-Requires=appspawn.service
-After=appspawn.service
 
 [Service]
-Type=exec
-# should run as system:system
-ExecStart=/usr/bin/sa_main /system/profile/accountmgr.xml
+Type=oneshot
+ExecStart=/bin/echo "OpenHarmony SystemAbilityFramework Service"
+RemainAfterExit=yes
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/appspawn.service b/recipes-openharmony/openharmony/files/appspawn.service
index 16635e01..e299f49c 100644
--- a/recipes-openharmony/openharmony/files/appspawn.service
+++ b/recipes-openharmony/openharmony/files/appspawn.service
@@ -1,14 +1,10 @@
 [Unit]
 Description=OpenHarmony Appspawn service
-Requires=samgr.service
-After=samgr.service
 
 [Service]
-Type=exec
-# Delay execution by 2 secs after samgr.service
-ExecStartPre=/bin/sleep 2
-ExecStartPre=mkdir -p /data/app
-ExecStart=/usr/bin/appspawn
+Type=oneshot
+ExecStart=/bin/echo "OpenHarmony Appspawn Service"
+RemainAfterExit=yes
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/deviceauth.service b/recipes-openharmony/openharmony/files/deviceauth.service
index 09c7d134..aab97854 100644
--- a/recipes-openharmony/openharmony/files/deviceauth.service
+++ b/recipes-openharmony/openharmony/files/deviceauth.service
@@ -1,13 +1,10 @@
 [Unit]
 Description=OpenHarmony Device Authentication daemon
-Requires=samgr.service
-After=samgr.service
 
 [Service]
-Type=exec
-# Delay execution by 2 secs after samgr.service
-ExecStartPre=/bin/sleep 2
-ExecStart=/usr/bin/deviceauth_service
+Type=oneshot
+ExecStart=/bin/echo "OpenHarmony Device Authentication Service"
+RemainAfterExit=yes
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/distributed_data.service b/recipes-openharmony/openharmony/files/distributed_data.service
index 5abbc235..4ce37814 100644
--- a/recipes-openharmony/openharmony/files/distributed_data.service
+++ b/recipes-openharmony/openharmony/files/distributed_data.service
@@ -1,13 +1,10 @@
 [Unit]
 Description=OpenHarmony Distributed Data service
-Requires=appspawn.service
-After=appspawn.service
 
 [Service]
-Type=exec
-CapabilityBoundingSet=CAP_DAC_READ_SEARCH
-# should run as system:system
-ExecStart=/usr/bin/sa_main /system/profile/distributeddata.xml
+Type=oneshot
+ExecStart=/bin/echo "OpenHarmony Distributed Data Service"
+RemainAfterExit=yes
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/distributedsched.service b/recipes-openharmony/openharmony/files/distributedsched.service
index 3464d205..578c42b8 100644
--- a/recipes-openharmony/openharmony/files/distributedsched.service
+++ b/recipes-openharmony/openharmony/files/distributedsched.service
@@ -1,12 +1,10 @@
 [Unit]
 Description=OpenHarmony Distributed Schedule service
-Requires=appspawn.service
-After=appspawn.service
 
 [Service]
-Type=exec
-# should run as system:system
-ExecStart=/usr/bin/sa_main /system/profile/distributedsched.xml
+Type=oneshot
+ExecStart=/bin/echo "OpenHarmony Distributed Schedule Service"
+RemainAfterExit=yes
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/dsoftbus.service b/recipes-openharmony/openharmony/files/dsoftbus.service
index 4eb198de..d9728659 100644
--- a/recipes-openharmony/openharmony/files/dsoftbus.service
+++ b/recipes-openharmony/openharmony/files/dsoftbus.service
@@ -1,12 +1,10 @@
 [Unit]
 Description=OpenHarmony DSoftBus services
-Requires=appspawn.service
-After=appspawn.service
 
 [Service]
-Type=exec
-# should run as system:system
-ExecStart=/usr/bin/sa_main /system/profile/softbus_server.xml
+Type=oneshot
+ExecStart=/bin/echo "OpenHarmony DSoftBus Service"
+RemainAfterExit=yes
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/faultloggerd.service b/recipes-openharmony/openharmony/files/faultloggerd.service
index e5017bdf..72d74493 100644
--- a/recipes-openharmony/openharmony/files/faultloggerd.service
+++ b/recipes-openharmony/openharmony/files/faultloggerd.service
@@ -1,12 +1,10 @@
 [Unit]
 Description=OpenHarmony FaultLogger daemon
-Requires=openharmony-preinit.service
-After=openharmony-preinit.service
 
 [Service]
-Type=exec
-ExecStartPre=install -m 775 -d /data/log/faultlog /data/log/faultlog/faultlogger /data/log/faultlog/temp/
-ExecStart=/usr/bin/faultloggerd
+Type=oneshot
+ExecStart=/bin/echo "OpenHarmony FaultLogger Service"
+RemainAfterExit=yes
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/hilogd.service b/recipes-openharmony/openharmony/files/hilogd.service
index 657dee96..06b61ed5 100644
--- a/recipes-openharmony/openharmony/files/hilogd.service
+++ b/recipes-openharmony/openharmony/files/hilogd.service
@@ -1,13 +1,10 @@
 [Unit]
 Description=OpenHarmony hilog daemon
-Requires=param.service
-After=param.service
 
 [Service]
-Type=exec
-ExecStartPre=mkdir -p /dev/unix/socket
-ExecStartPre=mkdir -p /data/log/hilog
-ExecStart=/usr/bin/hilogd
+Type=oneshot
+ExecStart=/bin/echo "OpenHarmony hilog Service"
+RemainAfterExit=yes
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/huks.service b/recipes-openharmony/openharmony/files/huks.service
index 09bec8b9..9c4c39b6 100644
--- a/recipes-openharmony/openharmony/files/huks.service
+++ b/recipes-openharmony/openharmony/files/huks.service
@@ -1,12 +1,10 @@
 [Unit]
 Description=OpenHarmony huks service
-Requires=appspawn.service
-After=appspawn.service
 
 [Service]
-Type=exec
-# should run as system:system
-ExecStart=/usr/bin/sa_main /system/profile/huks_service.xml
+Type=oneshot
+ExecStart=/bin/echo "OpenHarmony Huks Service"
+RemainAfterExit=yes
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/inputmethod.service b/recipes-openharmony/openharmony/files/inputmethod.service
index 5d4ae0a8..3e15e3e2 100644
--- a/recipes-openharmony/openharmony/files/inputmethod.service
+++ b/recipes-openharmony/openharmony/files/inputmethod.service
@@ -1,12 +1,10 @@
 [Unit]
 Description=OpenHarmony input method services
-Requires=appspawn.service
-After=appspawn.service
 
 [Service]
-Type=exec
-# should run as system:system
-ExecStart=/usr/bin/sa_main /system/profile/inputmethod_service.xml
+Type=oneshot
+ExecStart=/bin/echo "OpenHarmony Input Method Service"
+RemainAfterExit=yes
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/installs.service b/recipes-openharmony/openharmony/files/installs.service
index 8de5e169..b47eb4f2 100644
--- a/recipes-openharmony/openharmony/files/installs.service
+++ b/recipes-openharmony/openharmony/files/installs.service
@@ -1,13 +1,10 @@
 [Unit]
 Description=OpenHarmony Installs service
-Requires=samgr.service
-After=samgr.service
 
 [Service]
-Type=exec
-# Delay execution by 2 secs after samgr.service
-ExecStartPre=/bin/sleep 2
-ExecStart=/usr/bin/installs
+Type=oneshot
+ExecStart=/bin/echo "OpenHarmony Installs Service"
+RemainAfterExit=yes
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/param.service b/recipes-openharmony/openharmony/files/param.service
index 63b63434..aa8b6ce6 100644
--- a/recipes-openharmony/openharmony/files/param.service
+++ b/recipes-openharmony/openharmony/files/param.service
@@ -1,12 +1,10 @@
 [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
+Type=oneshot
+ExecStart=/bin/echo "OpenHarmony Param Service"
+RemainAfterExit=yes
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/samgr.service b/recipes-openharmony/openharmony/files/samgr.service
index 195350f6..bb66c394 100644
--- a/recipes-openharmony/openharmony/files/samgr.service
+++ b/recipes-openharmony/openharmony/files/samgr.service
@@ -1,12 +1,10 @@
 [Unit]
 Description=OpenHarmony SystemAbilityFramework service
-Requires=param.service
-After=param.service
 
 [Service]
-Type=exec
-ExecStartPre=install -m 755 -d /data/sadata_se /data/sadata_se/samgr
-ExecStart=/usr/bin/samgr
+Type=oneshot
+ExecStart=/bin/echo "OpenHarmony SystemAbilityFramework Service"
+RemainAfterExit=yes
 
 [Install]
 WantedBy=multi-user.target
diff --git a/recipes-openharmony/openharmony/files/time.service b/recipes-openharmony/openharmony/files/time.service
index 41e94446..f87cdf88 100644
--- a/recipes-openharmony/openharmony/files/time.service
+++ b/recipes-openharmony/openharmony/files/time.service
@@ -1,12 +1,10 @@
 [Unit]
 Description=OpenHarmony Time service
-Requires=appspawn.service
-After=appspawn.service
 
 [Service]
-Type=exec
-# should run as system:system
-ExecStart=/usr/bin/sa_main /system/profile/time_service.xml
+Type=oneshot
+ExecStart=/bin/echo "OpenHarmony Time Service"
+RemainAfterExit=yes
 
 [Install]
 WantedBy=multi-user.target
-- 
GitLab