<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On 7 May 2017 at 02:33, Joshua Watt <span dir="ltr"><<a href="mailto:jpewhacker@gmail.com" target="_blank">jpewhacker@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":1ij" class="a3s aXjCH m15be08ab5931b842">+if [ ! -f "$NAME" ]; then<br>
+ echo " generating ssh $TYPE key..."<br>
+ ssh-keygen -q -f "${NAME}.tmp" -N '' -t $TYPE<br>
+<br>
+ # Sync to ensure data is written to temp file before renaming<br>
+ sync<br>
+<br>
+ # Move (Atomically rename) files<br>
+ # Rename the .pub file first, since the check that triggers a<br>
+ # key generation is based on the private file.<br>
+ mv -f "${NAME}.tmp.pub" "${NAME}.pub"<br>
+ sync<br>
+<br>
+ mv -f "${NAME}.tmp" "${NAME}"<br>
+ sync<br>
+fi<br><br></div></blockquote><div><br></div><div>All of these syncs seem quite enthusiastic, are they really needed? Writing the file to a temporary name and then mving it to the real name should result in either no file or a complete file in the event of power loss, surely?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":1ij" class="a3s aXjCH m15be08ab5931b842">
diff --git a/meta/recipes-connectivity/<wbr>openssh/openssh/sshdgenkeys.<wbr>service b/meta/recipes-connectivity/<wbr>openssh/openssh/sshdgenkeys.<wbr>service<br>
index 148e6ad..af56404 100644<br>
--- a/meta/recipes-connectivity/<wbr>openssh/openssh/sshdgenkeys.<wbr>service<br>
+++ b/meta/recipes-connectivity/<wbr>openssh/openssh/sshdgenkeys.<wbr>service<br>
@@ -1,22 +1,14 @@<br>
[Unit]<br>
Description=OpenSSH Key Generation<br>
RequiresMountsFor=/var /run<br>
-ConditionPathExists=!/var/<wbr>run/ssh/ssh_host_rsa_key<br>
-ConditionPathExists=!/var/<wbr>run/ssh/ssh_host_dsa_key<br>
-ConditionPathExists=!/var/<wbr>run/ssh/ssh_host_ecdsa_key<br>
-ConditionPathExists=!/var/<wbr>run/ssh/ssh_host_ed25519_key<br>
-ConditionPathExists=!/etc/<wbr>ssh/ssh_host_rsa_key<br>
-ConditionPathExists=!/etc/<wbr>ssh/ssh_host_dsa_key<br>
-ConditionPathExists=!/etc/<wbr>ssh/ssh_host_ecdsa_key<br>
-ConditionPathExists=!/etc/<wbr>ssh/ssh_host_ed25519_key</div></blockquote></div><br>Can you not continue to use ConditionPathExists to only run this unit if it needs to run? You can prepend the argument with | to make them logical OR instead of logical AND, if I'm reading this documentation correctly.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Ross</div></div>