-
Notifications
You must be signed in to change notification settings - Fork 35
/
install.sh
51 lines (44 loc) · 1.37 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
#!/usr/bin/env bash
# edited from deno_install
set -e
if ! command -v unzip >/dev/null; then
echo "Error: unzip is required to install ipgw." 1>&2
exit 1
fi
if [ "$OS" = "Windows_NT" ]; then
target="windows-amd64"
else
case $(uname -sm) in
"Darwin x86_64") target="darwin-amd64" ;;
"Darwin arm64") target="darwin-arm64" ;;
"FreeBSD x86_64") target="freebsd-amd64" ;;
"FreeBSD i386") target="freebsd-386" ;;
"Linux x86_64") target="linux-amd64" ;;
"Linux arm") target="linux-arm" ;;
"Linux i386") target="linux-386" ;;
"Linux mips64") target="linux-mips64" ;;
"Linux mips64le") target="linux-mips64le" ;;
esac
fi
download_url="https://github.com/neucn/ipgw/releases/latest/download/ipgw-${target}.zip"
bin_dir="/usr/local/bin"
target_path="$bin_dir/ipgw"
if [ ! -d "$bin_dir" ]; then
mkdir -p "$bin_dir"
fi
curl --fail --location --progress-bar --output "$target_path.zip" "$download_url"
unzip -d "$bin_dir" -o "$target_path.zip"
chmod +x "$target_path"
rm "$target_path.zip"
echo "ipgw was installed successfully to $target_path"
if command -v ipgw >/dev/null; then
echo "Run 'ipgw --help' to get started"
else
case $SHELL in
/bin/zsh) shell_profile=".zshrc" ;;
*) shell_profile=".bash_profile" ;;
esac
echo "Manually add the directory to your \$HOME/$shell_profile (or similar)"
echo " export PATH=\"$bin_dir:\$PATH\""
echo "Run '$target_path --help' to get started"
fi