summaryrefslogtreecommitdiff
path: root/localbrotherfwfetch
blob: ff7e4bb419232faf0d38cdf8145031f8b59a76fa (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" "1.10"
  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. case $(xmllint --xpath '/RESPONSEINFO/FIRMUPDATEINFO/VERSIONCHECK/text()' response.xml) in
  37. 0)
  38. echo "--- request (name=$name, spec=$spec, firm=$firmid, version=$version) ---"
  39. cat request.xml | xmllint --format -
  40. echo "--- response ---"
  41. cat response.xml | xmllint --format -
  42. ;;
  43. 1)
  44. echo "-- no firmware update available (name=$name, spec=$spec, firm=$firmid, version=$version) --"
  45. ;;
  46. 2)
  47. echo "-- the request is partially incomplete (name=$name, spec=$spec, firm=$firmid, version=$version) --"
  48. ;;
  49. *)
  50. echo "-- the request is invalid (name=$name, spec=$spec, firm=$firmid, version=$version) --"
  51. ;;
  52. esac
  53. rm request.xml response.xml
  54. done
  55. done