This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
recipes-connectivity: nm: Configure networks in the first boot
- Loading branch information
1 parent
240b86b
commit be094f9
Showing
3 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
recipes-connectivity/networkmanager/networkmanager/firstboot-networkmanager-setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
FILECONDITION="/etc/sysconfig/networkmanager" | ||
DEFAULTPASSWORD="1234567890" | ||
|
||
while [ 1 ]; do | ||
read xx MAC xx <<<$(ip link | grep -A1 -e "^[0-9]*: wl" | grep link/ether) | ||
# poor's man "wait for device to appear" | ||
if [ -z "$MAC" ]; then | ||
sleep 1 | ||
continue | ||
fi | ||
|
||
# remove : | ||
SSID=${MAC//:} | ||
# make it uppercase | ||
SSID=${SSID^^} | ||
# prefix "Aero-" | ||
SSID="Aero-$SSID" | ||
break | ||
done | ||
|
||
# Let NetworkManager start dnsmasq with the right configuration file | ||
systemctl disable dnsmasq | ||
|
||
# Wifi | ||
nmcli con add type wifi ifname '*' con-name Wifi-hostspot autoconnect yes ssid $SSID | ||
nmcli con modify Wifi-hostspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared | ||
nmcli con modify Wifi-hostspot wifi-sec.key-mgmt wpa-psk | ||
nmcli con modify Wifi-hostspot wifi-sec.psk "1234567890" | ||
nmcli con modify Wifi-hostspot ipv4.addresses 192.168.8.0/24 | ||
nmcli con up Wifi-hostspot | ||
|
||
# Modem | ||
nmcli con add type gsm ifname '*' con-name Modem autoconnect yes | ||
nmcli con up Modem | ||
|
||
# Make sure this script just run once | ||
mkdir -p $(dirname $FILECONDITION) | ||
touch $FILECONDITION | ||
echo "First boot configuration succesful" |
14 changes: 14 additions & 0 deletions
14
recipes-connectivity/networkmanager/networkmanager/firstboot-networkmanager.service
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[Unit] | ||
Description=NetworkManager service default configuration | ||
Requisite=NetworkManager.service | ||
After=NetworkManager.service | ||
Before=network.target multi-user.target | ||
Wants=network.target | ||
ConditionPathExists=!/etc/sysconfig/networkmanager | ||
|
||
[Service] | ||
Type=oneshot | ||
ExecStart=/usr/sbin/firstboot-networkmanager-setup | ||
|
||
[Install] | ||
WantedBy=multi-user.target |
14 changes: 13 additions & 1 deletion
14
recipes-connectivity/networkmanager/networkmanager_%.bbappend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,17 @@ | ||
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:" | ||
|
||
SRC_URI += "file://firstboot-networkmanager.service" | ||
SRC_URI += "file://firstboot-networkmanager-setup" | ||
|
||
PACKAGECONFIG += "modemmanager" | ||
PACKAGECONFIG += "ppp" | ||
|
||
DEPENDS += "nss" | ||
PACKAGECONFIG += "systemd" | ||
PACKAGECONFIG += "systemd" | ||
|
||
SYSTEMD_SERVICE_${PN} += "firstboot-networkmanager.service" | ||
|
||
do_install_append() { | ||
install -D -m 0755 ${WORKDIR}/firstboot-networkmanager-setup ${D}/usr/sbin/firstboot-networkmanager-setup | ||
install -D -m 0644 ${WORKDIR}/firstboot-networkmanager.service ${D}${systemd_unitdir}/system | ||
} |