Restore network configuration on startup

Recent change to velia introduced persisting network configuration. It
just copies the .network file to /cfg partition. On boot it must be
restored into /run/systemd/network directory so systemd-networkd can
find the configuration.

If no configuration is found in /cfg, use the default configuration for
eth1 device, i.e., bridge.

Depends-on: https://cesnet-gerrit-czechlight/c/CzechLight/velia/+/3814
Depends-on: https://cesnet-gerrit-public/c/CzechLight/velia/+/3814
Depends-on: https://gerrit.cesnet.cz/c/CzechLight/velia/+/3814
Change-Id: I8d852b329b3189bc8c6bef5e34c0d4d86ea963b1
diff --git a/package/czechlight-cfg-fs/czechlight-cfg-fs.mk b/package/czechlight-cfg-fs/czechlight-cfg-fs.mk
index bc33805..aebc14b 100644
--- a/package/czechlight-cfg-fs/czechlight-cfg-fs.mk
+++ b/package/czechlight-cfg-fs/czechlight-cfg-fs.mk
@@ -40,6 +40,13 @@
 			$(TARGET_DIR)/usr/lib/systemd/system/
 		ln -sf ../openssh-persistent-keys.service $(TARGET_DIR)/usr/lib/systemd/system/multi-user.target.wants/
 	$(endif)
+	$(ifeq ($(CZECHLIGHT_CFG_FS_PERSIST_NETWORK),y))
+		mkdir -p $(TARGET_DIR)/usr/lib/systemd/system/network-pre.target.wants/
+		$(INSTALL) -D -m 0644 \
+			$(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/czechlight-cfg-fs/cfg-restore-systemd-networkd.service \
+			$(TARGET_DIR)/usr/lib/systemd/system/
+		ln -sf ../cfg-restore-systemd-network.service $(TARGET_DIR)/usr/lib/systemd/system/network-pre.target.wants/
+	$(endif)
 endef
 
 # Configure OpenSSH to look for *user* keys in the /cfg