blob: 6a26dfc589706a9b55d8c9b144b9ee4fc5c302ed [file] [log] [blame]
Jan Kundráte8b18112018-04-04 23:11:23 +02001CZECHLIGHT_CFG_FS_INSTALL_IMAGES = YES
Tomáš Pecka68a22862022-05-30 15:52:29 +02002CZECHLIGHT_CFG_FS_DEPENDENCIES = host-e2fsprogs host-libyang netopeer2 systemd
Jan Kundráte8b18112018-04-04 23:11:23 +02003
4CZECHLIGHT_CFG_FS_LOCATION = $(BINARIES_DIR)/cfg.ext4
5
6define CZECHLIGHT_CFG_FS_INSTALL_IMAGES_CMDS
7 rm -f $(CZECHLIGHT_CFG_FS_LOCATION)
8 $(HOST_DIR)/sbin/mkfs.ext4 -L cfg $(CZECHLIGHT_CFG_FS_LOCATION) $(call qstrip,$(CZECHLIGHT_CFG_FS_SIZE))
9endef
10
Jan Kundrát62dbb4a2018-04-05 20:42:09 +020011ifeq ($(BR2_PACKAGE_CZECHLIGHT_CFG_FS)-$(call qstrip,$(CZECHLIGHT_CFG_FS_SIZE)),y-)
12$(error CZECHLIGHT_CFG_FS_SIZE cannot be empty)
13endif
14
Jan Kundrát6b05a1d2019-03-06 17:01:28 +010015define CZECHLIGHT_CFG_FS_BUILD_CMDS
Jan Kundrát757863a2019-12-05 15:57:55 +010016 $(TARGET_CC) $(CZECHLIGHT_CFG_FS_PKGDIR)/czechlight-random-seed.c -o $(@D)/czechlight-random-seed
Jan Kundrátbd1cf692021-02-18 21:12:13 +010017
Václav Kubernát8cd61562021-12-08 13:27:31 +010018 $(HOST_DIR)/usr/bin/yanglint -t config \
Jan Kundrátbd1cf692021-02-18 21:12:13 +010019 $(TARGET_DIR)/usr/share/yang/modules/netopeer2/ietf-netconf-acm@2018-02-14.yang \
20 $(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/czechlight-cfg-fs/nacm.json
Jan Kundrát6b05a1d2019-03-06 17:01:28 +010021endef
22
Jan Kundráte40feeb2022-07-08 14:27:29 +020023CZECHLIGHT_CFG_FS_SYSTEMD_FOR_MULTIUSER = \
24 czechlight-install-yang.service \
25 czechlight-migrate.service \
26 nacm-restore.service
27
28$(ifeq ($(CZECHLIGHT_CFG_FS_PERSIST_SYSREPO),y))
29 CZECHLIGHT_CFG_FS_SYSTEMD_FOR_MULTIUSER += \
30 sysrepo-persistent-cfg.service \
31 cfg-restore-sysrepo.service
32$(endif)
33$(ifeq ($(CZECHLIGHT_CFG_FS_PERSIST_KEYS),y))
34 CZECHLIGHT_CFG_FS_SYSTEMD_FOR_MULTIUSER += openssh-persistent-keys.service
35$(endif)
36$(ifeq ($(CZECHLIGHT_CFG_FS_PERSIST_NETWORK),y))
37 CZECHLIGHT_CFG_FS_SYSTEMD_FOR_MULTIUSER += cfg-restore-systemd-networkd.service
38$(endif)
39
Jan Kundrát960274e2018-04-09 11:20:56 +020040define CZECHLIGHT_CFG_FS_INSTALL_TARGET_CMDS
Jan Kundrát567058d2018-11-08 19:15:56 +010041 mkdir -p $(TARGET_DIR)/cfg
Jan Kundráte40feeb2022-07-08 14:27:29 +020042 mkdir -p $(TARGET_DIR)/usr/lib/systemd/system/multi-user.target.wants/
43
44 $(INSTALL) -D -m 0755 -t $(TARGET_DIR)/sbin \
45 $(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/czechlight-cfg-fs/init-czechlight.sh \
46 $(@D)/czechlight-random-seed
47
48 $(INSTALL) -D -m 0644 -t $(TARGET_DIR)/usr/share/yang-data/ \
49 $(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/czechlight-cfg-fs/nacm.json
Tomáš Pecka04eb7372022-06-07 08:03:04 +020050
51 $(INSTALL) -D -m 0755 -t $(TARGET_DIR)/usr/libexec/czechlight-cfg-fs \
Jan Kundráte40feeb2022-07-08 14:27:29 +020052 $(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/czechlight-cfg-fs/czechlight-install-yang.sh \
Tomáš Pecka04eb7372022-06-07 08:03:04 +020053 $(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/czechlight-cfg-fs/czechlight-migrate.sh \
54 $(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/czechlight-cfg-fs/czechlight-migration-list.sh
55
56 $(INSTALL) -D -m 0644 -t $(TARGET_DIR)/usr/libexec/czechlight-cfg-fs/migrations \
57 $(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/czechlight-cfg-fs/migrations/*
58
Jan Kundráte40feeb2022-07-08 14:27:29 +020059
60 for UNIT in $(CZECHLIGHT_CFG_FS_SYSTEMD_FOR_MULTIUSER); do \
61 $(INSTALL) -D -m 0644 -t $(TARGET_DIR)/usr/lib/systemd/system/ \
62 $(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/czechlight-cfg-fs/$${UNIT}; \
63 ln -sf ../$${UNIT} $(TARGET_DIR)/usr/lib/systemd/system/multi-user.target.wants/ ;\
64 done
Jan Kundrát960274e2018-04-09 11:20:56 +020065endef
66
Jan Kundrát86665c42018-06-06 13:38:22 +020067# Configure OpenSSH to look for *user* keys in the /cfg
68define CZECHLIGHT_CFG_FS_OPENSSH_AUTH_PATH_PATCH
69 $(SED) 's|^AuthorizedKeysFile.*|AuthorizedKeysFile /cfg/ssh-user-auth/%u|' $(TARGET_DIR)/etc/ssh/sshd_config
70endef
71OPENSSH_POST_INSTALL_TARGET_HOOKS += CZECHLIGHT_CFG_FS_OPENSSH_AUTH_PATH_PATCH
72
Jan Kundrátf908bda2021-01-22 19:51:50 +010073NETOPEER2_CONF_OPTS += \
74 -DNP2SRV_SSH_AUTHORIZED_KEYS_PATTERN="/cfg/ssh-user-auth/%s" \
75 -DNP2SRV_SSH_AUTHORIZED_KEYS_ARG_IS_USERNAME=ON
76
Jan Kundráte8b18112018-04-04 23:11:23 +020077$(eval $(generic-package))