backstory
in the linux landscape, your network managers historically tended to be one of 2 options:
- NetworkManager
- connman
NetworkManager had a pretty staunch dependency graph when I first started looking at enabling it in a Qt based stack. connman was pushed by Meego/Maemo/Qt, and is configurable from Qt when several layers are in play. (I last looked at this over 7 years ago so I am not going to dredge up the layers in question.)
at some point (2016?) IWD appeared, written by the author of connman, and appeared to address our networking needs neatly while exposing this functionality via a sane dbus interace. This appeared to play well with systemd, which did a fairly good job handling the ethernet portion along with general carrier management, and advertizes this again via dbus, allowing one to track/drive both wifi and broader network state
migrating from connman to iwd
#!/usr/bin/env bash
set -o nounset
#set -o pipefail
#set -o errexit
#set -o xtrace
run_once_file=/data/connman-iwd-migration-complete
iwd_data_path=/var/lib/iwd
connman_data_path=/var/lib/connman
iwd_known_network_path=/var/lib/iwd/.known_network.freq
if [[ -f ${run_once_file} ]]; then
exit 0
fi
convert_connman_to_iwd() {
connman_file=$1
name=$(cat ${connman_file} | grep Name= | cut -f2 -d=)
passphrase=$(cat ${connman_file} | grep Passphrase= | cut -f2 -d=)
frequency=$(cat ${connman_file} | grep Frequency= | cut -f2 -d=)
extension=psk
if [[ -z ${passphrase} ]]; then
extension=open
fi
iwd_file_path=${iwd_data_path}/${name}.${extension}
if [[ -n ${passphrase} ]]; then
echo "[Security]" > "${iwd_file_path}"
echo "Passphrase=${passphrase}" >> "${iwd_file_path}"
else
touch ${iwd_file_path}
fi
echo "[$(uuidgen)]" >> ${iwd_known_network_path}
echo "name=${iwd_file_path}" >> ${iwd_known_network_path}
echo "list=${frequency}" >> ${iwd_known_network_path}
}
if [[ -d ${connman_data_path} ]]; then
mkdir -p ${iwd_data_path}
for connman_data in $(find ${connman_data_path}/wifi_*/settings); do
convert_connman_to_iwd ${connman_data}
done
fi
touch ${run_once_file}
sync
exit 0