#!/bin/bash # Origin: https://cbompart.wordpress.com/2014/05/26/brother-printer-firmware-part-2/ # Depends: libxml2-utils 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 '' >> request.xml echo -n $firmid >> request.xml echo -n 'LINUX1' >> request.xml echo -n $name >> request.xml echo -n '' >> request.xml echo -n $spec >> request.xml echo -n '' >> request.xml echo -n $firmid >> request.xml echo -n '' >> request.xml echo -n $version >> request.xml echo -n '121' >> 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