Skip to content

Commit

Permalink
Create Wi-Fi AP using NetworkManager
Browse files Browse the repository at this point in the history
  • Loading branch information
okalachev committed Apr 26, 2024
1 parent 249800b commit 00fb98c
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions builder/assets/init_rpi.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,15 @@
set -e # Exit immidiately on non-zero result

NEW_SSID='clover-'$(head -c 100 /dev/urandom | xxd -ps -c 100 | sed -e "s/[^0-9]//g" | cut -c 1-4)
echo "--- Setting SSID to ${NEW_SSID}"
# TODO: Use wpa_cli insted direct file edit
# FIXME: We rely on raspberrypi-net-mods to copy our file to /etc/wpa_supplicant.
# This is not very reliable, but seems to fix our rfkill problem.
cat << EOF >> /boot/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=GB
network={
ssid="${NEW_SSID}"
psk="cloverwifi"
mode=2
proto=WPA RSN
key_mgmt=WPA-PSK
pairwise=CCMP
group=CCMP
auth_alg=OPEN
}
EOF
echo "--- Creating Wi-Fi AP with SSID=${NEW_SSID}"
nmcli con add type wifi ifname wlan0 mode ap con-name clover ssid $NEW_SSID autoconnect true
nmcli con modify TEST-AP 802-11-wireless.band bg
# nmcli con modify TEST-AP 802-11-wireless.channel 6
nmcli con modify TEST-AP ipv4.method shared ipv4.address 192.168.11.1/24
nmcli con modify TEST-AP ipv6.method disabled
nmcli con modify TEST-AP wifi-sec.key-mgmt wpa-psk
nmcli con modify TEST-AP wifi-sec.psk "cloverwifi"
systemctl disable dnsmasq # disable dnsmasq to avoid conflicts with NetworkManager's dnsmasq

NEW_HOSTNAME=$(echo ${NEW_SSID} | tr '[:upper:]' '[:lower:]')
echo "--- Setting hostname to $NEW_HOSTNAME"
Expand Down

0 comments on commit 00fb98c

Please sign in to comment.