Skip to content

Commit

Permalink
enhanced scripts/install-slim.sh to accept optional release version, …
Browse files Browse the repository at this point in the history
…added scripts/uninstall-slim.sh for quick uninstalls

Signed-off-by: Kyle Quest <kcq.public@gmail.com>
  • Loading branch information
kcq committed Jul 15, 2023
1 parent a8a7469 commit eb2793a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
12 changes: 9 additions & 3 deletions scripts/install-slim.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@ function get_slim() {
local URL=""
local VER=""

# Get the current released tag_name
VER=$(curl -sL https://api.github.com/repos/docker-slim/docker-slim/releases \
if [ -n "$1" ]; then
VER=$1
else
# Get the current released tag_name
VER=$(curl -sL https://api.github.com/repos/slimtoolkit/slim/releases \
| grep tag_name | head -n1 | cut -d'"' -f4)
fi

if [ -n "${VER}" ]; then
URL="https://downloads.dockerslim.com/releases/${VER}"
Expand Down Expand Up @@ -96,4 +100,6 @@ if [ "$(id -u)" -ne 0 ]; then
exit 1
fi

get_slim
get_slim $1

# You can pass a specific version to install otherwise the latest version will be installed
36 changes: 36 additions & 0 deletions scripts/uninstall-slim.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env bash

function uninstall_slim() {
local VER=""

# /usr/local/bin should be present on Linux and macOS hosts. Just be sure.
if [ -d /usr/local/bin ]; then
VER=$(slim --version | cut -d'|' -f3)
echo " - Uninstalling version - ${VER}"

echo " - Removing slim slim binaries from /usr/local/bin"
rm /usr/local/bin/slim
rm /usr/local/bin/slim-sensor

echo " - Removing local state directory"
rm -rfv /tmp/slim-state

echo " - Removing state volume"
docker volume rm slim-state

echo " - Removing sensor volume"
docker volume rm slim-sensor.${VER}
else
echo "ERROR! /usr/local/bin is not present. Uninstall aborted."
exit 1
fi
}

echo "Slim scripted uninstall"

if [ "$(id -u)" -ne 0 ]; then
echo "ERROR! You must run this script as root."
exit 1
fi

uninstall_slim

0 comments on commit eb2793a

Please sign in to comment.