-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore:creating curl and check-sums scripts
- Loading branch information
Showing
4 changed files
with
142 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
|
||
# Directory containing your CLI binaries | ||
BINARY_DIR="./bin" | ||
|
||
# Output file for checksums | ||
CHECKSUM_FILE="your-cli-checksums.txt" | ||
|
||
# Ensure the binary directory exists | ||
if [ ! -d "$BINARY_DIR" ]; then | ||
echo "Error: Binary directory not found: $BINARY_DIR" | ||
exit 1 | ||
fi | ||
|
||
# Change to the binary directory | ||
cd "$BINARY_DIR" || exit 1 | ||
|
||
# Remove any existing checksum file | ||
rm -f "$CHECKSUM_FILE" | ||
|
||
# Generate checksums for all binaries | ||
for file in your-cli-*; do | ||
if [ -f "$file" ]; then | ||
if command -v sha256sum > /dev/null 2>&1; then | ||
# Linux | ||
sha256sum "$file" >> "$CHECKSUM_FILE" | ||
elif command -v shasum > /dev/null 2>&1; then | ||
# macOS | ||
shasum -a 256 "$file" >> "$CHECKSUM_FILE" | ||
else | ||
echo "Error: No suitable checksum tool found (sha256sum or shasum)" | ||
exit 1 | ||
fi | ||
fi | ||
done | ||
|
||
echo "Checksums have been saved to $CHECKSUM_FILE" | ||
|
||
# Display the contents of the checksum file | ||
cat "$CHECKSUM_FILE" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
2e98285ca2857bae5e3ee42aec8237bde21470bd8a92295a73822903a2ff65d3 bin/linux | ||
20cf988344455b84159eca537f021873b4100f2df89f0951e736d3d82b1c22fb bin/windows.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
#!/bin/bash | ||
|
||
BASE_URL="https://github.com/urizennnn/express-cli/releases/download/v2.4.5" | ||
CHECKSUM_URL="https://example.com/express-cli/express-cli-check-sum.txt" | ||
|
||
|
||
OS="$(uname -s)" | ||
ARCH="$(uname -m)" | ||
|
||
|
||
case "$OS" in | ||
Linux*) | ||
OS_SUFFIX="linux" | ||
TARGET_DIR="/usr/local/bin" | ||
SHA256SUM="sha256sum" | ||
;; | ||
Darwin*) | ||
OS_SUFFIX="macos" | ||
TARGET_DIR="/usr/local/bin" | ||
SHA256SUM="shasum -a 256" | ||
;; | ||
CYGWIN*|MINGW*|MSYS_NT*) | ||
OS_SUFFIX="windows.exe" | ||
TARGET_DIR="/c/Windows/System32" | ||
SHA256SUM="sha256sum" | ||
;; | ||
*) | ||
echo "Unsupported OS: $OS" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
|
||
case "$ARCH" in | ||
x86_64|amd64) ARCH_SUFFIX="amd64" ;; | ||
arm64|aarch64) ARCH_SUFFIX="arm64" ;; | ||
*) | ||
echo "Unsupported architecture: $ARCH" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
|
||
FILENAME="express-cli-${OS_SUFFIX}-${ARCH_SUFFIX}" | ||
FULL_URL="${BASE_URL}/express-cli-${OS_SUFFIX}-${ARCH_SUFFIX}" | ||
if [ "$OS_SUFFIX" == "windows.exe" ]; then | ||
TARGET_FILE="express-cli.exe" | ||
else | ||
TARGET_FILE="express-cli" | ||
fi | ||
|
||
|
||
TEMP_DIR=$(mktemp -d) | ||
cd "$TEMP_DIR" || exit 1 | ||
|
||
|
||
echo "Downloading $TARGET_FILE from $FULL_URL..." | ||
if ! curl -fsSL "$FULL_URL" -o "$FILENAME"; then | ||
echo "Failed to download the binary. Please check your internet connection and try again." | ||
exit 1 | ||
fi | ||
|
||
|
||
echo "Downloading checksums..." | ||
if ! curl -fsSL "$CHECKSUM_URL" -o checksums.txt; then | ||
echo "Failed to download checksums. Please check your internet connection and try again." | ||
exit 1 | ||
fi | ||
|
||
|
||
echo "Verifying checksum..." | ||
EXPECTED_CHECKSUM=$(grep "$FILENAME" checksums.txt | awk '{print $1}') | ||
ACTUAL_CHECKSUM=$($SHA256SUM "$FILENAME" | awk '{print $1}') | ||
|
||
if [ "$EXPECTED_CHECKSUM" != "$ACTUAL_CHECKSUM" ]; then | ||
echo "Checksum verification failed. The downloaded file may be corrupted or tampered with." | ||
exit 1 | ||
fi | ||
|
||
echo "Checksum verified successfully." | ||
|
||
|
||
if [ "$OS_SUFFIX" != "windows.exe" ]; then | ||
chmod +x "$FILENAME" | ||
fi | ||
|
||
|
||
if [ "$OS_SUFFIX" == "windows.exe" ]; then | ||
mv "$FILENAME" "$TARGET_DIR/$TARGET_FILE" | ||
else | ||
sudo mv "$FILENAME" "$TARGET_DIR/$TARGET_FILE" | ||
fi | ||
|
||
|
||
cd - || exit 1 | ||
rm -rf "$TEMP_DIR" | ||
|
||
echo "express-cli has been installed successfully to $TARGET_DIR/$TARGET_FILE!" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters