-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathuninstall
executable file
·68 lines (58 loc) · 1.69 KB
/
uninstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/bin/bash
OS_DIR_ON_PATH="$HOME/.local/bin"
SUIBASE_DIR="$HOME/suibase"
# Function to remove suibase scripts symlinks in ~/.local/bin
# Has no effect if symlink does not exists.
remove_bin_path() {
if [ -d "$OS_DIR_ON_PATH" ]; then
if [ -L "$OS_DIR_ON_PATH/$1" ]; then
rm -f "$OS_DIR_ON_PATH/$1"
echo " Symlink removed: $OS_DIR_ON_PATH/$1"
fi
fi
}
main() {
username=$(whoami)
echo
# Call stop on every workdirs.
local _DIR_ENTRIES=("$SUIBASE_DIR"/workdirs/*)
for dir_entry in "${_DIR_ENTRIES[@]}"; do
if [ -L "$dir_entry" ]; then
# Symlink, probably the "active", just skip it.
continue
fi
if [ -d "$dir_entry" ]; then
workdir=$(basename "$dir_entry")
if [ -f "$SUIBASE_DIR/workdirs/$workdir/workdir-exec" ]; then
echo "Stopping workdir [$workdir]..."
("$SUIBASE_DIR/workdirs/$workdir/workdir-exec" stop)
fi
fi
done
# Build the list of scripts (e.g. "localnet, devnet, tsui...")
local script_list=()
for dir_entry in "$SUIBASE_DIR/"scripts/*; do
if [ -f "$dir_entry" ] && [ -x "$dir_entry" ]; then
script_list+=("$(basename "$dir_entry")")
fi
done
for script_name in "${script_list[@]}"; do
remove_bin_path "$script_name"
done
# In addition of the dynamic list, try also with a hardcoded list that we know of.
remove_bin_path "localnet"
remove_bin_path "testnet"
remove_bin_path "mainnet"
remove_bin_path "devnet"
remove_bin_path "lsui"
remove_bin_path "tsui"
remove_bin_path "msui"
remove_bin_path "dsui"
remove_bin_path "asui"
remove_bin_path "csui"
remove_bin_path "sui"
echo
echo "suibase scripts uninstalled successfully for user [$username]"
echo
}
main