chip-update-firmware.sh: added option -u to delete cache

This commit is contained in:
Alex Kaplan 2015-09-12 13:53:04 -07:00
parent 9f7457d2b8
commit bc9ec9a87e
1 changed files with 20 additions and 2 deletions

View File

@ -1,7 +1,7 @@
#!/bin/bash
FW_DIR="$(pwd)/.firmware"
FW_IMAGE_DIR="${FW_DIR}/images"
S3_URL="https://s3-ap-northeast-1.amazonaws.com/stak-images/firmware/chip/stable/5/images"
S3_URL="https://s3-ap-northeast-1.amazonaws.com/stak-images/firmware/chip/stable/latest"
function require_directory {
if [[ ! -d "${1}" ]]; then
@ -11,11 +11,29 @@ function require_directory {
function cache_download {
if [[ ! -f "${1}/${2}" ]]; then
wget -P "${FW_IMAGE_DIR}" "${S3_URL}/${2}" ||
LATEST_URL="$(wget -q -O- ${S3_URL})"
wget -P "${FW_IMAGE_DIR}" "${LATEST_URL}images/${2}" ||
exit 1
fi
}
while getopts ":u" opt; do
case $opt in
u)
echo "updating cache"
if [[ -d "$FW_IMAGE_DIR" ]]; then
rm -rf $FW_IMAGE_DIR
fi
;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
esac
done
require_directory "${FW_IMAGE_DIR}"
cache_download "${FW_IMAGE_DIR}" rootfs.ubi
cache_download "${FW_IMAGE_DIR}" sun5i-r8-chip.dtb