Jan Kundrát | e8b1811 | 2018-04-04 23:11:23 +0200 | [diff] [blame] | 1 | CZECHLIGHT_CFG_FS_INSTALL_IMAGES = YES |
Tomáš Pecka | 68a2286 | 2022-05-30 15:52:29 +0200 | [diff] [blame] | 2 | CZECHLIGHT_CFG_FS_DEPENDENCIES = host-e2fsprogs host-libyang netopeer2 systemd |
Jan Kundrát | e8b1811 | 2018-04-04 23:11:23 +0200 | [diff] [blame] | 3 | |
| 4 | CZECHLIGHT_CFG_FS_LOCATION = $(BINARIES_DIR)/cfg.ext4 |
| 5 | |
| 6 | define 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)) |
| 9 | endef |
| 10 | |
Jan Kundrát | 62dbb4a | 2018-04-05 20:42:09 +0200 | [diff] [blame] | 11 | ifeq ($(BR2_PACKAGE_CZECHLIGHT_CFG_FS)-$(call qstrip,$(CZECHLIGHT_CFG_FS_SIZE)),y-) |
| 12 | $(error CZECHLIGHT_CFG_FS_SIZE cannot be empty) |
| 13 | endif |
| 14 | |
Jan Kundrát | 6b05a1d | 2019-03-06 17:01:28 +0100 | [diff] [blame] | 15 | define CZECHLIGHT_CFG_FS_BUILD_CMDS |
Jan Kundrát | 757863a | 2019-12-05 15:57:55 +0100 | [diff] [blame] | 16 | $(TARGET_CC) $(CZECHLIGHT_CFG_FS_PKGDIR)/czechlight-random-seed.c -o $(@D)/czechlight-random-seed |
Jan Kundrát | bd1cf69 | 2021-02-18 21:12:13 +0100 | [diff] [blame] | 17 | |
Václav Kubernát | 8cd6156 | 2021-12-08 13:27:31 +0100 | [diff] [blame] | 18 | $(HOST_DIR)/usr/bin/yanglint -t config \ |
Jan Kundrát | bd1cf69 | 2021-02-18 21:12:13 +0100 | [diff] [blame] | 19 | $(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át | 6b05a1d | 2019-03-06 17:01:28 +0100 | [diff] [blame] | 21 | endef |
| 22 | |
Jan Kundrát | e40feeb | 2022-07-08 14:27:29 +0200 | [diff] [blame] | 23 | CZECHLIGHT_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át | 960274e | 2018-04-09 11:20:56 +0200 | [diff] [blame] | 40 | define CZECHLIGHT_CFG_FS_INSTALL_TARGET_CMDS |
Jan Kundrát | 567058d | 2018-11-08 19:15:56 +0100 | [diff] [blame] | 41 | mkdir -p $(TARGET_DIR)/cfg |
Jan Kundrát | e40feeb | 2022-07-08 14:27:29 +0200 | [diff] [blame] | 42 | 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áš Pecka | 04eb737 | 2022-06-07 08:03:04 +0200 | [diff] [blame] | 50 | |
| 51 | $(INSTALL) -D -m 0755 -t $(TARGET_DIR)/usr/libexec/czechlight-cfg-fs \ |
Jan Kundrát | e40feeb | 2022-07-08 14:27:29 +0200 | [diff] [blame] | 52 | $(BR2_EXTERNAL_CZECHLIGHT_PATH)/package/czechlight-cfg-fs/czechlight-install-yang.sh \ |
Tomáš Pecka | 04eb737 | 2022-06-07 08:03:04 +0200 | [diff] [blame] | 53 | $(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át | e40feeb | 2022-07-08 14:27:29 +0200 | [diff] [blame] | 59 | |
| 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át | 960274e | 2018-04-09 11:20:56 +0200 | [diff] [blame] | 65 | endef |
| 66 | |
Jan Kundrát | 86665c4 | 2018-06-06 13:38:22 +0200 | [diff] [blame] | 67 | # Configure OpenSSH to look for *user* keys in the /cfg |
| 68 | define CZECHLIGHT_CFG_FS_OPENSSH_AUTH_PATH_PATCH |
| 69 | $(SED) 's|^AuthorizedKeysFile.*|AuthorizedKeysFile /cfg/ssh-user-auth/%u|' $(TARGET_DIR)/etc/ssh/sshd_config |
| 70 | endef |
| 71 | OPENSSH_POST_INSTALL_TARGET_HOOKS += CZECHLIGHT_CFG_FS_OPENSSH_AUTH_PATH_PATCH |
| 72 | |
Jan Kundrát | f908bda | 2021-01-22 19:51:50 +0100 | [diff] [blame] | 73 | NETOPEER2_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át | e8b1811 | 2018-04-04 23:11:23 +0200 | [diff] [blame] | 77 | $(eval $(generic-package)) |