Skip to content

Commit

Permalink
Add a change for killall to not unmount server and agent directory
Browse files Browse the repository at this point in the history
Signed-off-by: Vitor Savian <[email protected]>

Add recursive search and deletion of unmounted/mounted dirs in killall

Signed-off-by: Vitor Savian <[email protected]>

Only clean the server and agent directory if it is uninstall

Signed-off-by: Vitor Savian <[email protected]>
  • Loading branch information
vitorsavian committed Jul 12, 2024
1 parent 58ab259 commit 9a0c31f
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -902,10 +902,29 @@ for cmd in kubectl crictl ctr; do
fi
done
clean_mounted_directory() {
if ! grep -q " \$1" /proc/mounts; then
rm -rf "\$1"
return 0
fi
for path in "\$1"/*; do
if [ -d "\$path" ]; then
if grep -q " \$path" /proc/mounts; then
clean_mounted_directory "\$path"
else
rm -rf "\$path"
fi
else
rm "\$path"
fi
done
}
rm -rf /etc/rancher/k3s
rm -rf /run/k3s
rm -rf /run/flannel
rm -rf \${K3S_DATA_DIR}
clean_mounted_directory \${K3S_DATA_DIR}
rm -rf /var/lib/kubelet
rm -f ${BIN_DIR}/k3s
rm -f ${KILLALL_K3S_SH}
Expand Down

0 comments on commit 9a0c31f

Please sign in to comment.