-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_oss.sh
95 lines (79 loc) · 2.49 KB
/
install_oss.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
#!/bin/bash
# GitHub user/repo
USER_REPO="timeplus-io/proton"
# Fetch the latest release tag from GitHub
LATEST_TAG=$(curl -s https://api.github.com/repos/$USER_REPO/releases/latest | grep 'tag_name' | cut -d\" -f4)
# Check if the tag is empty
if [ -z "$LATEST_TAG" ]; then
echo "Failed to fetch the latest release tag from GitHub." >&2
exit 1
fi
# Identify the system's OS and architecture
OS=$(uname -s)
ARCH=$(uname -m)
# Map the architecture to the binary naming convention
case $ARCH in
"x86_64")
ARCH="x86_64"
;;
"arm64" | "aarch64")
if [ "$OS" == "Darwin" ]; then
ARCH="arm64"
else
ARCH="aarch64"
fi
;;
*)
echo "Currently, https://github.com/timeplus-io/proton does not support $OS-$ARCH releases. You can try our docker image\
with \
\$ docker pull ghcr.io/timeplus-io/proton" >&2
exit 1
;;
esac
# Binary file name
BINARY_FILE="proton-${LATEST_TAG}-${OS}-${ARCH}"
TARGET_FILE="proton"
# Check if the proton file exists
# Fix me, what if I wanna use this script 3 times?
# if `proton` not exist, we use proton
# else
# 1.use `"proton-${LATEST_TAG}-${OS}-${ARCH}"` (by default)
# 2.overwrite it(only work on manual bash install.sh)
if [ -f "$TARGET_FILE" ]; then
read -p "'proton' file already exists. Do you want to overwrite it? (y/n): " answer
if [ "$answer" = "y" -o "$answer" = "Y" ]; then
TARGET_FILE="proton"
else
TARGET_FILE=$BINARY_FILE
fi
fi
# Download URL
DOWNLOAD_URL="https://d.timeplus.com/${BINARY_FILE}"
# Download the binary
echo "Downloading $TARGET_FILE..."
curl -L -o "$TARGET_FILE" "$DOWNLOAD_URL"
# Check if the download was successful
if [ $? -eq 0 ]; then
# Make the file executable
chmod u+x "$TARGET_FILE"
echo "Download and permission setting completed: $TARGET_FILE"
echo "
To interact with Proton:
1. Start the Proton server(data store in current folder ./proton-data/ ):
./$TARGET_FILE server
2. In a separate terminal, connect to the server:
./$TARGET_FILE client
(Note: If you encounter a 'connection refused' error, use: ./$TARGET_FILE client --host 127.0.0.1)
3. To terminate the server, press ctrl+c in the server terminal.
For detailed usage and more information, check out the Timeplus documentation:
https://docs.timeplus.com/"
else
echo "Download failed or the binary for $OS-$ARCH is not available." >&2
exit 1
fi
if [ "${OS}" = "Linux" ]
then
echo
echo "You can also install it(data store in /var/lib/proton/):
sudo ./${TARGET_FILE} install"
fi