From fd7751b3631d8ef42c0e2a73c28609003b3cca92 Mon Sep 17 00:00:00 2001 From: Stefan Schmidt <stefan.schmidt@huawei.com> Date: Fri, 2 Jun 2023 10:22:40 +0200 Subject: [PATCH] networkmanager: Provide a static IP configuration file In some network scenarios it might be better to have the device configured with a static IP configuration instead of DHCP. This commit introduces a nmconnection file which allows such a configuration. The commit also introduces the nmcli command to the image for on device changes. Signed-off-by: Stefan Schmidt <stefan.schmidt@huawei.com> --- conf/distro/oniro-openharmony-linux.conf | 4 ++++ .../static-ip.nmconnection | 17 +++++++++++++++++ .../networkmanager-static-ip-config_git.bb | 15 +++++++++++++++ .../images/openharmony-standard-image.bb | 3 +++ 4 files changed, 39 insertions(+) create mode 100644 recipes-connectivity/networkmanager/networkmanager-static-ip-config/static-ip.nmconnection create mode 100644 recipes-connectivity/networkmanager/networkmanager-static-ip-config_git.bb diff --git a/conf/distro/oniro-openharmony-linux.conf b/conf/distro/oniro-openharmony-linux.conf index eacb12b5..f688947c 100644 --- a/conf/distro/oniro-openharmony-linux.conf +++ b/conf/distro/oniro-openharmony-linux.conf @@ -55,3 +55,7 @@ RPI_EXTRA_CONFIG:raspberrypi4-64 = ' \n \ dtoverlay=vc4-fkms-v3d \n \ ' HDMI_FORCE_HOTPLUG:raspberrypi4-64 = "1" + +# We use NetworkManager as the default network manager +PACKAGECONFIG:remove:pn-systemd = "networkd" + diff --git a/recipes-connectivity/networkmanager/networkmanager-static-ip-config/static-ip.nmconnection b/recipes-connectivity/networkmanager/networkmanager-static-ip-config/static-ip.nmconnection new file mode 100644 index 00000000..cb21f0bb --- /dev/null +++ b/recipes-connectivity/networkmanager/networkmanager-static-ip-config/static-ip.nmconnection @@ -0,0 +1,17 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: MIT + +[connection] +id=StaticIP +uuid=6e6ac8b6-b2d5-4f01-a25d-5a4191e5e897 +type=802-3-ethernet +autoconnect=true +interface-name=eth0 +permissions= + +[ipv4] +address1=192.168.2.199/24,192.168.2.1 +dns=192.168.2.1;8.8.8.8; +dns-search= +method=manual diff --git a/recipes-connectivity/networkmanager/networkmanager-static-ip-config_git.bb b/recipes-connectivity/networkmanager/networkmanager-static-ip-config_git.bb new file mode 100644 index 00000000..1719379c --- /dev/null +++ b/recipes-connectivity/networkmanager/networkmanager-static-ip-config_git.bb @@ -0,0 +1,15 @@ +# SPDX-FileCopyrightText: Huawei Inc. +# +# SPDX-License-Identifier: MIT + +LICENSE = "MIT" +#LIC_FILES_CHKSUM = "file://static-ip.nmconnection;beginline=1;endline=3;md5=a1537856660cf2c8e36079c007b35bec" +LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" + +SRC_URI = "file://static-ip.nmconnection" + +do_install:append() { + install -D -m0600 ${WORKDIR}/static-ip.nmconnection ${D}${libdir}/NetworkManager/system-connections/static-ip.nmconnection +} + +FILES:${PN} += "${libdir}/NetworkManager/system-connections/" diff --git a/recipes-openharmony/images/openharmony-standard-image.bb b/recipes-openharmony/images/openharmony-standard-image.bb index 2cb597a6..dcfe486c 100644 --- a/recipes-openharmony/images/openharmony-standard-image.bb +++ b/recipes-openharmony/images/openharmony-standard-image.bb @@ -13,3 +13,6 @@ IMAGE_INSTALL += "openharmony-standard" # Let's be friendly enough to provide a fully working interactive shell IMAGE_INSTALL += "bash" + +# Provide static IP configuration file +IMAGE_INSTALL += "networkmanager-nmcli networkmanager-static-ip-config" -- GitLab