blob: ff7e4bb419232faf0d38cdf8145031f8b59a76fa (
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" "1.10"
- 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
- case $(xmllint --xpath '/RESPONSEINFO/FIRMUPDATEINFO/VERSIONCHECK/text()' response.xml) in
- 0)
- echo "--- request (name=$name, spec=$spec, firm=$firmid, version=$version) ---"
- cat request.xml | xmllint --format -
- echo "--- response ---"
- cat response.xml | xmllint --format -
- ;;
- 1)
- echo "-- no firmware update available (name=$name, spec=$spec, firm=$firmid, version=$version) --"
- ;;
- 2)
- echo "-- the request is partially incomplete (name=$name, spec=$spec, firm=$firmid, version=$version) --"
- ;;
- *)
- echo "-- the request is invalid (name=$name, spec=$spec, firm=$firmid, version=$version) --"
- ;;
- esac
- rm request.xml response.xml
- done
- done
|