Unknown issue with k3s-uninstall.sh exiting with 1.

The script looks to be completing without error in my testing as well as
in the original issue so I am forcing an exit with 0 until the cause can
be found.

Fixes #23
This commit is contained in:
Xan Manning 2020-05-16 21:19:48 +01:00
parent aa1a0a9620
commit 26467de186
1 changed files with 32 additions and 18 deletions

View File

@ -1,44 +1,58 @@
#!/bin/sh
#!/usr/bin/env bash
set -x
[ $(id -u) -eq 0 ] || exec sudo $0 $@
set -xeuo pipefail
/usr/local/bin/k3s-killall.sh
[[ "$(id -u)" -eq 0 ]] || exec sudo "${0}" "${@}"
if which systemctl; then
remove_uninstall() {
[ -f "${0}" ] && rm -- "${0}"
exit 0
}
trap remove_uninstall EXIT
/usr/local/bin/k3s-killall.sh ; echo "k3s-killall.sh exited ${?} ..."
WSYSCTL=$(which systemctl || true)
if [[ "${WSYSCTL}" != "" ]] ; then
systemctl disable k3s
systemctl reset-failed k3s
systemctl daemon-reload
fi
if which rc-update; then
WRCUPD=$(which rc-update || true)
if [[ "${WRCUPD}" != "" ]] ; then
rc-update delete k3s default
fi
for unit in /etc/systemd/system/k3s*.service; do
[ -f "$unit" ] && rm -f "$unit"
done
K3SSVC=$(ls /etc/systemd/system/k3s*.service || true)
remove_uninstall() {
[ -f /usr/local/bin/k3s-uninstall.sh ] && rm -f /usr/local/bin/k3s-uninstall.sh
}
trap remove_uninstall EXIT
if [[ "${K3SSVC}" != "" ]] ; then
for unit in /etc/systemd/system/k3s*.service ; do
[ -f "${unit}" ] && rm -f "${unit}"
done
fi
if (ls /etc/systemd/system/k3s*.service || ls /etc/init.d/k3s*) >/dev/null 2>&1; then
K3SINIT=$(ls /etc/init.d/k3s* || true)
if [[ "${K3SINIT}" != "" ]] ; then
set +x; echo 'Additional k3s services installed, skipping uninstall of k3s'; set -x
exit
fi
for cmd in kubectl crictl ctr; do
if [ -L "{{ k3s_install_dir }}/$cmd" ]; then
rm -f "{{ k3s_install_dir }}/$cmd"
for cmd in {kubectl,crictl,ctr} ; do
if [ -L "{{ k3s_install_dir }}/${cmd}" ]; then
rm -f "{{ k3s_install_dir }}/${cmd}"
fi
done
[ -d /etc/rancher/k3s ] && rm -rf /etc/rancher/k3s
[ -d /var/lib/rancher/k3s ] && rm -rf /var/lib/rancher/k3s
[ -d /var/lib/kubelet ] && rm -rf /var/lib/kubelet
for bin in {{ k3s_install_dir }}/k3s*; do
[ -f "$bin" ] && rm -f "$bin"
[ -f "${bin}" ] && rm -f "${bin}"
done
[ -f /usr/local/bin/k3s-killall.sh ] && rm -f /usr/local/bin/k3s-killall.sh