iwd: fix secret installation

This commit is contained in:
Colin 2023-05-14 10:21:16 +00:00
parent 38d921dbc9
commit 51ca72da84
2 changed files with 10 additions and 8 deletions

View File

@ -9,7 +9,7 @@
generated.script.script = builtins.readFile ../../../../scripts/install-iwd + '' generated.script.script = builtins.readFile ../../../../scripts/install-iwd + ''
touch "/var/lib/iwd/.secrets.psk.stamp" touch "/var/lib/iwd/.secrets.psk.stamp"
''; '';
generated.script.scriptArgs = [ "/run/secrets/iwd" "/var/lib/iwd" ]; generated.script.scriptArgs = [ "/run/secrets/net" "/var/lib/iwd" ];
}; };
}; };
} }

View File

@ -1,5 +1,5 @@
#!/bin/sh #!/bin/sh
# usage: install-iwd.sh <source_dir> <dest_dir> # usage: install-iwd <source_dir> <dest_dir>
# source_dir contains plain-text .psk files of any filename. # source_dir contains plain-text .psk files of any filename.
# for each file, this extracts the SSID and creates a symlink in dest_dir which # for each file, this extracts the SSID and creates a symlink in dest_dir which
# points to the original file, using the SSID name as filename. # points to the original file, using the SSID name as filename.
@ -11,10 +11,12 @@ src_dir="$1"
dest_dir="$2" dest_dir="$2"
for f in $(ls "$src_dir") for f in $(ls "$src_dir")
do do
ssid=$(sed -rn 's/# SSID=(.*)/\1/p' "$src_dir/$f") if [ -f "$src_dir/$f" ]; then
# not sure that iwd can deal with un-writeable symlinks ssid=$(sed -rn 's/# SSID=(.*)/\1/p' "$src_dir/$f")
# ln -sf "$src_dir/$f" "$dest_dir/$ssid.psk" # not sure that iwd can deal with un-writeable symlinks
cp "$src_dir/$f" "$dest_dir/$ssid.psk" # ln -sf "$src_dir/$f" "$dest_dir/$ssid.psk"
# not strictly necessary, but iwd does default to rw cp "$src_dir/$f" "$dest_dir/$ssid.psk"
chmod 600 "$dest_dir/$ssid.psk" # not strictly necessary, but iwd does default to rw
chmod 600 "$dest_dir/$ssid.psk"
fi
done done