Skip to content

Commit 45b940a

Browse files
committed
fetch script
1 parent 5641fa7 commit 45b940a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

fetch_latest_iso.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# fetch_latest_iso.sh
2+
# Author: D.A.Pelasgus
3+
#!/bin/bash
4+
5+
# Variables for repository and output file with directory fallback
6+
REPO="${REPO:-chimeraos/install-media}"
7+
OUTPUT_FILE="${OUTPUT_FILE:-latest_iso_download_url.txt}"
8+
9+
# Fetch the latest release data from the GitHub API
10+
response=$(curl -s "https://api.github.com/repos/$REPO/releases/latest")
11+
12+
# Check if the response contains assets and find an ISO asset
13+
iso_url=$(echo "$response" | jq -r '.assets[] | select(.name | endswith(".iso")) | .browser_download_url')
14+
iso_name=$(echo "$response" | jq -r '.assets[] | select(.name | endswith(".iso")) | .name')
15+
16+
# Verify if an ISO file was found
17+
if [[ -n "$iso_url" ]]; then
18+
echo "ISO file found: $iso_name"
19+
echo "Download URL: $iso_url"
20+
21+
# Save the download link to the output file
22+
echo "$iso_url" > "$OUTPUT_FILE"
23+
else
24+
echo "Error: ISO file not found in the latest release."
25+
exit 1
26+
fi

0 commit comments

Comments
 (0)