summaryrefslogtreecommitdiff
path: root/localbrotherfwfetch
blob: bf8ae59265609b39ab4af0d536662041e8071267 (plain)
  1. #!/bin/bash
  2. # Origin: https://cbompart.wordpress.com/2014/05/26/brother-printer-firmware-part-2/
  3. # Depends: libxml2-utils
  4. name=
  5. spec=
  6. firms=
  7. while getopts ":n:s:f:" opt; do
  8. case $opt in
  9. n)
  10. name=$OPTARG
  11. ;;
  12. s)
  13. spec=$OPTARG
  14. ;;
  15. f)
  16. firms=$OPTARG
  17. ;;
  18. esac
  19. done
  20. IFS=',' read -a firmids <<< "$firms"
  21. for firmid in "${firmids[@]}"
  22. do
  23. for version in "0" "B0000000000" "1.10"
  24. do
  25. echo -n '<REQUESTINFO><FIRMUPDATETOOLINFO><FIRMCATEGORY>' >> request.xml
  26. echo -n $firmid >> request.xml
  27. echo -n '</FIRMCATEGORY><OS>LINUX</OS><INSPECTMODE>1</INSPECTMODE></FIRMUPDATETOOLINFO><FIRMUPDATEINFO><MODELINFO><NAME>' >> request.xml
  28. echo -n $name >> request.xml
  29. echo -n '</NAME><SPEC>' >> request.xml
  30. echo -n $spec >> request.xml
  31. echo -n '</SPEC><DRIVER></DRIVER><FIRMINFO><FIRM><ID>' >> request.xml
  32. echo -n $firmid >> request.xml
  33. echo -n '</ID><VERSION>' >> request.xml
  34. echo -n $version >> request.xml
  35. echo -n '</VERSION></FIRM></FIRMINFO></MODELINFO><DRIVERCNT>1</DRIVERCNT><LOGNO>2</LOGNO><ERRBIT></ERRBIT><NEEDRESPONSE>1</NEEDRESPONSE></FIRMUPDATEINFO></REQUESTINFO>' >> request.xml
  36. 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
  37. case $(xmllint --xpath '/RESPONSEINFO/FIRMUPDATEINFO/VERSIONCHECK/text()' response.xml) in
  38. 0)
  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. ;;
  44. 1)
  45. echo "-- no firmware update available (name=$name, spec=$spec, firm=$firmid, version=$version) --"
  46. ;;
  47. 2)
  48. echo "-- the request is partially incomplete (name=$name, spec=$spec, firm=$firmid, version=$version) --"
  49. ;;
  50. *)
  51. echo "-- the request is invalid (name=$name, spec=$spec, firm=$firmid, version=$version) --"
  52. ;;
  53. esac
  54. rm request.xml response.xml
  55. done
  56. done