-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch_binary_libraries.sh
More file actions
83 lines (72 loc) · 2.79 KB
/
fetch_binary_libraries.sh
File metadata and controls
83 lines (72 loc) · 2.79 KB
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
#!/bin/bash
# Configuration
SDK_NAME="VSBarcodeReader-iOS-EVAL"
VERSION="7.3.1"
DOWNLOAD_URL="https://sdk.visionsmarts.com/downloads/${SDK_NAME}-v${VERSION}.tar.gz"
EXPECTED_SHA256="b4b4f75a5a80c418830b78f7a20466de2f21ed95473f5d4ac21d4e2a26d33cf9"
# Colors
BOLD_GREEN="\033[1;32m"
BOLD_RED="\033[1;31m"
RESET="\033[0m"
echo "--------------------------------------------------------"
echo "Installing $SDK_NAME (Evaluation Version)"
echo "--------------------------------------------------------"
echo "By proceeding, you agree to the Evaluation License terms:"
echo "https://github.com/VisionSmarts/VSBarcodeReader-iOS/blob/main/LICENSE"
echo ""
echo "NOTE: This SDK transmits anonymous telemetry to our servers."
echo "--------------------------------------------------------"
# 1. License Check
read -p "Do you accept these terms? (y/n): " confirm
if [[ $confirm != [yY] ]]; then
echo "Installation cancelled."
exit 1
fi
# 2. Check for required tools
if ! command -v tar &> /dev/null; then
echo "Error: 'tar' is not installed. Please install it to continue."
exit 1
fi
if command -v sha256sum &> /dev/null; then
SHA_CMD="sha256sum"
elif command -v shasum &> /dev/null; then
SHA_CMD="shasum -a 256"
else
echo "Error: No SHA-256 tool found (sha256sum or shasum). Please install one."
exit 1
fi
# 3. Download
TMP_FILE="$(mktemp /tmp/${SDK_NAME}-XXXXXX.tar.gz)"
cleanup() {
rm -f "$TMP_FILE"
}
trap cleanup EXIT
echo "Downloading $SDK_NAME..."
if ! curl -fL --progress-bar "$DOWNLOAD_URL" -o "$TMP_FILE"; then
echo "Error: Download failed. Check your connection or rate limits."
exit 1
fi
# 4. Verify SHA-256
echo "Verifying SHA-256 checksum..."
ACTUAL_HASH="$($SHA_CMD "$TMP_FILE" | awk '{print $1}')"
if [[ "$ACTUAL_HASH" != "$EXPECTED_SHA256" ]]; then
echo -e "${BOLD_RED}--------------------------------------------------------${RESET}"
echo -e "${BOLD_RED}ALERT: Checksum mismatch! The downloaded file may be corrupt or tampered with.${RESET}"
echo -e "${BOLD_RED} Expected: $EXPECTED_SHA256${RESET}"
echo -e "${BOLD_RED} Got: $ACTUAL_HASH${RESET}"
echo -e "${BOLD_RED}Installation aborted. Please contact support@visionsmarts.com${RESET}"
echo -e "${BOLD_RED}--------------------------------------------------------${RESET}"
exit 1
fi
echo "SHA-256 verified: $ACTUAL_HASH"
# 5. Extract
echo "Extracting $SDK_NAME..."
if tar -xzf "$TMP_FILE" -C .; then
echo -e "${BOLD_GREEN}--------------------------------------------------------${RESET}"
echo -e "${BOLD_GREEN}SUCCESS: $SDK_NAME has been installed.${RESET}"
echo -e "${BOLD_GREEN}Reminder: This is for EVALUATION ONLY. No production/pilot use.${RESET}"
echo -e "${BOLD_GREEN}--------------------------------------------------------${RESET}"
else
echo "Error: Extraction failed."
exit 1
fi