Skip to content

Commit d210aeb

Browse files
Add an uninstaller script
Co-authored-by: pico_190 <picoprograma190@proton.me>
1 parent db32905 commit d210aeb

2 files changed

Lines changed: 80 additions & 0 deletions

File tree

docs/manual/install.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ Copy and paste the following code in a terminal session.
2727
curl -fsSL fuckingnode.github.io/install.sh | bash
2828
```
2929

30+
On Linux an macOS you're provided with an uninstall script we hope you never need.
31+
32+
```bash
33+
curl -fsSL fuckingnode.github.io/remove.sh | bash
34+
```
35+
3036
### :simple-nixos: Nix / NixOS
3137

3238
!!! warning

docs/remove.sh

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
INSTALL_DIR="/usr/local/fuckingnode"
6+
7+
remove_the_thing() {
8+
echo "Removing install files..."
9+
10+
if [ -d "$INSTALL_DIR" ]; then
11+
if sudo rm -rf "$INSTALL_DIR" 2>/dev/null; then
12+
echo "Removed $INSTALL_DIR entirely"
13+
else
14+
echo "Failed to remove $INSTALl_DIR."
15+
fi
16+
fi
17+
}
18+
19+
clean_path_from_file() {
20+
local file="$1"
21+
22+
[ ! -f "$file" ] && return
23+
24+
if grep -q "$INSTALL_DIR" "$file"; then
25+
cp "$file" "$file.bak_fuckingnode_$(date +%Y%m%d%H%M%S)"
26+
sed -i "\#$INSTALL_DIR#d" "$file"
27+
echo "Lines containing $INSTALL_DIR gone from $file (a backup was made just in case, .bak_fuckingnode_*)."
28+
fi
29+
}
30+
31+
clean_path_config() {
32+
echo "Clearing PATH..."
33+
34+
FILES_BASH=("$HOME/.bashrc" "$HOME/.bash_profile" "$HOME/.profile")
35+
FILES_ZSH=("$HOME/.zshrc")
36+
FISH_CONFIG="$HOME/.config/fish/config.fish"
37+
38+
for f in "${FILES_BASH[@]}"; do
39+
clean_path_from_file "$f"
40+
done
41+
42+
for f in "${FILES_ZSH[@]}"; do
43+
clean_path_from_file "$f"
44+
done
45+
46+
clean_path_from_file "$FISH_CONFIG"
47+
}
48+
49+
main() {
50+
echo "FuckingNode uninstall"
51+
echo "So sad to see you leave :("
52+
echo "This'll remove binaries, shortcuts, and PATH entries related to FuckingNode."
53+
echo ""
54+
55+
read -r -p "Proceed? [y/N]: " ans
56+
case "$ans" in
57+
y|Y|yes|YES)
58+
;;
59+
*)
60+
echo "Aborted. Thanks for staying!"
61+
exit 0
62+
;;
63+
esac
64+
65+
remove_the_thing
66+
clean_path_config
67+
68+
echo ""
69+
echo "Uninstalled successfully."
70+
echo "If you did this because you were unsatisfied with FuckingNode, please create an issue at https://github.com/FuckingNode/FuckingNode/issues/new telling us how we could improve."
71+
echo "Thank you anyways, cya!"
72+
}
73+
74+
main "$@"

0 commit comments

Comments
 (0)