-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathinstall.sh
executable file
·90 lines (76 loc) · 2.18 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/bin/bash
set -e
error() {
echo -e "error:" "$@" >&2
exit 1
}
if [[ ${OS:-} = Windows_NT ]]; then
error "This installer does not support Windows."
fi
echo "Installing flyscrape"
case $(uname -ms) in
'Darwin x86_64')
target=darwin_amd64
;;
'Darwin arm64')
target=darwin_arm64
;;
'Linux aarch64' | 'Linux arm64')
target=linux_arm64
;;
'Linux x86_64' | *)
target=linux_amd64
;;
esac
dir="$HOME/.flyscrape"
mkdir -p "$dir" ||
error "Failed to create directory: $HOME/.flyscrape"
archive="$dir/flyscrape_$target.tar.gz"
url="https://github.com/philippta/flyscrape/releases/latest/download/flyscrape_0.9.0_$target.tar.gz"
curl --fail --location --progress-bar --output "$archive" "$url" ||
error "Failed to download flyscrape from: $url"
tar -xzf "$archive" -C "$dir" ||
error "Failed to extract downloaded archive."
chmod +x "$dir/flyscrape" ||
error "Failed to chmod the flyscrape executable."
rm "$archive" "$dir/README.md" "$dir/LICENSE" ||
error "Failed to clean up the downloaded archive."
case $(basename "$SHELL") in
zsh)
# Add paths to zsh
if [[ ":$PATH:" != *":$HOME/.flyscrape:"* ]]; then
if [[ -w "$HOME/.zshrc" ]]; then
echo "# flyscrape" >> "$HOME/.zshrc"
echo "export PATH=\"$dir:\$PATH\"" >> "$HOME/.zshrc"
else
echo ""
echo "Manually add the directory to ~/.zshrc (or similar):"
echo " export PATH=\"$dir:\$PATH\""
fi
fi
;;
bash)
# Add paths to bbash
if [[ ":$PATH:" != *":$HOME/.flyscrape:"* ]]; then
if [[ -w "$HOME/.bashrc" ]]; then
echo "# flyscrape" >> "$HOME/.bashrc"
echo "export PATH=$dir:\$PATH" >> "$HOME/.bashrc"
else
echo ""
echo "Manually add the directory to ~/.bashrc (or similar):"
echo " export PATH=$dir:\$PATH"
fi
fi
;;
*)
echo ""
echo "Manually add the directory to ~/.bashrc (or similar):"
echo " export PATH=$dir:\$PATH"
;;
esac
echo ""
echo "The installation was successfull!"
echo ""
echo "Note:"
echo "Please restart your terminal window. This ensures your system correctly detects flyscrape."
echo ""