Skip to content

Commit 6eb7798

Browse files
committed
fix(install): incus error
1 parent 5ce5188 commit 6eb7798

1 file changed

Lines changed: 14 additions & 16 deletions

File tree

install.sh

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -93,37 +93,35 @@ function install_helm {
9393
function configure_os {
9494
echo -e "\\033[32m---> Start configuring kernel parameters\\033[0m"
9595
if [[ "$(command -v iptables)" != "" ]] ; then
96-
iptables -F
97-
iptables -X
98-
iptables -F -t nat
99-
iptables -X -t nat
100-
iptables -P FORWARD ACCEPT
96+
iptables -F || echo -e "\\033[33m---> Warning: iptables -F failed, skipping (container environment?)\\033[0m"
97+
iptables -X || echo -e "\\033[33m---> Warning: iptables -X failed, skipping\\033[0m"
98+
iptables -F -t nat || echo -e "\\033[33m---> Warning: iptables -F -t nat failed, skipping\\033[0m"
99+
iptables -X -t nat || echo -e "\\033[33m---> Warning: iptables -X -t nat failed, skipping\\033[0m"
100+
iptables -P FORWARD ACCEPT || echo -e "\\033[33m---> Warning: iptables -P FORWARD ACCEPT failed, skipping\\033[0m"
101101
else
102-
# Kube hostport depends on iptables
103-
echo -e "\\033[33m---> The iptables does not exist...\\033[0m"
104-
exit 1
102+
echo -e "\\033[33m---> Warning: iptables does not exist, skipping iptables configuration...\\033[0m"
105103
fi
106-
swapoff -a
107-
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
108-
mount bpffs -t bpf /sys/fs/bpf
104+
swapoff -a 2>/dev/null || true
105+
sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab 2>/dev/null || true
106+
mount bpffs -t bpf /sys/fs/bpf 2>/dev/null || echo -e "\\033[33m---> Warning: mount bpffs failed, skipping (container environment?)\\033[0m"
109107
rmem_max=$(sysctl -ne net.core.rmem_max)
110108
if [ ! -n "$rmem_max" ] || [ 2500000 -gt $rmem_max ] ;then
111-
echo 'net.core.rmem_max = 2500000' >> /etc/sysctl.conf
109+
echo 'net.core.rmem_max = 2500000' >> /etc/sysctl.conf 2>/dev/null || true
112110
fi
113111
nr_hugepages=$(sysctl -ne vm.nr_hugepages)
114112
if [ ! -n "$nr_hugepages" ] || [ 1024 -gt $nr_hugepages ] ;then
115-
echo 'vm.nr_hugepages = 1024' >> /etc/sysctl.conf
113+
echo 'vm.nr_hugepages = 1024' >> /etc/sysctl.conf 2>/dev/null || true
116114
fi
117115
max_user_instances=$(sysctl -ne fs.inotify.max_user_instances)
118116
if [ ! -n "$max_user_instances" ] || [ 65535 -gt $max_user_instances ] ;then
119-
echo 'fs.inotify.max_user_instances = 65535' >> /etc/sysctl.conf
117+
echo 'fs.inotify.max_user_instances = 65535' >> /etc/sysctl.conf 2>/dev/null || true
120118
fi
121-
sysctl -p
119+
sysctl -p 2>/dev/null || echo -e "\\033[33m---> Warning: sysctl -p failed, skipping (container environment?)\\033[0m"
122120

123121
cpufreq=$(ls /sys/devices/system/cpu/cpu*/cpufreq >/dev/null 2>&1 || echo "false")
124122
if [[ $cpufreq != "false" ]]; then
125123
for cpu in /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor; do
126-
echo performance > $cpu
124+
echo performance > $cpu 2>/dev/null || true
127125
done
128126
fi
129127
echo -e "\\033[32m---> Configuring kernel parameters finish\\033[0m"

0 commit comments

Comments
 (0)