Support Windows in install-safe-shain.sh (git bash, cygwin, ...)

This commit is contained in:
Sander Declerck 2026-01-20 12:53:18 +01:00
parent f358709ab2
commit 99cd416628
No known key found for this signature in database

View file

@ -42,8 +42,9 @@ detect_os() {
echo "linuxstatic" echo "linuxstatic"
fi fi
;; ;;
Darwin*) echo "macos" ;; Darwin*) echo "macos" ;;
*) error "Unsupported operating system: $(uname -s)" ;; MINGW*|MSYS*|CYGWIN*) echo "win" ;;
*) error "Unsupported operating system: $(uname -s)" ;;
esac esac
} }
@ -293,7 +294,11 @@ main() {
# Detect platform # Detect platform
OS=$(detect_os) OS=$(detect_os)
ARCH=$(detect_arch) ARCH=$(detect_arch)
BINARY_NAME="safe-chain-${OS}-${ARCH}" if [ "$OS" = "win" ]; then
BINARY_NAME="safe-chain-${OS}-${ARCH}.exe"
else
BINARY_NAME="safe-chain-${OS}-${ARCH}"
fi
info "Detected platform: ${OS}-${ARCH}" info "Detected platform: ${OS}-${ARCH}"
@ -311,9 +316,15 @@ main() {
download "$DOWNLOAD_URL" "$TEMP_FILE" download "$DOWNLOAD_URL" "$TEMP_FILE"
# Rename and make executable # Rename and make executable
FINAL_FILE="${INSTALL_DIR}/safe-chain" if [ "$OS" = "win" ]; then
FINAL_FILE="${INSTALL_DIR}/safe-chain.exe"
else
FINAL_FILE="${INSTALL_DIR}/safe-chain"
fi
mv "$TEMP_FILE" "$FINAL_FILE" || error "Failed to move binary to $FINAL_FILE" mv "$TEMP_FILE" "$FINAL_FILE" || error "Failed to move binary to $FINAL_FILE"
chmod +x "$FINAL_FILE" || error "Failed to make binary executable" if [ "$OS" != "win" ]; then
chmod +x "$FINAL_FILE" || error "Failed to make binary executable"
fi
info "Binary installed to: $FINAL_FILE" info "Binary installed to: $FINAL_FILE"