Skip to content

Commit

Permalink
fix(autok3s): fix uninstall scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
JacieChao authored and Jason-ZW committed Jun 1, 2022
1 parent fd10894 commit dfb8b3c
Showing 1 changed file with 6 additions and 29 deletions.
35 changes: 6 additions & 29 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -302,32 +302,6 @@ create_symlinks() {
fi
}

# --- create kill process script ---
create_killprocess() {
echo "Creating kill script ${BINLOCATION}/autok3s-killall.sh"
$SUDO tee ${BINLOCATION}/autok3s-killall.sh >/dev/null << \EOF
#!/bin/sh
[ $(id -u) -eq 0 ] || exec sudo $0 $@
killtree() {
kill -9 $(
{ set +x; } 2>/dev/null;
for pid in $@; do
echo $pid
done
set -x;
) 2>/dev/null
}
pstree() {
ps -e -o pid= -o args= | sed -e 's/^ *//; s/\s\s*/\t/;' | grep -E "kube-explorer|autok3s" | cut -f1
}
killtree $({ set +x; } 2>/dev/null; pstree; set -x)
EOF
$SUDO chmod 755 ${BINLOCATION}/autok3s-killall.sh
$SUDO chown root:root ${BINLOCATION}/autok3s-killall.sh
}

# --- create uninstall script ---
create_uninstall() {
echo "Creating uninstall script ${BINLOCATION}/autok3s-uninstall.sh"
Expand All @@ -342,11 +316,15 @@ fi
remove_uninstall() {
rm -f ${BINLOCATION}/autok3s-uninstall.sh
rm -f ${BINLOCATION}/autok3s-killall.sh
}
trap remove_uninstall EXIT
${BINLOCATION}/autok3s-killall.sh
pids=\$(ps -e -o pid= -o args= | sed -e 's/^ *//; s/\s\s*/\t/;' | grep -E "kube-explorer|autok3s " | grep -v grep | cut -f1)
set +m
for pid in \$pids; do
kill -9 \$pid 2>&1
done
set -m
rm -f ${BINLOCATION}/autok3s
rm -f ${BINLOCATION}/kube-explorer
Expand All @@ -360,5 +338,4 @@ hasCli
getPackage
getKubeExplorer
create_symlinks
create_killprocess
create_uninstall

0 comments on commit dfb8b3c

Please sign in to comment.