mirror of
https://github.com/k3s-io/k3s.git
synced 2024-06-07 19:41:36 +00:00
Merge pull request #902 from erikwilson/cleanup-install
Cleanup killall script
This commit is contained in:
commit
fd8667a935
15
install.sh
15
install.sh
@ -463,27 +463,36 @@ pstree() {
|
||||
}
|
||||
|
||||
killtree() {
|
||||
[ $# -ne 0 ] && kill $(set +x; pstree $@; set -x)
|
||||
kill -9 $({ set +x; } 2>/dev/null; pstree $@; set -x) 2>/dev/null
|
||||
}
|
||||
|
||||
killtree $(lsof | sed -e 's/^[^0-9]*//g; s/ */\t/g' | grep -w 'k3s/data/[^/]*/bin/containerd-shim' | cut -f1 | sort -n -u)
|
||||
getshims() {
|
||||
lsof | sed -e 's/^[^0-9]*//g; s/ */\t/g' | grep -w 'k3s/data/[^/]*/bin/containerd-shim' | cut -f1 | sort -n -u
|
||||
}
|
||||
|
||||
killtree $({ set +x; } 2>/dev/null; getshims; set -x)
|
||||
|
||||
do_unmount() {
|
||||
{ set +x; } 2>/dev/null
|
||||
MOUNTS=
|
||||
while read ignore mount ignore; do
|
||||
MOUNTS="$mount\n$MOUNTS"
|
||||
done </proc/self/mounts
|
||||
MOUNTS=$(printf $MOUNTS | grep "^$1" | sort -r)
|
||||
if [ -n "${MOUNTS}" ]; then
|
||||
set -x
|
||||
umount ${MOUNTS}
|
||||
else
|
||||
set -x
|
||||
fi
|
||||
}
|
||||
|
||||
do_unmount '/run/k3s'
|
||||
do_unmount '/var/lib/rancher/k3s'
|
||||
do_unmount '/run/netns/cni-'
|
||||
|
||||
# Delete network interface(s) that match 'master cni0'
|
||||
ip link show | grep 'master cni0' | while read ignore iface ignore; do
|
||||
ip link show 2>/dev/null | grep 'master cni0' | while read ignore iface ignore; do
|
||||
iface=${iface%%@*}
|
||||
[ -z "$iface" ] || ip link delete $iface
|
||||
done
|
||||
|
Loading…
Reference in New Issue
Block a user