upgrade-fw: use tar balls from github releases
This commit is contained in:
parent
61f769b0a5
commit
c57118c568
@ -1,11 +1,12 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
FILE="$1"
|
FILE="$1"
|
||||||
|
DOWNLOAD=""
|
||||||
MTDDEV="/dev/mtd3"
|
MTDDEV="/dev/mtd3"
|
||||||
SAFEFILE="/root/new.fw"
|
SAFEFILE="/root/new.fw"
|
||||||
CHECKSTR="Linux-2.6.32.42_stm24_0208-idl4k"
|
CHECKSTR="Linux-2.6.32.42_stm24_0208-idl4k"
|
||||||
GITHUB1="https://github.com/perexg/satip-axe/tree/master/dist"
|
|
||||||
GITHUB2="https://github.com/perexg/satip-axe/blob/master/dist/$FILE?raw=true"
|
GITHUB1="https://api.github.com/repos/perexg/satip-axe/releases"
|
||||||
|
|
||||||
if test "$PWD" != "/root" -a "$PWD" != "/"; then
|
if test "$PWD" != "/root" -a "$PWD" != "/"; then
|
||||||
echo "Run this utility from / or /root directory"
|
echo "Run this utility from / or /root directory"
|
||||||
@ -17,23 +18,65 @@ if test "$FILE" = "-h" -o "$FILE" = "--help"; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$FILE"; then
|
if ! test -r "$FILE"; then
|
||||||
echo "Trying to fetch the list of available firmware files:"
|
if test -z "$FILE"; then
|
||||||
if ! wget -q -O /root/list.txt "$GITHUB1"; then
|
echo "Trying to fetch the list of available firmware files:"
|
||||||
|
else
|
||||||
|
echo "Trying to fetch the URL for the firmware:"
|
||||||
|
fi
|
||||||
|
if ! wget -q -O /root/list.json "$GITHUB1"; then
|
||||||
echo "FAILED"
|
echo "FAILED"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
grep -o -E ">satip-axe-.*.fw<" /root/list.txt | grep -o -E "satip-axe.*.fw"
|
cat /root/list.json | grep -E '("name"|"browser_download_url")' | \
|
||||||
rm /root/list.txt
|
grep -v -E '"name":.*.tgz' | \
|
||||||
exit 0
|
while IFS="\n" read line
|
||||||
|
do
|
||||||
|
case "$line" in
|
||||||
|
\ *\"name\":*)
|
||||||
|
name=$(echo "$line" | cut -d '"' -f 4)
|
||||||
|
;;
|
||||||
|
\ *\"browser_download_url\":*)
|
||||||
|
fw=$(echo "$line" | cut -d '/' -f 9 | cut -d '"' -f 1 | cut -d '.' -f 1)
|
||||||
|
fw="$fw.fw"
|
||||||
|
if test -z "$FILE"; then
|
||||||
|
printf "%-40s : %s\n" "$name" "$fw"
|
||||||
|
else
|
||||||
|
if test "$FILE" = "$fw"; then
|
||||||
|
f=$(echo "$line" | cut -d '"' -f 4)
|
||||||
|
echo "$f" > /root/url.txt
|
||||||
|
printf " %s\n" "$f"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
name=''
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
rm /root/list.json
|
||||||
|
if test -z "$FILE"; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
if test -r /root/url.txt; then
|
||||||
|
DOWNLOAD=$(cat /root/url.txt)
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! test -r "$FILE"; then
|
if test -n "$DOWNLOAD"; then
|
||||||
echo "Downloading $FILE:"
|
echo "Downloading $FILE from $DOWNLOAD to $SAFEFILE:"
|
||||||
if ! wget -O "$SAFEFILE" "$GITHUB2/$FILE"; then
|
if ! wget -O - "$DOWNLOAD" | tar xOzf - "$FILE" > "$SAFEFILE"; then
|
||||||
echo "Unable to fetch firmware file $GITHUB2"
|
echo "Unable to fetch firmware file $DOWNLOAD / $FILE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
if ! test -r "$SAFEFILE"; then
|
||||||
|
echo "Unable to fetch firmware file $DOWNLOAD / $FILE"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
FILESIZE=$(stat -c "%s" "$SAFEFILE")
|
||||||
|
if test -z "$FILESIZE" -o $FILESIZE -le 0; then
|
||||||
|
echo "Download failed (wrong file size)!"
|
||||||
|
else
|
||||||
|
echo "Downloaded firmware $FILE (file $SAFEFILE size $FILESIZE bytes)..."
|
||||||
|
fi
|
||||||
FILE="$SAFEFILE"
|
FILE="$SAFEFILE"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -69,7 +112,7 @@ while test 1 -eq 1; do
|
|||||||
nanddump -f "$SAFEFILE.old" -l "$FILESIZE" "$MTDDEV"
|
nanddump -f "$SAFEFILE.old" -l "$FILESIZE" "$MTDDEV"
|
||||||
FILESIZE2=$(stat -c "%s" "$SAFEFILE.old")
|
FILESIZE2=$(stat -c "%s" "$SAFEFILE.old")
|
||||||
if test "$FILESIZE" -gt "$FILESIZE2"; then
|
if test "$FILESIZE" -gt "$FILESIZE2"; then
|
||||||
echo "Unable to verify (file sizes does not match - $FILESIZE > $FILESIZE2"
|
echo "Unable to verify (file sizes does not match - $FILESIZE > $FILESIZE2)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
if ! dd if=/dev/null seek="$FILESIZE" bs=1 of="$SAFEFILE.old" 2> /dev/null; then
|
if ! dd if=/dev/null seek="$FILESIZE" bs=1 of="$SAFEFILE.old" 2> /dev/null; then
|
||||||
@ -78,7 +121,7 @@ while test 1 -eq 1; do
|
|||||||
fi
|
fi
|
||||||
FILESIZE2=$(stat -c "%s" "$SAFEFILE.old")
|
FILESIZE2=$(stat -c "%s" "$SAFEFILE.old")
|
||||||
if test "$FILESIZE" != "$FILESIZE2"; then
|
if test "$FILESIZE" != "$FILESIZE2"; then
|
||||||
echo "Unable to verify (file sizes does not match - $FILESIZE != $FILESIZE2"
|
echo "Unable to verify (file sizes does not match - $FILESIZE != $FILESIZE2)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
result=$(diff "$SAFEFILE.old" "$SAFEFILE")
|
result=$(diff "$SAFEFILE.old" "$SAFEFILE")
|
||||||
|
Loading…
Reference in New Issue
Block a user