wifi: Fix installation
This commit is contained in:
parent
8179433c41
commit
ea9a75d495
4 changed files with 34 additions and 37 deletions
|
@ -21,9 +21,38 @@ in
|
|||
temp="$(mktemp --directory --suffix="-install-wifi")"
|
||||
cd "$temp"
|
||||
|
||||
bus_get() {
|
||||
sudo busctl -j get-property "fi.w1.wpa_supplicant1" "$@"
|
||||
}
|
||||
|
||||
network_config() {
|
||||
bus_get "$1" "fi.w1.wpa_supplicant1.Network" Properties | jq '.data | keys[] as $k | "\($k)=\(.[$k] | .data)"' -r | sort
|
||||
}
|
||||
|
||||
# Temporarily create a new network to get defaults
|
||||
default_id="$(wpa_cli add_network | tail -n1)"
|
||||
network_config "/fi/w1/wpa_supplicant1/Interfaces/0/Networks/$default_id" > default.conf
|
||||
wpa_cli remove_network "$default_id"
|
||||
|
||||
networks_config() {
|
||||
# List all interfaces
|
||||
bus_get "/fi/w1/wpa_supplicant1" "fi.w1.wpa_supplicant1" Interfaces | jq '.data[]' -r | while read -r interface
|
||||
do
|
||||
# List all networks
|
||||
bus_get "$interface" "fi.w1.wpa_supplicant1.Interface" Networks | jq '.data[]' -r | while read -r network
|
||||
do
|
||||
# Show configuration
|
||||
echo "[$network]"
|
||||
network_config "$network" > current.conf
|
||||
comm -23 current.conf default.conf
|
||||
rm current.conf
|
||||
echo
|
||||
done
|
||||
done
|
||||
}
|
||||
|
||||
# Save config for diffing later
|
||||
wpa_cli save_config > /dev/null
|
||||
cat <(sudo cat /run/wpa_supplicant/wpa_supplicant.conf) > old.conf
|
||||
networks_config > old.conf
|
||||
|
||||
# Export Wi-Fi config from pass
|
||||
${importScript}
|
||||
|
@ -38,11 +67,10 @@ in
|
|||
sudo ${applyScript}
|
||||
|
||||
# Diff the config
|
||||
wpa_cli save_config > /dev/null
|
||||
cat <(sudo cat /run/wpa_supplicant/wpa_supplicant.conf) > new.conf
|
||||
networks_config > new.conf
|
||||
diff --color=auto -U 5 old.conf new.conf
|
||||
|
||||
rm old.conf new.conf
|
||||
rm default.conf old.conf new.conf
|
||||
cd /
|
||||
rmdir "$temp"
|
||||
'';
|
||||
|
@ -58,17 +86,6 @@ in
|
|||
extraConfig = ''
|
||||
country=NL
|
||||
'';
|
||||
# Public wireless networks
|
||||
networks = lib.genAttrs [
|
||||
"CDWiFi"
|
||||
"EurostarTrainsWiFi"
|
||||
"_SNCF gare-gratuit"
|
||||
"_SNCF_WIFI_INOUI"
|
||||
"Wifi in de trein"
|
||||
"WiFi in de trein"
|
||||
"_WIFI_LYRIA"
|
||||
"WIFIonICE"
|
||||
] (ssid: { });
|
||||
userControlled.enable = true; # Allow some control with wpa_cli
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue