Skip to content

Instantly share code, notes, and snippets.

@antonlacon
Last active May 28, 2020 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonlacon/53b058a84d7f8fafa685c584320a7d84 to your computer and use it in GitHub Desktop.
Save antonlacon/53b058a84d7f8fafa685c584320a7d84 to your computer and use it in GitHub Desktop.
#!/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