firmware_update.sh 807 B

123456789101112131415161718192021222324252627282930313233
  1. #!/bin/sh
  2. # include the json sh library
  3. . /usr/share/libubox/jshn.sh
  4. json_init
  5. PACKAGE_NAME="oboo-clock-base"
  6. MAC=`cat /sys/class/net/ra0/address`
  7. PACKAGE_VER=`opkg info $PACKAGE_NAME | grep Version | sed -e 's/^Version:\s//g'`
  8. MODEL=`ubus call system board | grep model | sed -e 's/:"(.*?)"/\1/p'`
  9. DATA=`wget -qO- https://api.getoboo.com/v1/firmware/update?mac=$MAC`
  10. # Parse JSON content
  11. json_load "$DATA"
  12. json_get_var update_available update_available
  13. json_get_var mac mac
  14. json_get_var package_version package_version
  15. doUpdate () {
  16. opkg update
  17. opkg upgrade --force-overwrite $PACKAGE_NAME
  18. sh /usr/share/oboo/oboo-sw-upgrade.sh
  19. }
  20. if [ $update_available ] && [ "$PACKAGE_VER" != "$package_version" ]; then
  21. echo "update available"
  22. doUpdate
  23. else
  24. echo "no update available"
  25. fi;