-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuninstall.sh
More file actions
53 lines (43 loc) · 1.53 KB
/
uninstall.sh
File metadata and controls
53 lines (43 loc) · 1.53 KB
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
#!/usr/bin/env bash
set -e
CLI_LINK="$HOME/.local/bin/cvecli"
PATH_EXPORT='export PATH="$HOME/.local/bin:$PATH"'
DOCKER_ALIAS="alias cvecli='docker run --rm -it ghcr.io/debaa17/cve-scanner-cli:latest'"
REMOVED_PATH_LINE=0
REMOVED_ALIAS_LINE=0
remove_line_from_file() {
local rc_file="$1"
local line="$2"
local temp_file
if [ ! -f "$rc_file" ]; then
return
fi
if ! grep -Fqx "$line" "$rc_file"; then
return
fi
temp_file="$(mktemp)"
grep -Fvx "$line" "$rc_file" > "$temp_file" || true
mv "$temp_file" "$rc_file"
}
if [ -L "$CLI_LINK" ] || [ -f "$CLI_LINK" ]; then
rm -f "$CLI_LINK"
printf "\033[0;32mRemoved %s\033[0m\n" "$CLI_LINK"
else
printf "\033[0;33mNo cvecli launcher found at %s\033[0m\n" "$CLI_LINK"
fi
for rc_file in "$HOME/.bashrc" "$HOME/.zshrc" "$HOME/.profile"; do
if [ -f "$rc_file" ] && grep -Fqx "$PATH_EXPORT" "$rc_file"; then
remove_line_from_file "$rc_file" "$PATH_EXPORT"
REMOVED_PATH_LINE=1
printf "\033[0;32mRemoved PATH entry from %s\033[0m\n" "$rc_file"
fi
if [ -f "$rc_file" ] && grep -Fqx "$DOCKER_ALIAS" "$rc_file"; then
remove_line_from_file "$rc_file" "$DOCKER_ALIAS"
REMOVED_ALIAS_LINE=1
printf "\033[0;32mRemoved Docker alias from %s\033[0m\n" "$rc_file"
fi
done
printf "\033[0;32mUninstall complete.\033[0m\n"
if [ "$REMOVED_PATH_LINE" -eq 1 ] || [ "$REMOVED_ALIAS_LINE" -eq 1 ]; then
printf "\033[0;33mOpen a new terminal or reload your shell config to apply the shell changes.\033[0m\n"
fi