On Thursday, March 12, 2020 at 5:48:39 PM UTC+1, Q. Gylstorff wrote:
From: Quirin Gylstorff <quirin....@siemens.com>

Systemd waits with starting service until a oneshot is finished this leads
to a race condition if you try to restart a service in a oneshot.


very good catch!
 
"Behavior of oneshot is similar to simple; however, the service manager will consider
the unit started after the main process exits. It will then start follow-up units.
RemainAfterExit= is particularly useful for this type of service.  Type=oneshot is the
implied default if neither Type= nor ExecStart= are specified."[1]

[1]: man systemd.service

Signed-off-by: Quirin Gylstorff <quirin....@siemens.com>
---
 .../sshd-regen-keys/files/sshd-regen-keys.service               | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/meta/recipes-support/sshd-regen-keys/files/sshd-regen-keys.service b/meta/recipes-support/sshd-regen-keys/files/sshd-regen-keys.service
index a05e1a9..4c4dc0e 100644
--- a/meta/recipes-support/sshd-regen-keys/files/sshd-regen-keys.service
+++ b/meta/recipes-support/sshd-regen-keys/files/sshd-regen-keys.service
@@ -7,7 +7,7 @@ Before=shutdown.target sshd.service
 ConditionPathIsReadWrite=/etc
 
 [Service]
-Type=oneshot
+Type=simple
 RemainAfterExit=yes
 Environment=DEBIAN_FRONTEND=noninteractive
 ExecStart=/usr/sbin/sshd-regen-keys.sh
--
2.20.1