diff options
Diffstat (limited to 'localbrotherfwfetch')
-rwxr-xr-x | localbrotherfwfetch | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/localbrotherfwfetch b/localbrotherfwfetch new file mode 100755 index 0000000..808304c --- /dev/null +++ b/localbrotherfwfetch @@ -0,0 +1,57 @@ +#!/bin/bash + +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 |