-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.sh
executable file
·106 lines (92 loc) · 2.55 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
set -e
USER="devnazir"
REPO="ip-address-language"
API_URL="https://api.github.com/repos/${USER}/${REPO}/releases/latest"
ARCH=$(uname -m)
OS=$(uname -s)
BIN_NAME="ipl"
echo "Downloading..."
# Get the latest release from GitHub API
latest_tag=$(curl -s $API_URL | grep 'tag_name' | cut -d\" -f4)
tag_without_v=$(echo $latest_tag | cut -c 2-) # Remove the leading 'v' from the tag
echo "Latest release: $latest_tag"
if [ -z "$latest_tag" ]; then
echo "Failed to get latest release"
exit 1
fi
# Construct the correct file name based on OS and architecture
case $OS in
Darwin)
case $ARCH in
x86_64)
ARCH_BIN="${REPO}_${tag_without_v}_darwin_amd64.tar.gz"
;;
arm64)
ARCH_BIN="${REPO}_${tag_without_v}_darwin_arm64.tar.gz"
;;
*)
echo "Unsupported architecture: $ARCH on macOS"
exit 1
;;
esac
;;
Linux)
case $ARCH in
x86_64)
ARCH_BIN="${REPO}_${tag_without_v}_linux_amd64.tar.gz"
;;
i386|i686)
ARCH_BIN="${REPO}_${tag_without_v}_linux_386.tar.gz"
;;
aarch64)
ARCH_BIN="${REPO}_${tag_without_v}_linux_arm64.tar.gz"
;;
armv7l)
ARCH_BIN="${REPO}_${tag_without_v}_linux_armv7.tar.gz"
;;
*)
echo "Unsupported architecture: $ARCH on Linux"
exit 1
;;
esac
;;
CYGWIN*|MINGW*|MSYS*)
# For Windows (using Cygwin, MinGW, or MSYS)
case $ARCH in
x86_64)
ARCH_BIN="${REPO}_${tag_without_v}_windows_amd64.tar.gz"
;;
i386|i686)
ARCH_BIN="${REPO}_${tag_without_v}_win_386.tar.gz"
;;
*)
echo "Unsupported architecture: $ARCH on Windows"
exit 1
;;
esac
;;
*)
echo "Unsupported OS: $OS"
exit 1
;;
esac
# Construct the URL to download the archive
ARCHIVE_URL="https://github.com/${USER}/${REPO}/releases/download/${latest_tag}/${ARCH_BIN}"
echo "Downloading $ARCHIVE_URL"
# Download the latest release tar.gz archive
curl -L -o /tmp/$REPO.tar.gz $ARCHIVE_URL
# Extract the archive
tar -xzvf /tmp/$REPO.tar.gz -C /tmp
# Copy the binary to /usr/local/bin (Linux/macOS) or equivalent on Windows
if [[ "$OS" == "Darwin" || "$OS" == "Linux" ]]; then
sudo cp /tmp/$REPO /usr/local/bin/$BIN_NAME
elif [[ "$OS" == "CYGWIN"* || "$OS" == "MINGW"* || "$OS" == "MSYS"* ]]; then
cp /tmp/$REPO.exe /c/Program\ Files/$REPO/$BIN_NAME.exe
else
echo "Unsupported OS: $OS"
exit 1
fi
# Clean up
rm -rf /tmp/$REPO.tar.gz /tmp/${REPO}-${latest_tag}
echo "Installed ip-address-lang ${latest_tag}"