-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.sh
executable file
·53 lines (45 loc) · 1.41 KB
/
install.sh
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
#!/bin/bash
shellFile=""
if [ -n "$($SHELL -c 'echo $ZSH_VERSION')" ]; then
shellFile=".zshrc"
elif [ -n "$($SHELL -c 'echo $BASH_VERSION')" ]; then
shellFile=".bashrc"
else
echo "no installation script found for this, please install manually"
exit 0
fi
platform=''
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
platform="linux-amd64"
elif [[ "$OSTYPE" == "darwin"* ]]; then
if [[ $(sysctl -n machdep.cpu.brand_string) == *"Apple"* ]]; then
platform="darwin-arm64"
else
platform="darwin-amd64"
fi
else
echo "platform not supported"
exit 0
fi
platform="deps-cleaner-$platform"
tagName=$(curl -s https://api.github.com/repos/bhumit070/deps-cleaner/releases/latest | awk -F'"tag_name":' '{print $2}' | awk -F'"' '{print $2}' | xargs)
downloadableUrl="https://github.com/bhumit070/deps-cleaner/releases/download/$tagName/$platform"
echo "downloading..."
installDir="$HOME/.deps-cleaner"
destinationPath="$installDir/deps-cleaner"
mkdir -p "$installDir"
curl -# -L "$downloadableUrl" -o "$destinationPath" && chmod +x "$destinationPath"
command="export PATH=\$PATH:\$HOME/.deps-cleaner"
if grep -q "$command" "$HOME/$shellFile"; then
echo "already installed."
exit 0
fi
echo $command >>"$HOME/$shellFile"
echo "Changes applied. Reload shell now? [y/N]"
read -r answer
if [[ "$answer" =~ ^[Yy]$ ]]; then
exec "$SHELL" -l
else
echo "You can reload the shell later by running: exec \"\$SHELL\" -l"
fi
echo "installation completed."