Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 40 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -962,19 +962,51 @@ rm -rf /var/lib/kubelet
rm -f ${BIN_DIR}/k3s
rm -f ${KILLALL_K3S_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 k3s-selinux package if a compatible package manager is found
zypper_remove_selinux_rpm() {
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
$SUDO \$uninstall_cmd
\$uninstall_cmd
}
dnf_remove_selinux_rpm() {
package_manager=dnf
# yum is only needed for rhel 7, which is EOM since 2024 anyway
if ! type dnf >/dev/null 2>&1; then
package_manager=yum
fi
\$package_manager remove -y k3s-selinux
}
rpm_ostree_uninstall_cmd="rpm-ostree uninstall --idempotent k3s-selinux"

# shellcheck source=/dev/null
[ -r /etc/os-release ] && . /etc/os-release

if [ "\$(expr "\${ID_LIKE}" : ".*suse.*")" != 0 ]; then
zypper_remove_selinux_rpm
# cover any standard & atomic rhel/centos/fedora + derivatives like amazon linux
elif [ "\${ID:-}" = fedora ] || [ "\$(expr "\${ID_LIKE}" : ".*fedora.*\|.*rhel.*\|.*centos.*")" != 0 ]; then
if [ -n "\${OSTREE_VERSION:-}" ]; then
\$rpm_ostree_uninstall_cmd
else
dnf_remove_selinux_rpm
fi
# if we did not match yet just check for package managers commonly found on selinux-enabled distributions
elif type rpm-ostree >/dev/null 2>&1; then
\$rpm_ostree_uninstall_cmd
elif type zypper >/dev/null 2>&1; then
zypper_remove_selinux_rpm
elif type yum >/dev/null 2>&1; then
dnf_remove_selinux_rpm
elif [ -d /usr/share/selinux ]; then
echo '[WARN] Automatic removal of "k3s-selinux" package not possible, please remove it manually.' >&2
fi

if [ -d /etc/zypp/repos.d ]; then
rm -f /etc/zypp/repos.d/rancher-k3s-common*.repo
elif [ -d /etc/yum.repos.d ]; then
rm -f /etc/yum.repos.d/rancher-k3s-common*.repo
fi
EOF
$SUDO chmod 755 ${UNINSTALL_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 @@
46177d4c99440b4c0311b67233823a8e8a2fc09693f6c89af1a7161e152fbfad install.sh
0068b53a147d93bc66039b86d2834f2dce3d530f11ea5b803a158d8fda2030bc install.sh