#!/bin/sh# directory where search for imagesTOP_DIR="${TOP_DIR:-./bin/targets}"# key to sign imagesBUILD_KEY="${BUILD_KEY:-key-build}"# TODO unify naming?# remove other signatures (added e.g. by buildbot)REMOVE_OTER_SIGNATURES="${REMOVE_OTER_SIGNATURES:-1}"# find all sysupgrade images in TOP_DIR# factory images don't need signatures as non OpenWrt system doesn't check them anywayforimagein$(find$TOP_DIR-typef-name"*-sysupgrade.bin");do# check if image actually support metadataiffwtool-i/dev/null"$image";then# remove all previous signaturesif[-n"$REMOVE_OTER_SIGNATURES"];thenwhile["$?"=0];dofwtool-t-s/dev/null"$image"donefi# run same operation as build root does for signingcp"$BUILD_KEY.ucert""$image.ucert"usign-S-m"$image"-s"$BUILD_KEY"-x"$image.sig"ucert-A-c"$image.ucert"-x"$image.sig"fwtool-S"$image.ucert""$image"fidone