aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-containers/k3s/k3s/k3s-clean
blob: 8eca918c05184976220f5982eb9e04ff4f4a2e3a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/sh -eu
#
# Copyright (C) 2020 Axis Communications AB
#
# SPDX-License-Identifier: Apache-2.0

do_unmount() {
	[ $# -eq 2 ] || return
	local mounts=
	while read ignore mount ignore; do
		case $mount in
			$1/*|$2/*)
				mounts="$mount $mounts"
				;;
		esac
	done </proc/self/mounts
	[ -z "$mounts" ] || umount $mounts
}

do_unmount /run/k3s /var/lib/rancher/k3s

# The lines below come from install.sh's create_killall() function:
ip link show 2>/dev/null | grep 'master cni0' | while read ignore iface ignore; do
    iface=${iface%%@*}
    [ -z "$iface" ] || ip link delete $iface
done

ip link delete cni0
ip link delete flannel.1
rm -rf /var/lib/cni/