Last active
May 28, 2020 19:33
-
-
Save antonlacon/53b058a84d7f8fafa685c584320a7d84 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
if [ -z ${1} ]; then | |
echo "Error: Must supply release version number" | |
exit 1 | |
else | |
LE_VERSION="${1}" | |
fi | |
LE_DESCRIPTION="A fast and user-friendly Kodi Entertainment Center distribution" | |
json_output="{\n" | |
json_output+="\t\"os_list\": [\n" | |
LIST_OF_IMAGES=($(find target/ -name "LibreELEC-RPi*$LE_VERSION.img.gz")) | |
image_count=${#LIST_OF_IMAGES[@]} | |
loop_count=0 | |
for img in "${LIST_OF_IMAGES[@]}"; do | |
IMAGE_NAME=$(basename $img) | |
IMAGE_EXTRACT_SIZE=$(zcat $img | wc -c) | |
IMAGE_SHA256=$(zcat $img | sha256sum | cut -d " " -f 1) | |
IMAGE_DL_SIZE=$(du $img | cut -f 1) | |
IMAGE_RELEASE_DATE=$(date -r $img "+%F") | |
DEVICES=$( echo $IMAGE_NAME | cut -d "-" -f 2 | cut -d "." -f 1) | |
if [ $DEVICES = "RPi4" ]; then | |
DEVICES="RPi4" | |
elif [ $DEVICES = "RPi2" ]; then | |
DEVICES="RPi2/RPi3" | |
else | |
DEVICES="RPi0/RPi1" | |
fi | |
loop_count=$((loop_count+1)) | |
json_output+="\t\t{\n" | |
json_output+="\t\t\"url\": \"http://releases.libreelec.tv/$IMAGE_NAME\",\n" | |
json_output+="\t\t\"extract_size\": $IMAGE_EXTRACT_SIZE,\n" | |
json_output+="\t\t\"extract_sha256\": \"$IMAGE_SHA256\",\n" | |
json_output+="\t\t\"image_download_size\": $IMAGE_DL_SIZE,\n" | |
json_output+="\t\t\"description\": \"${LE_DESCRIPTION}\",\n" | |
json_output+="\t\t\"icon\": \"http://releases.libreelec.tv/noobs/LibreELEC_RPi/LibreELEC_RPi.png\",\n" | |
json_output+="\t\t\"name\": \"LibreELEC (${DEVICES})\",\n" | |
json_output+="\t\t\"release_date\": \"${IMAGE_RELEASE_DATE}\"\n" | |
if [ $loop_count -ne $image_count ]; then | |
json_output+="\t\t},\n" | |
else | |
json_output+="\t\t}\n" | |
fi | |
done | |
json_output+="\t]\n" | |
json_output+="}\n" | |
echo -e "${json_output}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment