From 19f8ba24b55f1e500dce848d3643eee64b1620b6 Mon Sep 17 00:00:00 2001 From: Vitor Savian Date: Tue, 25 Jun 2024 12:05:28 -0300 Subject: [PATCH] Add a change for killall to not unmount server and agent directory Signed-off-by: Vitor Savian Add recursive search and deletion of unmounted/mounted dirs in killall Signed-off-by: Vitor Savian Only clean the server and agent directory if it is uninstall Signed-off-by: Vitor Savian --- install.sh | 22 ++++++++++++++++++++-- install.sh.sha256sum | 2 +- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/install.sh b/install.sh index a1ed2c7b0eac..502c46196191 100755 --- a/install.sh +++ b/install.sh @@ -843,7 +843,6 @@ do_unmount_and_remove() { } do_unmount_and_remove '/run/k3s' -do_unmount_and_remove "${K3S_DATA_DIR}" do_unmount_and_remove '/var/lib/kubelet/pods' do_unmount_and_remove '/var/lib/kubelet/plugins' do_unmount_and_remove '/run/netns/cni-' @@ -902,10 +901,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} diff --git a/install.sh.sha256sum b/install.sh.sha256sum index f3ddf5f71fd2..a9299f3af2c2 100644 --- a/install.sh.sha256sum +++ b/install.sh.sha256sum @@ -1 +1 @@ -937085bbac8e3b55209739762e05c2c1006c4f4fe65dba01908f3544dc47da27 install.sh +e10b36efb5e7e7692f144582d09f5909a91c5b5996965d643dbe13282befcfc1 install.sh