summaryrefslogtreecommitdiff
path: root/localbrotherfwfetch
blob: 4f085a7d3634ef25f6a73a6232a22a9ee5f94bc7 (plain)
  1. #!/bin/bash
  2. # Origin: https://cbompart.wordpress.com/2014/05/26/brother-printer-firmware-part-2/
  3. name=
  4. spec=
  5. firms=
  6. while getopts ":n:s:f:" opt; do
  7. case $opt in
  8. n)
  9. name=$OPTARG
  10. ;;
  11. s)
  12. spec=$OPTARG
  13. ;;
  14. f)
  15. firms=$OPTARG
  16. ;;
  17. esac
  18. done
  19. IFS=',' read -a firmids <<< "$firms"
  20. for firmid in "${firmids[@]}"
  21. do
  22. for version in "0" "B0000000000"
  23. do
  24. echo -n '<REQUESTINFO><FIRMUPDATETOOLINFO><FIRMCATEGORY>' >> request.xml
  25. echo -n $firmid >> request.xml
  26. echo -n '</FIRMCATEGORY><OS>LINUX</OS><INSPECTMODE>1</INSPECTMODE></FIRMUPDATETOOLINFO><FIRMUPDATEINFO><MODELINFO><NAME>' >> request.xml
  27. echo -n $name >> request.xml
  28. echo -n '</NAME><SPEC>' >> request.xml
  29. echo -n $spec >> request.xml
  30. echo -n '</SPEC><DRIVER></DRIVER><FIRMINFO><FIRM><ID>' >> request.xml
  31. echo -n $firmid >> request.xml
  32. echo -n '</ID><VERSION>' >> request.xml
  33. echo -n $version >> request.xml
  34. echo -n '</VERSION></FIRM></FIRMINFO></MODELINFO><DRIVERCNT>1</DRIVERCNT><LOGNO>2</LOGNO><ERRBIT></ERRBIT><NEEDRESPONSE>1</NEEDRESPONSE></FIRMUPDATEINFO></REQUESTINFO>' >> request.xml
  35. curl -X POST -d @request.xml https://firmverup.brother.co.jp/kne_bh7_update_nt_ssl/ifax2.asmx/fileUpdate -H "Content-Type:text/xml" --sslv3 -o response.xml -s
  36. valid=`grep "<RESPONSEINFO><FIRMUPDATEINFO><VERSIONCHECK>0</VERSIONCHECK>" response.xml`
  37. if [ -n "$valid" ]
  38. then
  39. echo "--- request (name=$name, spec=$spec, firm=$firmid, version=$version) ---"
  40. cat request.xml | xmllint --format -
  41. echo "--- response ---"
  42. cat response.xml | xmllint --format -
  43. else
  44. partial=`grep "<RESPONSEINFO><FIRMUPDATEINFO><VERSIONCHECK>2</VERSIONCHECK><FIRMID>" response.xml`
  45. if [ -n "$partial" ]
  46. then
  47. echo "-- the request is partially incomplete (name=$name, spec=$spec, firm=$firmid, version=$version) --"
  48. else
  49. echo "-- the request is invalid (name=$name, spec=$spec, firm=$firmid, version=$version) --"
  50. fi
  51. fi
  52. rm request.xml response.xml
  53. done
  54. done