Skip to content
  • Sponsor
  • Notifications You must be signed in to change notification settings
  • Fork 2

Commit 7d4cab9

Browse files
authoredJul 19, 2024
Fix install script (#8)
* Update install_libchdb.sh * Update install_libchdb.sh * Update install_libchdb.sh * Update install_libchdb.sh
1 parent a400fd0 commit 7d4cab9

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed
 

‎install_libchdb.sh

+34-11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,28 @@ set -e
66
command -v curl >/dev/null 2>&1 || { echo >&2 "curl is required but it's not installed. Aborting."; exit 1; }
77
command -v tar >/dev/null 2>&1 || { echo >&2 "tar is required but it's not installed. Aborting."; exit 1; }
88

9+
# Function to download and extract the file
10+
download_and_extract() {
11+
local url=$1
12+
local file="libchdb.tar.gz"
13+
14+
echo "Attempting to download $PLATFORM from $url"
15+
16+
# Download the file with a retry logic
17+
if curl -L -o "$file" "$url"; then
18+
echo "Download successful."
19+
20+
# Optional: Verify download integrity here, if checksums are provided
21+
22+
# Untar the file
23+
if tar -xzf "$file"; then
24+
echo "Extraction successful."
25+
return 0
26+
fi
27+
fi
28+
return 1
29+
}
30+
931
# Get the newest release version
1032
LATEST_RELEASE=$(curl --silent "https://api.github.com/repos/chdb-io/chdb/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
1133

@@ -31,17 +53,18 @@ case "$(uname -s)" in
3153
;;
3254
esac
3355

56+
# Main download URL
3457
DOWNLOAD_URL="https://github.com/chdb-io/chdb/releases/download/$LATEST_RELEASE/$PLATFORM"
58+
FALLBACK_URL="https://github.com/chdb-io/chdb/releases/latest/download/$PLATFORM"
3559

36-
echo "Downloading $PLATFORM from $DOWNLOAD_URL"
37-
38-
# Download the file
39-
curl -L -o libchdb.tar.gz $DOWNLOAD_URL
40-
41-
# Optional: Verify download integrity here, if checksums are provided
42-
43-
# Untar the file
44-
tar -xzf libchdb.tar.gz
60+
# Try the main download URL first
61+
if ! download_and_extract "$DOWNLOAD_URL"; then
62+
echo "Retrying with fallback URL..."
63+
if ! download_and_extract "$FALLBACK_URL"; then
64+
echo "Both primary and fallback downloads failed. Aborting."
65+
exit 1
66+
fi
67+
fi
4568

4669
# If current uid is not 0, check if sudo is available and request the user to input the password
4770
if [[ $EUID -ne 0 ]]; then
@@ -88,5 +111,5 @@ fi
88111
rm -f libchdb.tar.gz libchdb.so chdb.h
89112

90113
GREENECHO "Installation completed successfully." ; ENDECHO
91-
REDECHO "If any error occurred, please report it to:" ; ENDECHO
92-
REDECHO " https://github.com/chdb-io/chdb/issues/new/choose" ; ENDECHO
114+
GREENECHO "If any error occurred, please report it to:" ; ENDECHO
115+
GREENECHO " https://github.com/chdb-io/chdb/issues/new/choose" ; ENDECHO

0 commit comments

Comments
 (0)