Skip to content

Commit

Permalink
Update k3s-uninstall.sh.j2
Browse files Browse the repository at this point in the history
  • Loading branch information
onedr0p committed Dec 9, 2023
1 parent c5dff15 commit 809ce1d
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions templates/k3s-uninstall.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ set -x

/usr/local/bin/k3s-killall.sh

if which systemctl; then
if command -v systemctl; then
systemctl disable k3s
systemctl reset-failed k3s
systemctl daemon-reload
fi
if which rc-update; then
if command -v rc-update; then
rc-update delete k3s default
fi

rm -f {{ k3s_systemd_unit_dir }}/k3s.service
rm -f {{ k3s_systemd_unit_dir }}/k3s.env

remove_uninstall() {
rm -f /usr/local/bin/k3s-uninstall.sh
Expand All @@ -31,20 +32,25 @@ for cmd in kubectl crictl ctr; do
fi
done

for bin in {{ k3s_install_dir }}/k3s*; do
if [ -f "${bin}" ]; then
rm -f "${bin}"
fi
done

rm -rf {{ k3s_config_dir }}
rm -rf /etc/rancher/k3s
rm -rf /run/k3s
rm -rf /run/flannel
rm -rf {{ k3s_runtime_config['data-dir'] | default(k3s_data_dir) }}
rm -rf /var/lib/kubelet
rm -f {{ k3s_install_dir }}/k3s
rm -f /usr/local/bin/k3s-killall.sh

if type yum >/dev/null 2>&1; then
yum remove -y k3s-selinux
rm -f /etc/yum.repos.d/rancher-k3s-common*.repo
elif type rpm-ostree >/dev/null 2>&1; then
rpm-ostree uninstall k3s-selinux
rm -f /etc/yum.repos.d/rancher-k3s-common*.repo
elif type zypper >/dev/null 2>&1; then
uninstall_cmd="zypper remove -y k3s-selinux"
if [ "${TRANSACTIONAL_UPDATE=false}" != "true" ] && [ -x /usr/sbin/transactional-update ]; then
uninstall_cmd="transactional-update --no-selfupdate -d run $uninstall_cmd"
fi
$uninstall_cmd
rm -f /etc/zypp/repos.d/rancher-k3s-common*.repo
fi

0 comments on commit 809ce1d

Please sign in to comment.