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,19 +9,21 @@ then
exit 1 exit 1
fi fi
source /etc/piwifiap.conf source /etc/piwifiap/piwifiap.conf
if [ "$network_system" = "systemd-networkd" ] case "$network_system" in
then "systemd-networkd")
systemctl stop hostapd systemctl stop hostapd
systemctl disable hostapd systemctl disable hostapd
elif [ "$network_system" = "NetworkManager" ] ;;
then "NetworkManager")
nmcli con down piwifi-ap nmcli con down piwifi-hotspot
nmcli con mod piwifi-ap autoconnect no nmcli con mod piwifi-hotspot autoconnect no
else ;;
*)
echo "Unable to determine what type of network configuration (systemd-networkd" echo "Unable to determine what type of network configuration (systemd-networkd"
echo "or NetworkManager) your system uses." echo "or NetworkManager) your system uses."
echo "Cannot disable wireless access point." echo "Cannot disable wireless access point."
exit 2 exit 2
fi ;;
esac

View File

@@ -9,20 +9,21 @@ then
exit 1 exit 1
fi fi
source /etc/piwifiap.conf source /etc/piwifiap/piwifiap.conf
if [ "$network_system" = "systemd-networkd" ] case "$network_system" in
then "systemd-networkd")
systemctl enable hostapd systemctl enable hostapd
systemctl start hostapd systemctl start hostapd
elif [ "$network_system" = "NetworkManager" ] ;;
then "NetworkManager")
nmcli con mod piwifi-ap autoconnect yes nmcli con mod piwifi-hotspot autoconnect yes
nmcli con up piwifi-ap nmcli con up piwifi-hotspot passwd-file /etc/piwifiap/piwifiap.secret
else ;;
*)
echo "Unable to determine what type of network configuration (systemd-networkd" echo "Unable to determine what type of network configuration (systemd-networkd"
echo "or NetworkManager) your system uses." echo "or NetworkManager) your system uses."
echo "Cannot enable wireless access point." echo "Cannot enable wireless access point."
exit 2 exit 2
fi ;;
esac

View File

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

View File

@@ -9,37 +9,39 @@ then
exit 1 exit 1
fi fi
source /etc/piwifiap.conf source /etc/piwifiap/piwifiap.conf
newssidok=0 wapssidok="no"
while [ "$newssidok" -ne 1 ] while [[ "$wapssidok" == "no" ]]
do do
echo -n "New SSID: " echo "This access point will need an SSID. This is what will appear"
read newssid echo "as the name of this terminal when other devices connect."
if [ "$newssid" = "" ] echo -n "Please enter the desired SSID for this access point: "
read wapssid
if [[ "$wapssid" = "" ]]
then then
echo "SSID cannot be blank. Try again or hit <ctrl>-c to abort." echo "SSID cannot be blank. Try again."
else else
newssidok=1 wapssidok="yes"
fi fi
done done
if [ "$network_system" = "systemd-networkd" ] case "$network_system" in
then "systemd-networkd")
sed -i "/ssid=.*/c ssid=$newssid" /etc/hostapd/hostapd.conf sed -i "/ssid=.*/c ssid=$wapssid" /etc/hostapd/hostapd.conf
systemctl restart hostapd systemctl restart hostapd
elif [ "$network_system" = "NetworkManager" ] sed -i 's|'wapssid=.*'|'wapssid="\'$wapssid\'"'|' /etc/piwifiap/piwifiap.conf
then ;;
nmcli con down piwifi-ap "NetworkManager")
nmcli con mod piwifi-ap ssid "$newssid" nmcli con down piwifi-hotspot
nmcli con up piwifi-ap nmcli con mod piwifi-hotspot ssid "$wapssid"
else nmcli con up piwifi-hotspot passwd-file /etc/piwifiap/piwifiap.secret
sed -i 's|'wapssid=.*'|'wapssid="\'$wapssid\'"'|' /etc/piwifiap/piwifiap.conf
;;
*)
echo "Unable to determine what type of network configuration (systemd-networkd" echo "Unable to determine what type of network configuration (systemd-networkd"
echo "or NetworkManager) your system uses." echo "or NetworkManager) your system uses."
echo "Cannot modify wireless access point parameters." echo "Cannot modify wireless access point parameters."
exit 2 exit 2
fi ;;
esac
sed -i 's,'wapssid=.*','wapssid="\"$newssid\""',' /etc/piwifiap.conf