Skip to content

Commit 14ad643

Browse files
committed
update setup/uninstall
1 parent bbb0fc9 commit 14ad643

2 files changed

Lines changed: 47 additions & 36 deletions

File tree

‎setup‎

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,31 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
# === Setup SSI ===
5-
6-
echo "Initializing installer..."
7-
tmpdir="$(mktemp -d)"
8-
trap 'rm -rf "$tmpdir"' EXIT
9-
cd "$tmpdir"
10-
export PATH="$tmpdir:$PATH"
11-
12-
if command -v curl >/dev/null 2>&1; then
13-
curl -fSsL https://github.com/DannyBen/ssi/releases/download/v0.1.4/ssi -o ssi
14-
elif command -v wget >/dev/null 2>&1; then
15-
wget -nv -O ssi https://github.com/DannyBen/ssi/releases/download/v0.1.4/ssi
16-
else
17-
echo "Error: please install wget or curl, then try again" >&2
18-
exit 1
19-
fi
20-
chmod +x ssi
21-
22-
# === Install ===
23-
4+
prepare_installer() {
5+
echo "Initializing installer..."
6+
SSI_VERSION="0.1.8"
7+
8+
# Set up tmp dir where all work is done
9+
tmpdir="$(mktemp -d)"
10+
trap 'rm -rf "$tmpdir"' EXIT
11+
cd "$tmpdir"
12+
export PATH="$tmpdir:$PATH"
13+
14+
# Download ssi if needed
15+
if ! command -v ssi >/dev/null 2>&1 || [ "$(ssi --version 2>/dev/null)" != "$SSI_VERSION" ]; then
16+
if command -v curl >/dev/null 2>&1; then
17+
curl -fSsL https://github.com/DannyBen/ssi/releases/download/v$SSI_VERSION/ssi -o ssi
18+
elif command -v wget >/dev/null 2>&1; then
19+
wget -nv -O ssi https://github.com/DannyBen/ssi/releases/download/v$SSI_VERSION/ssi
20+
else
21+
echo "Error: please install wget or curl, then try again" >&2
22+
exit 1
23+
fi
24+
chmod +x ssi
25+
fi
26+
}
27+
28+
prepare_installer
2429
ssi log info "Installing fuzzycd"
2530
ssi install bin https://github.com/DannyBen/fuzzycd/releases/latest/download/fuzzycd
2631

‎uninstall‎

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,31 @@
11
#!/usr/bin/env bash
22
set -euo pipefail
33

4-
# === Setup SSI ===
4+
prepare_installer() {
5+
echo "Initializing installer..."
6+
SSI_VERSION="0.1.8"
57

6-
echo "Initializing installer..."
7-
tmpdir="$(mktemp -d)"
8-
trap 'rm -rf "$tmpdir"' EXIT
9-
cd "$tmpdir"
10-
export PATH="$tmpdir:$PATH"
8+
# Set up tmp dir where all work is done
9+
tmpdir="$(mktemp -d)"
10+
trap 'rm -rf "$tmpdir"' EXIT
11+
cd "$tmpdir"
12+
export PATH="$tmpdir:$PATH"
1113

12-
if command -v curl >/dev/null 2>&1; then
13-
curl -fSsL https://github.com/DannyBen/ssi/releases/download/v0.1.4/ssi -o ssi
14-
elif command -v wget >/dev/null 2>&1; then
15-
wget -nv -O ssi https://github.com/DannyBen/ssi/releases/download/v0.1.4/ssi
16-
else
17-
echo "Error: please install wget or curl, then try again" >&2
18-
exit 1
19-
fi
20-
chmod +x ssi
14+
# Download ssi if needed
15+
if ! command -v ssi >/dev/null 2>&1 || [ "$(ssi --version 2>/dev/null)" != "$SSI_VERSION" ]; then
16+
if command -v curl >/dev/null 2>&1; then
17+
curl -fSsL https://github.com/DannyBen/ssi/releases/download/v$SSI_VERSION/ssi -o ssi
18+
elif command -v wget >/dev/null 2>&1; then
19+
wget -nv -O ssi https://github.com/DannyBen/ssi/releases/download/v$SSI_VERSION/ssi
20+
else
21+
echo "Error: please install wget or curl, then try again" >&2
22+
exit 1
23+
fi
24+
chmod +x ssi
25+
fi
26+
}
2127

22-
# === Uninstall ===
28+
prepare_installer
2329

2430
ssi log info "Uninstalling fuzzycd"
2531
ssi uninstall bin fuzzycd

0 commit comments

Comments
 (0)