blob: 607f1b789cf3dc98ad0e1264b9e3ca8093c142ad [file] [log] [blame]
William A. Kennington IIIf19a8382021-02-16 14:16:47 -08001SUMMARY = "Configures ncsi for a gBMC system"
2PR = "r1"
3LICENSE = "Apache-2.0"
4LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
5
6inherit systemd
7
William A. Kennington IIId8122302023-10-16 18:25:18 -07008GBMC_NCSI_IF_OLD ??= ""
William A. Kennington IIIf0b88e22023-10-16 18:26:32 -07009GBMC_NCSI_PURGE_ETC ??= ""
William A. Kennington IIId8122302023-10-16 18:25:18 -070010
William A. Kennington III7f11d1f2021-02-16 14:57:41 -080011SRC_URI += " \
William A. Kennington III96745092021-08-06 00:06:42 -070012 file://-bmc-gbmcbrncsidhcp.netdev \
13 file://-bmc-gbmcbrncsidhcp.network \
14 file://-bmc-gbmcncsidhcp.netdev \
15 file://-bmc-gbmcncsidhcp.network \
William A. Kennington III7f11d1f2021-02-16 14:57:41 -080016 file://50-gbmc-ncsi.rules.in \
William A. Kennington III96745092021-08-06 00:06:42 -070017 file://gbmc-ncsi-dhcrelay.service.in \
William A. Kennington IIIc7454fb2021-09-14 16:01:37 -070018 file://gbmc-ncsi-ip-from-ra.service.in \
19 file://gbmc-ncsi-ip-from-ra.sh.in \
William A. Kennington III71fc1892021-12-13 14:32:20 -080020 file://gbmc-ncsi-smartnic-wa.sh.in \
William A. Kennington III7f11d1f2021-02-16 14:57:41 -080021 file://gbmc-ncsi-sslh.socket.in \
22 file://gbmc-ncsi-sslh.service \
William A. Kennington III1ef795b2021-03-10 18:59:12 -080023 file://gbmc-ncsi-nft.sh.in \
William A. Kennington IIIe99168a2021-03-10 23:40:47 -080024 file://gbmc-ncsi-br-pub-addr.sh.in \
William A. Kennington III21e7e452021-11-05 01:31:59 -070025 file://gbmc-ncsi-br-deprecated-ips.sh.in \
Vivekanand Veeracholane3f33702021-06-16 15:29:15 -070026 file://gbmc-ncsi-set-nicenabled.service.in \
William A. Kennington III9f57cee2022-11-03 14:17:35 -070027 file://gbmc-ncsi-alias.service.in \
William A. Kennington III37e6f392022-05-16 16:19:11 -070028 file://50-gbmc-ncsi-clear-ip.sh.in \
William A. Kennington IIId8122302023-10-16 18:25:18 -070029 file://gbmc-ncsi-old.service.in \
William A. Kennington IIIf0b88e22023-10-16 18:26:32 -070030 file://gbmc-ncsi-purge.service.in \
William A. Kennington III7f11d1f2021-02-16 14:57:41 -080031 "
William A. Kennington IIIf19a8382021-02-16 14:16:47 -080032
33S = "${WORKDIR}"
34
Willy Tu4dd03ca2021-08-06 09:37:35 -070035RDEPENDS:${PN} += " \
William A. Kennington IIIb03ef8c2021-10-01 01:16:24 -070036 bash \
William A. Kennington III96745092021-08-06 00:06:42 -070037 dhcp-relay \
William A. Kennington III1ef795b2021-03-10 18:59:12 -080038 gbmc-ip-monitor \
William A. Kennington III7f11d1f2021-02-16 14:57:41 -080039 ncsid \
William A. Kennington III5aa84b52021-11-15 15:20:13 -080040 network-sh \
William A. Kennington III7f11d1f2021-02-16 14:57:41 -080041 nftables-systemd \
42 sslh \
William A. Kennington III5aa84b52021-11-15 15:20:13 -080043 ndisc6-rdisc6 \
William A. Kennington III7f11d1f2021-02-16 14:57:41 -080044 "
William A. Kennington IIIf19a8382021-02-16 14:16:47 -080045
Willy Tu4dd03ca2021-08-06 09:37:35 -070046FILES:${PN} += " \
William A. Kennington III37e6f392022-05-16 16:19:11 -070047 ${datadir}/gbmc-br-lib \
William A. Kennington III1ef795b2021-03-10 18:59:12 -080048 ${datadir}/gbmc-ip-monitor \
49 ${systemd_unitdir} \
50 "
William A. Kennington IIIf19a8382021-02-16 14:16:47 -080051
Willy Tu4dd03ca2021-08-06 09:37:35 -070052SYSTEMD_SERVICE:${PN} += " \
William A. Kennington III96745092021-08-06 00:06:42 -070053 gbmc-ncsi-dhcrelay.service \
William A. Kennington III7f11d1f2021-02-16 14:57:41 -080054 gbmc-ncsi-sslh.service \
55 gbmc-ncsi-sslh.socket \
Vivekanand Veeracholane3f33702021-06-16 15:29:15 -070056 gbmc-ncsi-set-nicenabled.service \
William A. Kennington IIIc7454fb2021-09-14 16:01:37 -070057 gbmc-ncsi-ip-from-ra.service \
William A. Kennington IIId8122302023-10-16 18:25:18 -070058 ${@'' if d.getVar('GBMC_NCSI_IF_OLD') == '' else 'gbmc-ncsi-old.service'} \
William A. Kennington IIIf0b88e22023-10-16 18:26:32 -070059 ${@'' if d.getVar('GBMC_NCSI_PURGE_ETC') == '' else 'gbmc-ncsi-purge.service'} \
William A. Kennington III7f11d1f2021-02-16 14:57:41 -080060 "
61
Willy Tu4dd03ca2021-08-06 09:37:35 -070062do_install:append() {
William A. Kennington IIIf19a8382021-02-16 14:16:47 -080063 if_name='${GBMC_NCSI_IF_NAME}'
William A. Kennington IIIf19a8382021-02-16 14:16:47 -080064 if [ -z "$if_name" ]; then
65 echo "Missing if_name" >&2
66 exit 1
67 fi
68
69 install -d -m0755 ${D}${sysconfdir}/sysctl.d
70 echo "net.ipv6.conf.$if_name.accept_dad=0" \
71 >>${D}${sysconfdir}/sysctl.d/25-gbmc-ncsi.conf
72 echo "net.ipv6.conf.$if_name.dad_transmits=0" \
73 >>${D}${sysconfdir}/sysctl.d/25-gbmc-ncsi.conf
74
William A. Kennington III96745092021-08-06 00:06:42 -070075 install -d -m0755 ${D}${systemd_unitdir}/network
76 install -m0644 ${WORKDIR}/-bmc-gbmcbrncsidhcp.netdev \
77 ${D}${systemd_unitdir}/network/
78 install -m0644 ${WORKDIR}/-bmc-gbmcbrncsidhcp.network \
79 ${D}${systemd_unitdir}/network/
80 install -m0644 ${WORKDIR}/-bmc-gbmcncsidhcp.netdev \
81 ${D}${systemd_unitdir}/network/
82 install -m0644 ${WORKDIR}/-bmc-gbmcncsidhcp.network \
83 ${D}${systemd_unitdir}/network/
84
William A. Kennington IIIf19a8382021-02-16 14:16:47 -080085 netdir=${D}${systemd_unitdir}/network/00-bmc-$if_name.network.d
86 install -d -m0755 "$netdir"
87 echo '[Network]' >>"$netdir"/gbmc-ncsi.conf
88 echo 'DHCP=false' >>"$netdir"/gbmc-ncsi.conf
89 echo 'IPv6AcceptRA=false' >>"$netdir"/gbmc-ncsi.conf
90 echo 'LLMNR=false' >>"$netdir"/gbmc-ncsi.conf
91 echo 'MulticastDNS=false' >>"$netdir"/gbmc-ncsi.conf
92 echo 'LinkLocalAddressing=ipv6' >>"$netdir"/gbmc-ncsi.conf
93
94 nftdir=${D}${sysconfdir}/nftables
95 install -d -m0755 "$nftdir"
William A. Kennington III1ef795b2021-03-10 18:59:12 -080096 sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/50-gbmc-ncsi.rules.in \
William A. Kennington IIIf19a8382021-02-16 14:16:47 -080097 >"$nftdir"/50-gbmc-ncsi.rules
98
99 wantdir=${D}${systemd_system_unitdir}/multi-user.target.wants
100 install -d -m0755 "$wantdir"
101 ln -sv ../ncsid@.service "$wantdir"/ncsid@$if_name.service
William A. Kennington III7f11d1f2021-02-16 14:57:41 -0800102
William A. Kennington III9f57cee2022-11-03 14:17:35 -0700103 sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-alias.service.in \
104 >${D}${systemd_system_unitdir}/gbmc-ncsi-alias.service
105 install -d -m0755 "${D}${systemd_system_unitdir}/nic-hostless@$if_name.target.wants"
106 ln -sv ../gbmc-ncsi-alias.service "${D}${systemd_system_unitdir}/nic-hostless@$if_name.target.wants"/
107 install -d -m0755 "${D}${systemd_system_unitdir}/nic-hostful@$if_name.target.wants"
108 ln -sv ../gbmc-ncsi-alias.service "${D}${systemd_system_unitdir}/nic-hostful@$if_name.target.wants"/
109
William A. Kennington III7f11d1f2021-02-16 14:57:41 -0800110 install -m 0644 ${WORKDIR}/gbmc-ncsi-sslh.service ${D}${systemd_system_unitdir}
William A. Kennington III1ef795b2021-03-10 18:59:12 -0800111 sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-sslh.socket.in \
William A. Kennington III7f11d1f2021-02-16 14:57:41 -0800112 >${D}${systemd_system_unitdir}/gbmc-ncsi-sslh.socket
William A. Kennington III1ef795b2021-03-10 18:59:12 -0800113
114 mondir=${D}${datadir}/gbmc-ip-monitor/
115 install -d -m0755 $mondir
116 sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-nft.sh.in \
117 >${WORKDIR}/gbmc-ncsi-nft.sh
118 install -m644 ${WORKDIR}/gbmc-ncsi-nft.sh $mondir
William A. Kennington IIIe99168a2021-03-10 23:40:47 -0800119 sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-br-pub-addr.sh.in \
120 >${WORKDIR}/gbmc-ncsi-br-pub-addr.sh
121 install -m644 ${WORKDIR}/gbmc-ncsi-br-pub-addr.sh $mondir
William A. Kennington III21e7e452021-11-05 01:31:59 -0700122 sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-br-deprecated-ips.sh.in \
123 >${WORKDIR}/gbmc-ncsi-br-deprecated-ips.sh
124 install -m644 ${WORKDIR}/gbmc-ncsi-br-deprecated-ips.sh $mondir
Vivekanand Veeracholane3f33702021-06-16 15:29:15 -0700125
William A. Kennington III37e6f392022-05-16 16:19:11 -0700126 brlibdir=${D}${datadir}/gbmc-br-lib/
127 install -d -m0755 $brlibdir
128 sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/50-gbmc-ncsi-clear-ip.sh.in \
129 >${WORKDIR}/50-gbmc-ncsi-clear-ip.sh
130 install -m644 ${WORKDIR}/50-gbmc-ncsi-clear-ip.sh $brlibdir
William A. Kennington IIIb174c182021-11-03 14:54:51 -0700131
Vivekanand Veeracholane3f33702021-06-16 15:29:15 -0700132 sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-set-nicenabled.service.in \
133 >${D}${systemd_system_unitdir}/gbmc-ncsi-set-nicenabled.service
William A. Kennington III96745092021-08-06 00:06:42 -0700134
135 sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-dhcrelay.service.in \
136 >${D}${systemd_system_unitdir}/gbmc-ncsi-dhcrelay.service
William A. Kennington IIIc7454fb2021-09-14 16:01:37 -0700137
William A. Kennington IIId8122302023-10-16 18:25:18 -0700138 if [ -n "${GBMC_NCSI_IF_OLD}" ]; then
139 sed -e "s,@NCSI_IF@,$if_name,g" -e "s,@OLD_IF@,${GBMC_NCSI_IF_OLD},g" ${WORKDIR}/gbmc-ncsi-old.service.in \
140 >${D}${systemd_system_unitdir}/gbmc-ncsi-old.service
141 fi
142
William A. Kennington IIIf0b88e22023-10-16 18:26:32 -0700143 if [ -n "${GBMC_NCSI_PURGE_ETC}" ]; then
144 sed -e "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-purge.service.in \
145 >${D}${systemd_system_unitdir}/gbmc-ncsi-purge.service
146 fi
147
William A. Kennington IIIc7454fb2021-09-14 16:01:37 -0700148 sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-ip-from-ra.service.in \
149 >${WORKDIR}/gbmc-ncsi-ip-from-ra.service
150 install -m0644 ${WORKDIR}/gbmc-ncsi-ip-from-ra.service ${D}${systemd_system_unitdir}
151 sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-ip-from-ra.sh.in \
152 >${WORKDIR}/gbmc-ncsi-ip-from-ra.sh
153 install -d -m0755 ${D}${libexecdir}
154 install -m0755 ${WORKDIR}/gbmc-ncsi-ip-from-ra.sh ${D}${libexecdir}/
William A. Kennington III71fc1892021-12-13 14:32:20 -0800155
156 sed "s,@NCSI_IF@,$if_name,g" ${WORKDIR}/gbmc-ncsi-smartnic-wa.sh.in \
157 >${WORKDIR}/gbmc-ncsi-smartnic-wa.sh
158 install -d -m0755 ${D}${bindir}
159 install -m0755 ${WORKDIR}/gbmc-ncsi-smartnic-wa.sh ${D}${bindir}/
William A. Kennington III96745092021-08-06 00:06:42 -0700160}
161
162do_rm_work:prepend() {
163 # HACK: Work around broken do_rm_work not properly calling rm with `--`
164 # It doesn't like filenames that start with `-`
165 rm -rf -- ${WORKDIR}/-*
William A. Kennington IIIf19a8382021-02-16 14:16:47 -0800166}