summaryrefslogtreecommitdiff
path: root/localbrotherfwfetch
blob: 808304c4c81618b19211efccf7fbe85d308150c1 (plain)
  1. #!/bin/bash
  2. name=
  3. spec=
  4. firms=
  5. while getopts ":n:s:f:" opt; do
  6. case $opt in
  7. n)
  8. name=$OPTARG
  9. ;;
  10. s)
  11. spec=$OPTARG
  12. ;;
  13. f)
  14. firms=$OPTARG
  15. ;;
  16. esac
  17. done
  18. IFS=',' read -a firmids <<< "$firms"
  19. for firmid in "${firmids[@]}"
  20. do
  21. for version in "0" "B0000000000"
  22. do
  23. echo -n '<REQUESTINFO><FIRMUPDATETOOLINFO><FIRMCATEGORY>' >> request.xml
  24. echo -n $firmid >> request.xml
  25. echo -n '</FIRMCATEGORY><OS>LINUX</OS><INSPECTMODE>1</INSPECTMODE></FIRMUPDATETOOLINFO><FIRMUPDATEINFO><MODELINFO><NAME>' >> request.xml
  26. echo -n $name >> request.xml
  27. echo -n '</NAME><SPEC>' >> request.xml
  28. echo -n $spec >> request.xml
  29. echo -n '</SPEC><DRIVER></DRIVER><FIRMINFO><FIRM><ID>' >> request.xml
  30. echo -n $firmid >> request.xml
  31. echo -n '</ID><VERSION>' >> request.xml
  32. echo -n $version >> request.xml
  33. echo -n '</VERSION></FIRM></FIRMINFO></MODELINFO><DRIVERCNT>1</DRIVERCNT><LOGNO>2</LOGNO><ERRBIT></ERRBIT><NEEDRESPONSE>1</NEEDRESPONSE></FIRMUPDATEINFO></REQUESTINFO>' >> request.xml
  34. 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
  35. valid=`grep "<RESPONSEINFO><FIRMUPDATEINFO><VERSIONCHECK>0</VERSIONCHECK>" response.xml`
  36. if [ -n "$valid" ]
  37. then
  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. else
  43. partial=`grep "<RESPONSEINFO><FIRMUPDATEINFO><VERSIONCHECK>2</VERSIONCHECK><FIRMID>" response.xml`
  44. if [ -n "$partial" ]
  45. then
  46. echo "-- the request is partially incomplete (name=$name, spec=$spec, firm=$firmid, version=$version) --"
  47. else
  48. echo "-- the request is invalid (name=$name, spec=$spec, firm=$firmid, version=$version) --"
  49. fi
  50. fi
  51. rm request.xml response.xml
  52. done
  53. done