-
Notifications
You must be signed in to change notification settings - Fork 152
/
init.sh
executable file
·46 lines (38 loc) · 1.43 KB
/
init.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/sh
set -o errexit
set -o nounset
# install CNIs
cp -f /usr/bin/terway /opt/cni/bin/
chmod +x /opt/cni/bin/terway
cp -f /usr/bin/cilium-cni /opt/cni/bin/
chmod +x /opt/cni/bin/cilium-cni
# init cni config
terway-cli cni /etc/eni/10-terway.conflist /etc/eni/10-terway.conf --output /etc/cni/net.d/10-terway.conflist
terway-cli nodeconfig
node_capabilities=/var/run/eni/node_capabilities
if [ ! -f "$node_capabilities" ]; then
echo "Init node capabilities"
mkdir -p /var/run/eni
touch "$node_capabilities"
fi
require_erdma=$(jq '.enable_erdma' -r </etc/eni/eni_conf)
if [ "$require_erdma" = "true" ]; then
echo "Init erdma driver"
if modprobe erdma; then
echo "node support erdma"
echo "erdma = true" >>"$node_capabilities"
if ! grep -q "erdma *= *true" "$node_capabilities"; then
sed -i '/erdma *=/d' "$node_capabilities"
echo "erdma = true" >> "$node_capabilities"
fi
else
sed -i '/erdma *= *true/d' "$node_capabilities"
echo "node not support erdma, pls install the latest erdma driver"
fi
fi
# copy node capabilities to tmpfs so policy container can read it
cp $node_capabilities /var-run-eni/node_capabilities
cat $node_capabilities
sysctl -w net.ipv4.conf.eth0.rp_filter=0
modprobe sch_htb || true
chroot /host sh -c "systemctl disable eni.service; rm -f /etc/udev/rules.d/75-persistent-net-generator.rules /lib/udev/rules.d/60-net.rules /lib/udev/rules.d/61-eni.rules /lib/udev/write_net_rules"