This is a copy from tor-browser-bundle/gitian/signmars.sh that we currently use for mar signing.
mentioned in issue #40414 (closed)