Theo Chatzimichos c336cc
#!/bin/bash
Theo Chatzimichos c336cc
Theo Chatzimichos c336cc
help() {
Theo Chatzimichos c336cc
    echo "Encrypt a given string and print out the output. This output can be"
Theo Chatzimichos c336cc
    echo "then used as encrypted pillar"
Theo Chatzimichos c336cc
    echo
Theo Chatzimichos c336cc
}
Theo Chatzimichos c336cc
Theo Chatzimichos c336cc
[[ $1 == '--help' ]] && help && exit
Theo Chatzimichos c336cc
Theo Chatzimichos b65362
while getopts h arg; do
Theo Chatzimichos c336cc
    case ${arg} in
Theo Chatzimichos c336cc
        h) help && exit ;;
Theo Chatzimichos c336cc
        *) help && exit 1 ;;
Theo Chatzimichos c336cc
    esac
Theo Chatzimichos c336cc
done
Theo Chatzimichos c336cc
Theo Chatzimichos 9a0754
echo "Please type the string that you want to encrypt"
Theo Chatzimichos 9a0754
read STRING
Theo Chatzimichos 9a0754
Theo Chatzimichos c336cc
[[ -z $STRING ]] && help && exit 1
Theo Chatzimichos c336cc
Theo Chatzimichos d2d4c6
RECIPIENTS=$(egrep '^\s*0x' encrypted_pillar_recipients | while read i; do echo "-r $i"; done | xargs)
Theo Chatzimichos c336cc
echo -n "${STRING}" | gpg --armor --batch --trust-model always --encrypt ${RECIPIENTS}