--- /dev/null
+[Unit]
+Description=Network Connectivity
+Wants=network.target
+Before=network.target
+
+[Service]
+Type=oneshot
+RemainAfterExit=yes
+
+# lo is brought up earlier, which will cause the upcoming "ifup -a" to fail
+# with exit code 1, due to an "ip: RTNETLINK answers: File exists" error during
+# its "ip addr add ..." command, subsequently causing this unit to fail even
+# though it is a benign error. Flushing the lo address with the command below
+# before ifup prevents this failure.
+ExecStart=/sbin/ip addr flush dev lo
+
+ExecStart=/sbin/ifup -a
+ExecStop=/sbin/ifdown -a
+
+[Install]
+WantedBy=multi-user.target
-exec $(SED) 's,$(HOST_DIR),,g' {} \;
endef
+define SYSTEMD_INSTALL_NETWORK_HOOK
+ $(INSTALL) -D -m 644 package/systemd/network.service \
+ $(TARGET_DIR)/etc/systemd/system/network.service
+ mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+ ln -fs ../network.service \
+ $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/network.service
+endef
+
SYSTEMD_POST_INSTALL_TARGET_HOOKS += \
SYSTEMD_INSTALL_INIT_HOOK \
SYSTEMD_INSTALL_TTY_HOOK \
SYSTEMD_INSTALL_MACHINEID_HOOK \
SYSTEMD_SANITIZE_PATH_IN_UNITS
+ifeq ($(BR2_PACKAGE_SYSTEMD_NETWORKD),)
+SYSTEMD_POST_INSTALL_TARGET_HOOKS += SYSTEMD_INSTALL_NETWORK_HOOK
+endif
+
define SYSTEMD_USERS
systemd-journal -1 systemd-journal -1 * /var/log/journal - - Journal
systemd-journal-gateway -1 systemd-journal-gateway -1 * /var/log/journal - - Journal Gateway