blob: 4f085a7d3634ef25f6a73a6232a22a9ee5f94bc7 (
plain)
- #!/bin/bash
- # Origin: https://cbompart.wordpress.com/2014/05/26/brother-printer-firmware-part-2/
- name=
- spec=
- firms=
- while getopts ":n:s:f:" opt; do
- case $opt in
- n)
- name=$OPTARG
- ;;
- s)
- spec=$OPTARG
- ;;
- f)
- firms=$OPTARG
- ;;
- esac
- done
- IFS=',' read -a firmids <<< "$firms"
- for firmid in "${firmids[@]}"
- do
- for version in "0" "B0000000000"
- do
- echo -n '<REQUESTINFO><FIRMUPDATETOOLINFO><FIRMCATEGORY>' >> request.xml
- echo -n $firmid >> request.xml
- echo -n '</FIRMCATEGORY><OS>LINUX</OS><INSPECTMODE>1</INSPECTMODE></FIRMUPDATETOOLINFO><FIRMUPDATEINFO><MODELINFO><NAME>' >> request.xml
- echo -n $name >> request.xml
- echo -n '</NAME><SPEC>' >> request.xml
- echo -n $spec >> request.xml
- echo -n '</SPEC><DRIVER></DRIVER><FIRMINFO><FIRM><ID>' >> request.xml
- echo -n $firmid >> request.xml
- echo -n '</ID><VERSION>' >> request.xml
- echo -n $version >> request.xml
- echo -n '</VERSION></FIRM></FIRMINFO></MODELINFO><DRIVERCNT>1</DRIVERCNT><LOGNO>2</LOGNO><ERRBIT></ERRBIT><NEEDRESPONSE>1</NEEDRESPONSE></FIRMUPDATEINFO></REQUESTINFO>' >> request.xml
- 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
- valid=`grep "<RESPONSEINFO><FIRMUPDATEINFO><VERSIONCHECK>0</VERSIONCHECK>" response.xml`
- if [ -n "$valid" ]
- then
- echo "--- request (name=$name, spec=$spec, firm=$firmid, version=$version) ---"
- cat request.xml | xmllint --format -
- echo "--- response ---"
- cat response.xml | xmllint --format -
- else
- partial=`grep "<RESPONSEINFO><FIRMUPDATEINFO><VERSIONCHECK>2</VERSIONCHECK><FIRMID>" response.xml`
- if [ -n "$partial" ]
- then
- echo "-- the request is partially incomplete (name=$name, spec=$spec, firm=$firmid, version=$version) --"
- else
- echo "-- the request is invalid (name=$name, spec=$spec, firm=$firmid, version=$version) --"
- fi
- fi
- rm request.xml response.xml
- done
- done
|