Skip to content
This repository has been archived by the owner on Jan 3, 2023. It is now read-only.

Commit

Permalink
recipes-connectivity: nm: Configure networks in the first boot
Browse files Browse the repository at this point in the history
  • Loading branch information
zehortigoza committed Aug 2, 2017
1 parent 240b86b commit be094f9
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
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"
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 recipes-connectivity/networkmanager/networkmanager_%.bbappend
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
}

0 comments on commit be094f9

Please sign in to comment.