Changes for bookworm NetworkManager
This commit is contained in:
77
ap-setup.sh
77
ap-setup.sh
@@ -40,15 +40,16 @@ function get_ap_params() {
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
# Save parameters in config file
|
# Save parameters in config file
|
||||||
sed -i 's,'wapssid=.*','wapssid="\"$wapssid\""',' /etc/piwifiap.conf
|
sed -i 's|'wapssid=.*'|'wapssid="\'$wapssid\'"'|' /etc/piwifiap/piwifiap.conf
|
||||||
sed -i 's,'wappass=.*','wappass="\"$wappass\""',' /etc/piwifiap.conf
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
function config_systemd-networkd() {
|
function config_systemd-networkd() {
|
||||||
echo "Configuring as wireless access point using systemd-networkd."
|
echo "Configuring as wireless access point using systemd-networkd."
|
||||||
get_ap_params
|
get_ap_params
|
||||||
# Save network system in config file
|
# Save network system type in config file
|
||||||
sed -i 's,'network_system=.*','network_system="\"systemd-networkd\""',' /etc/piwifiap.conf
|
sed -i 's,'network_system=.*','network_system="\"systemd-networkd\""',' /etc/piwifiap/piwifiap.conf
|
||||||
|
|
||||||
apt install hostapd
|
apt install hostapd
|
||||||
systemctl unmask hostapd
|
systemctl unmask hostapd
|
||||||
@@ -97,19 +98,34 @@ function config_NetworkManager() {
|
|||||||
get_ap_params
|
get_ap_params
|
||||||
|
|
||||||
# Clean up a possible failed previous attempt
|
# Clean up a possible failed previous attempt
|
||||||
nmcli con del piwifi-ap >/dev/null 2>&1
|
nmcli con del piwifi-hotspot >/dev/null 2>&1
|
||||||
nmcli con del piwifi-ethernet >/dev/null 2>&1
|
nmcli con del piwifi-ethernet >/dev/null 2>&1
|
||||||
nmcli con del piwifi-apbridge >/dev/null 2>&1
|
nmcli con del piwifi-bridge >/dev/null 2>&1
|
||||||
|
|
||||||
|
|
||||||
# Save network system in config file
|
# Save network system type in config file
|
||||||
sed -i 's,'network_system=.*','network_system="\"NetworkManager\""',' /etc/piwifiap.conf
|
sed -i 's|'network_system=.*'|'network_system="\"NetworkManager\""'|' /etc/piwifiap/piwifiap.conf
|
||||||
|
|
||||||
|
# create bridge interface
|
||||||
|
nmcli con add type bridge con-name piwifi-bridge ifname bridge0
|
||||||
|
|
||||||
nmcli device wifi hotspot ssid $wapssid password $wappass
|
# add ethernet to bridge
|
||||||
nmcli connection add type bridge con-name 'Bridge' ifname bridge0
|
nmcli con add type ethernet slave-type bridge con-name piwifi-ethernet ifname eth0 master bridge0
|
||||||
nmcli connection add type ethernet slave-type bridge con-name 'Ethernet' ifname eth0 master bridge0
|
|
||||||
nmcli connection modify 'Hotspot' master bridge0
|
# create access point
|
||||||
nmcli connection up Bridge
|
nmcli con add type wifi ifname wlan0 mode ap con-name piwifi-hotspot ssid $wapssid
|
||||||
nmcli connection up Hotspot
|
nmcli con modify piwifi-hotspot wifi-sec.key-mgmt wpa-psk
|
||||||
|
nmcli con modify piwifi-hotspot 802-11-wireless.band bg
|
||||||
|
|
||||||
|
# add wifi to bridge
|
||||||
|
nmcli con modify piwifi-hotspot master bridge0 slave-type bridge
|
||||||
|
|
||||||
|
# activate bridge
|
||||||
|
nmcli con up piwifi-bridge
|
||||||
|
|
||||||
|
# activite wifi
|
||||||
|
nmcli con up piwifi-hotspot passwd-file /etc/piwifiap/piwifiap.secret
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
current_user=$(whoami)
|
current_user=$(whoami)
|
||||||
@@ -121,18 +137,20 @@ then
|
|||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
echo "If this terminal connects to a network using ethernet, it can be configured"
|
echo "If this system connects to a network using ethernet, it can be configured"
|
||||||
echo "as a wireless access point for other terminals. Would you like to configure"
|
echo "as a wireless access point for other systems. Would you like to configure"
|
||||||
echo -n "this terminal as an access point? [y/N]: "
|
echo -n "this system as an access point? [y/N]: "
|
||||||
read wapconf
|
read wapconf
|
||||||
if [[ "$wapconf" == "Y" || "$wapconf" == "y" ]]
|
if [[ "$wapconf" == "Y" || "$wapconf" == "y" ]]
|
||||||
then
|
then
|
||||||
# Determine if we are using NetworkManager or systemd-networkd
|
# Determine if we are using NetworkManager or systemd-networkd
|
||||||
echo ""
|
echo ""
|
||||||
echo "Copying files..."
|
echo "Copying files..."
|
||||||
chmod +x apsetup/usr/local/bin/*
|
chmod +x apsetup/usr/local/bin/wap-*
|
||||||
cp -Rv apsetup/usr/local/bin/* /usr/local/bin
|
cp -R apsetup/usr/local/bin/* /usr/local/bin/
|
||||||
cp -Rv apsetup/etc/* /etc
|
cp -R apsetup/etc/* /etc/
|
||||||
|
chown -R root:root /etc/piwifiap
|
||||||
|
chmod 600 /etc/piwifiap/*
|
||||||
if systemctl status dhcpcd.service|grep -q "Active: active (running)"
|
if systemctl status dhcpcd.service|grep -q "Active: active (running)"
|
||||||
then
|
then
|
||||||
config_systemd-networkd
|
config_systemd-networkd
|
||||||
@@ -155,12 +173,23 @@ then
|
|||||||
echo ""
|
echo ""
|
||||||
echo "To disable the access point altogether in the future, run:"
|
echo "To disable the access point altogether in the future, run:"
|
||||||
echo " sudo wap-disable"
|
echo " sudo wap-disable"
|
||||||
echo "at a command prompt and reboot the terminal. To re-enable it, run:"
|
echo "at a command prompt and reboot. To re-enable it, run:"
|
||||||
echo " sudo wap-enable"
|
echo " sudo wap-enable"
|
||||||
echo "at a command prompt and reboot the terminal."
|
echo "at a command prompt and reboot."
|
||||||
echo ""
|
echo ""
|
||||||
echo -n "Press enter key to continue..."
|
echo "The system must be rebooted for the configuration to take effect."
|
||||||
read cont
|
echo ""
|
||||||
|
read -p "Would you like to reboot now? [Y/n]: " -r rebootok
|
||||||
|
case "$rebootok" in
|
||||||
|
"y" | "Y" | "")
|
||||||
|
reboot
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "You may continue to use the system, but the access point will not be"
|
||||||
|
echo "functional until you reboot."
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
else
|
else
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user