#!/bin/bash
set -e

if test "$#" -ne 1; then
  echo "Wrong number of arguments" >&2
  exit 2
fi

if test $(whoami) != 'signing-gpg'; then
  echo 'This script should be run as the signing-gpg user' >&2
  exit 1
fi

gpg_subkey='0x157432CF78A65729!'
exec gpg --homedir /home/signing-gpg/.gnupg -absu "$gpg_subkey" --batch --no-tty -o- --passphrase-fd 0 -- "$1"
