summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-07-13 08:40:59 +0300
committerLars Wirzenius <liw@liw.fi>2023-07-13 08:40:59 +0300
commitc2cffd5635379a49c3451c08c5d0f545281c61e8 (patch)
tree6ba356807f0a9f9b004b2cd5bc60253860df8e1a
parente8e737603e44d4077f81798d16010210114aa468 (diff)
downloadv-i-c2cffd5635379a49c3451c08c5d0f545281c61e8.tar.gz
feat(configure-installer): allow user to pre-configure a wifi
Sponsored-by: author
-rwxr-xr-xconfigure-installer16
1 files changed, 16 insertions, 0 deletions
diff --git a/configure-installer b/configure-installer
index fce3695..b11cc6e 100755
--- a/configure-installer
+++ b/configure-installer
@@ -29,6 +29,8 @@ class Config:
"user_ca_pub_file": None,
"user_ca_pub_cmd": None,
"cmd_as_user": None,
+ "wifi_name": None,
+ "wifi_password": None,
}
exandable = [
@@ -65,6 +67,9 @@ class Config:
def host_cert(self, hostname):
return self._get_from_file_or_cmd("host_cert", "host certificate", hostname)
+ def wifi(self):
+ return self.config.get("wifi_name"), self.config.get("wifi_password")
+
def _get_from_file_or_cmd(self, prefix, msg, hostname):
log("_get: A")
filename = self.config.get(f"{prefix}_file")
@@ -206,6 +211,16 @@ def user_ca(config, mp):
write(cakeys, ca_key, 0, 0, 0o644)
+def wifi(config, mp):
+ (name, password) = config.wifi()
+ if name and password:
+ data = f"[Security]\nPassphrase={password}\n"
+ filename = f"{mp}/var/lib/iwd/{name}.psk"
+ dirname = os.path.dirname(filename)
+ os.makedirs(dirname, exist_ok=True)
+ write(filename, data, 0, 0, 0o600)
+
+
def main():
log("configure-image starting")
@@ -236,6 +251,7 @@ def main():
host_id(config, mp, args.hostname)
authorized_keys(config, mp)
user_ca(config, mp)
+ wifi(config, mp)
finally:
unmount(mp)
os.rmdir(mp)