forked from T-REX-XP/RRManager
-
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.
- Loading branch information
1 parent
289cd4b
commit dc57114
Showing
4 changed files
with
220 additions
and
13 deletions.
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
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,46 @@ | ||
#!/usr/bin/env bash | ||
# Assuming jq is installed on your system for parsing and generating JSON | ||
# Content-Type header for JSON output | ||
echo "Content-type: application/json" | ||
echo "" | ||
|
||
USER=$(/usr/syno/synoman/webman/modules/authenticate.cgi) | ||
|
||
if [ "${USER}" = "" ]; then | ||
echo -e "Security : user not authenticated\n" | ||
else | ||
# Define the URL for GitHub API | ||
URL="https://api.github.com/repos/RROrg/rr/releases/latest" | ||
|
||
# Fetch the latest release info using the GitHub API | ||
response=$(curl -s "${URL}") | ||
|
||
# Extract the tag name from the response | ||
TAG=$(echo "${response}" | jq -r '.tag_name') | ||
|
||
# Read local version | ||
LOCALTAG=$(cat /usr/rr/VERSION 2>/dev/null | grep LOADERVERSION | cut -d'=' -f2) | ||
|
||
# Check if LOCALTAG is empty | ||
if [ -z "${LOCALTAG}" ]; then | ||
# Generate error message using jq | ||
echo "{}" | jq --arg message "Unknown bootloader version!" '.error = $message' | ||
exit 0 | ||
fi | ||
|
||
# Generate output JSON | ||
if [ "${TAG}" = "${LOCALTAG}" ]; then | ||
# Use jq to generate JSON for up-to-date status | ||
echo "{}" | jq --arg tag "$TAG" --arg message "Actual version is ${TAG}" \ | ||
'.status = "up-to-date" | .tag = $tag | .message = $message' | ||
else | ||
# Use jq to generate JSON for update available, including release notes | ||
# Fetch and escape release notes from GitHub API response | ||
releaseNotes=$(echo "${response}" | jq '.body') | ||
|
||
# Use jq to build the JSON response | ||
echo "{}" | jq --arg tag "$TAG" --argjson notes "$releaseNotes" \ | ||
'.status = "update available" | .tag = $tag | .notes = $notes' | ||
fi | ||
|
||
fi |
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
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