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 16, 2024
1 parent 58ab259 commit 19f8ba2
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
22 changes: 20 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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-'
Expand Down Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion install.sh.sha256sum
Original file line number Diff line number Diff line change
@@ -1 +1 @@
937085bbac8e3b55209739762e05c2c1006c4f4fe65dba01908f3544dc47da27 install.sh
e10b36efb5e7e7692f144582d09f5909a91c5b5996965d643dbe13282befcfc1 install.sh

0 comments on commit 19f8ba2

Please sign in to comment.