updates for bookworm NetworkManager setup

This commit is contained in:
2026-03-10 10:03:15 -04:00
parent 926e7210bc
commit 7879d1dee0
4 changed files with 102 additions and 95 deletions

View File

@@ -9,39 +9,41 @@ then
exit 1
fi
source /etc/piwifiap.conf
source /etc/piwifiap/piwifiap.conf
newppok=0
while [ "$newppok" -ne 1 ]
wappassok="no"
while [[ "$wappassok" == "no" ]]
do
echo -n "New passphrase: "
read newpp
newpplen=`echo -n $newpp | wc -m`
if [ "$newpp" = "" -o "$newpplen" -lt 8 ]
then
echo "Passphrase didn't satisfy requirements. Try again or hit <ctrl>-c to abort."
else
newppok=1
fi
echo "You will need to set a passphrase for this access point. It should"
echo "be at least 8 characters in length and cannot be blank."
echo -n "Please enter the desired passphrase for this access point: "
read wappass
wappasslen=$(echo -n $wappass | wc -m)
if [[ "$wappass" == "" || $wappasslen -lt 8 ]]
then
echo "Passphrase doesn't satisfy requirements above. Try again."
else
wappassok="yes"
fi
done
if [ "$network_system" = "systemd-networkd" ]
then
sed -i "/wpa_passphrase=.*/c wpa_passphrase=$newpp" /etc/hostapd/hostapd.conf
systemctl restart hostapd
elif [ "$network_system" = "NetworkManager" ]
then
nmcli con down piwifi-ap
nmcli con mod piwifi-ap wifi-sec.psk "$newpp"
nmcli con up piwifi-ap
else
echo "Unable to determine what type of network configuration (systemd-networkd"
echo "or NetworkManager) your system uses."
echo "Cannot modify wireless access point parameters."
exit 2
fi
sed -i 's,'wappass=.*','wappass="\"$newpp\""',' /etc/piwifiap.conf
case "$network_system" in
"systemd-networkd")
sed -i "/wpa_passphrase=.*/c wpa_passphrase=$wappass" /etc/hostapd/hostapd.conf
systemctl restart hostapd
sed -i 's|'wappass=.*'|'wappass="\'$wappass\'"'|' /etc/piwifiap/piwifiap.conf
sed -i 's|'802-11-wireless-security.psk:.*'|'802-11-wireless-security.psk:$wappass'|' /etc/piwifiap/piwifiap.secret
;;
"NetworkManager")
nmcli con down piwifi-hotspot
sed -i 's|'wappass=.*'|'wappass="\'$wappass\'"'|' /etc/piwifiap/piwifiap.conf
sed -i 's|'802-11-wireless-security.psk:.*'|'802-11-wireless-security.psk:$wappass'|' /etc/piwifiap/piwifiap.secret
nmcli con up piwifi-hotspot passwd-file /etc/piwifiap/piwifiap.secret
;;
*)
echo "Unable to determine what type of network configuration (systemd-networkd"
echo "or NetworkManager) your system uses."
echo "Cannot modify wireless access point parameters."
exit 2
;;
esac