6
6
command -v curl > /dev/null 2>&1 || { echo >&2 " curl is required but it's not installed. Aborting." ; exit 1; }
7
7
command -v tar > /dev/null 2>&1 || { echo >&2 " tar is required but it's not installed. Aborting." ; exit 1; }
8
8
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
+
9
31
# Get the newest release version
10
32
LATEST_RELEASE=$( curl --silent " https://api.github.com/repos/chdb-io/chdb/releases/latest" | grep ' "tag_name":' | sed -E ' s/.*"([^"]+)".*/\1/' )
11
33
@@ -31,17 +53,18 @@ case "$(uname -s)" in
31
53
;;
32
54
esac
33
55
56
+ # Main download URL
34
57
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 "
35
59
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
45
68
46
69
# If current uid is not 0, check if sudo is available and request the user to input the password
47
70
if [[ $EUID -ne 0 ]]; then
88
111
rm -f libchdb.tar.gz libchdb.so chdb.h
89
112
90
113
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