package/ifupdown-scripts: add openrc support
authorCarlos Santos <unixmania@gmail.com>
Mon, 9 Mar 2020 02:50:03 +0000 (23:50 -0300)
committerYann E. MORIN <yann.morin.1998@free.fr>
Wed, 11 Mar 2020 21:12:17 +0000 (22:12 +0100)
The "network" script allows configuring an interface by means of two
/etc/ifup.<if_name> and /etc/ifdown.<if_name> files with the commands
required to bring it up and down, respectively. So we can support the
BR2_SYSTEM_DHCP config if netifrc is not selected.

- Replace the dependency on !BR2_PACKAGE_OPENRC in Config.in by a
  dependency on !BR2_PACKAGE_NETIFRC.

- Add an IFUPDOWN_SCRIPTS_DHCP_OPENRC macro to create the ifup.<if_name>
  and ifdown.<if_name> files.

- Add an IFUPDOWN_SCRIPTS_INSTALL_INIT_OPENRC hook that includes the
  IFUPDOWN_SCRIPTS_{PREAMBLE,DHCP,DHCP_OPENRC} macros. LOCALHOST is not
  required, since "lo" is configured by the "loopback" script.

Signed-off-by: Carlos Santos <unixmania@gmail.com>
[yann.morin.1998@free.fr:
  - adapt after the preamble was spit to itw own patch
]
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
package/ifupdown-scripts/Config.in
package/ifupdown-scripts/ifupdown-scripts.mk

index 4b984bc30c40e7681ba019cac488c4f07493200f..166094c5115692c098ce1a1ee83a30764549227c 100644 (file)
@@ -1,7 +1,7 @@
 config BR2_PACKAGE_IFUPDOWN_SCRIPTS
        bool "ifupdown scripts"
        default y if BR2_ROOTFS_SKELETON_DEFAULT
-       depends on !BR2_PACKAGE_SYSTEMD_NETWORKD && !BR2_PACKAGE_OPENRC
+       depends on !BR2_PACKAGE_SYSTEMD_NETWORKD && !BR2_PACKAGE_NETIFRC
        help
          Set of scripts used by ifupdown (either the standalone one,
          or the busybox one) to bring network up, or tear it down.
index 8a2337e46b1b388a89ed88651b5b0e8ddcc2c0b2..5ef032142c24e64d5690b0192deb2ef27cf5a579 100644 (file)
@@ -30,6 +30,12 @@ define IFUPDOWN_SCRIPTS_DHCP
                echo "  hostname \$$(hostname)"; \
        ) >> $(TARGET_DIR)/etc/network/interfaces
 endef
+define IFUPDOWN_SCRIPTS_DHCP_OPENRC
+       echo "ifup $(IFUPDOWN_SCRIPTS_DHCP_IFACE)" \
+               > $(TARGET_DIR)/etc/ifup.$(IFUPDOWN_SCRIPTS_DHCP_IFACE)
+       echo "ifdown $(IFUPDOWN_SCRIPTS_DHCP_IFACE)" \
+               > $(TARGET_DIR)/etc/ifdown.$(IFUPDOWN_SCRIPTS_DHCP_IFACE)
+endef
 endif
 
 define IFUPDOWN_SCRIPTS_INSTALL_TARGET_CMDS
@@ -38,6 +44,12 @@ define IFUPDOWN_SCRIPTS_INSTALL_TARGET_CMDS
        $(call SYSTEM_RSYNC,$(IFUPDOWN_SCRIPTS_PKGDIR)/network,$(TARGET_DIR)/etc/network)
 endef
 
+define IFUPDOWN_SCRIPTS_INSTALL_INIT_OPENRC
+       $(IFUPDOWN_SCRIPTS_PREAMBLE)
+       $(IFUPDOWN_SCRIPTS_DHCP)
+       $(IFUPDOWN_SCRIPTS_DHCP_OPENRC)
+endef
+
 define IFUPDOWN_SCRIPTS_INSTALL_INIT_SYSV
        $(INSTALL) -D -m 0755 $(IFUPDOWN_SCRIPTS_PKGDIR)/S40network \
                $(TARGET_DIR)/etc/init.d/S40network