Skip to content

Commit 76cda3c

Browse files
committed
feat: enhance installer compatibility and robustness across platforms
- Improve Windows detection by recognizing WSL and Cygwin environments - Add support for the armv7 architecture - Refine error messages to include armv7 in the supported architectures list - Add error handling when setting executable permissions and renaming files during installation - Notify user upon successful installation completion - Strengthen warnings for insecure CURL usage, emphasizing security risks Signed-off-by: appleboy <[email protected]>
1 parent 4f033d1 commit 76cda3c

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

install.sh

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ function log_error() {
3030
}
3131

3232
function detect_client_info() {
33+
# Detect WSL or Cygwin as windows
34+
if [[ "${CLIENT_PLATFORM}" =~ ^(mingw|cygwin|msys)_nt* ]] || grep -qi microsoft /proc/version 2>/dev/null; then
35+
CLIENT_PLATFORM="windows"
36+
fi
37+
3338
case "${CLIENT_PLATFORM}" in
3439
darwin | linux | windows) ;;
3540
*) log_error "Unknown or unsupported platform: ${CLIENT_PLATFORM}. Supported platforms are Linux, Darwin, and Windows." 2 ;;
@@ -38,7 +43,8 @@ function detect_client_info() {
3843
case "${CLIENT_ARCH}" in
3944
x86_64* | i?86_64* | amd64*) CLIENT_ARCH="amd64" ;;
4045
aarch64* | arm64*) CLIENT_ARCH="arm64" ;;
41-
*) log_error "Unknown or unsupported architecture: ${CLIENT_ARCH}. Supported architectures are x86_64, i686, and arm64." 3 ;;
46+
armv7l*) CLIENT_ARCH="arm-7" ;;
47+
*) log_error "Unknown or unsupported architecture: ${CLIENT_ARCH}. Supported architectures are x86_64, i686, arm64, armv7." 3 ;;
4248
esac
4349
}
4450

@@ -50,9 +56,9 @@ function download_and_install() {
5056
TARGET="$INSTALL_DIR/${CLIENT_BINARY}"
5157

5258
curl -# -fSL --retry 5 --keepalive-time 2 ${INSECURE_OPTION} "${DOWNLOAD_URL_PREFIX}/${CLIENT_BINARY}" -o "${TARGET}"
53-
chmod +x "${TARGET}"
59+
chmod +x "${TARGET}" || log_error "Failed to set executable permission on: ${TARGET}" 7
5460
# Rename the binary to codegpt
55-
mv "${TARGET}" "${INSTALL_DIR}/codegpt"
61+
mv "${TARGET}" "${INSTALL_DIR}/codegpt" || log_error "Failed to rename ${TARGET} to ${INSTALL_DIR}/codegpt" 8
5662
# show the version
5763
print_message info "Installed ${ORANGE}${CLIENT_BINARY}${NC} to ${GREEN}${INSTALL_DIR}${NC}"
5864
print_message info "Run ${ORANGE}codegpt version${NC} to show the version"
@@ -61,6 +67,7 @@ function download_and_install() {
6167
"${INSTALL_DIR}/codegpt" version
6268
print_message info "==============================="
6369
print_message info ""
70+
print_message info "Installation completed successfully!"
6471
}
6572

6673
function add_to_path() {
@@ -100,7 +107,8 @@ if [[ "${CURL_INSECURE}" != 'true' && "${CURL_INSECURE}" != 'false' ]]; then
100107
log_error "CURL_INSECURE must be either 'true' or 'false'" 4
101108
fi
102109
if [[ "${CURL_INSECURE}" == 'true' ]]; then
103-
print_message warning "CURL_INSECURE is set to true. Proceeding with insecure download."
110+
print_message warning "WARNING: CURL_INSECURE is set to true. Proceeding with insecure download."
111+
print_message warning "WARNING: You are bypassing SSL certificate verification. This is insecure and may expose you to man-in-the-middle attacks."
104112
fi
105113
INSECURE_OPTION=""
106114
if [[ "${CURL_INSECURE}" == 'true' ]]; then

0 commit comments

Comments
 (0)