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
50 changes: 41 additions & 9 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ get_pr_artifact_url() {
if [ -z "${commit_id}" ]; then
fatal "Installing PR builds requires GITHUB_TOKEN with k3s-io/k3s repo permissions"
fi

get_commit_artifact_url "${commit_id}"
}

Expand Down Expand Up @@ -968,19 +968,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 @@
448f9207d4d566066269d5f8950a457aced691aadf9d455a98dfd1dc1b75bef3 install.sh
da0e70ee96ecbf9b38bd03e62ea2e8780200b492226f3571a5cb42a74af16515 install.sh
Loading