summaryrefslogtreecommitdiff
path: root/localbrotherfwfetch
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2015-10-10 22:48:14 +0200
committerJonas Smedegaard <dr@jones.dk>2015-10-10 22:50:04 +0200
commit5dda6d810d128b56cd22328e16897cb40f3fbe15 (patch)
tree673609e9206d2be91d4295f7a2e83406fe5fd6a5 /localbrotherfwfetch
parent6f4c2f475f30dcf43a69cf1cabd17831c60cd04e (diff)
Parse response reliably, and handle no-op (response code 1) separate from failure.
Diffstat (limited to 'localbrotherfwfetch')
-rwxr-xr-xlocalbrotherfwfetch25
1 files changed, 13 insertions, 12 deletions
diff --git a/localbrotherfwfetch b/localbrotherfwfetch
index 3ef554c..ff7e4bb 100755
--- a/localbrotherfwfetch
+++ b/localbrotherfwfetch
@@ -38,22 +38,23 @@ do
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
+ 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 -
- 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
+ ;;
+ 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