]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Don't fail if we can't retrieve default credentials
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 1 May 2023 07:45:06 +0000 (09:45 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 1 May 2023 07:45:06 +0000 (09:45 +0200)
Let's not fail if we can't run ssh-add or timedatectl to get the
SSH key or timezone.

mkosi/config.py

index 2eef4e870bf7cd68c18689cc2b558c9e51b5d37d..5bafdacfde67c8eee0c8fd072f55eb682009acc9 100644 (file)
@@ -1836,8 +1836,10 @@ def load_credentials(args: argparse.Namespace) -> dict[str, str]:
             ["timedatectl", "show", "-p", "Timezone", "--value"],
             text=True,
             stdout=subprocess.PIPE,
+            check=False,
         ).stdout.strip()
-        creds["firstboot.timezone"] = tz
+        if tz:
+            creds["firstboot.timezone"] = tz
 
     if "firstboot.locale" not in creds:
         creds["firstboot.locale"] = "C.UTF-8"
@@ -1851,8 +1853,10 @@ def load_credentials(args: argparse.Namespace) -> dict[str, str]:
             text=True,
             stdout=subprocess.PIPE,
             env=os.environ,
+            check=False,
         ).stdout.strip()
-        creds["ssh.authorized_keys.root"] = key
+        if key:
+            creds["ssh.authorized_keys.root"] = key
 
     return creds