26 lines
780 B
Bash
26 lines
780 B
Bash
#!/bin/sh
|
|
|
|
set -eu
|
|
|
|
umask 022
|
|
|
|
cd /srv/web/iot.foo.sh/shelly
|
|
|
|
PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
|
|
|
|
URL="http://archive.shelly-tools.de/"
|
|
|
|
for _prod in $(curl -sSf "${URL}/archive.php" | jq -r '.[].type') ; do
|
|
_ver="$(curl -sSf "${URL}/archive.php?type=${_prod}" | jq -r \
|
|
'max_by(.version[1:] | split(".") | map(try tonumber catch 0)) .version')"
|
|
_name="$(curl -sSf "${URL}/archive.php?type=${_prod}" | jq -r \
|
|
'limit(1; .[].file)')"
|
|
if [ ! -f "${_prod}.${_ver}.zip" ]; then
|
|
echo "New firmware for ${_prod} (version ${_ver})"
|
|
curl -sSf -o "${_prod}.${_ver}.zip" "${URL}/version/${_ver}/${_name}"
|
|
if [ -h "$_name" ]; then
|
|
rm -f "$_name"
|
|
fi
|
|
ln -s "${_prod}.${_ver}.zip" "$_name"
|
|
fi
|
|
done
|