dotfiles/mbsync/mk_authinfo

36 lines
769 B
Bash
Executable File

#!/usr/bin/env zsh
function cleanup(){
if (( $+commands[shred] )) ; then
shred transient/authinfo*
elif (( $+commands[srm] )) ; then
srm transient/authinfo*
elif ; then
echo UNABLE TO FIND A WAY TO SECURELY DELETE THIS.
exit -1
fi
rm transient/authinfo*
}
trap cleanup EXIT
cd $(dirname $0)
if [[ ! -e ./transient ]] ; then
mkdir transient
fi
if [[ ! -e ~/transient/authinfo ]] ; then
echo "Hello. I need the bridge password for this to work."
read _password\?"password: " asdaD
sed "s/PASSWORD_PROVIDED_BY_BRIDGE/${_password}/g" authinfo.template \
> transient/authinfo
unset _password
fi
gpg -e -r james@jpatrick.io transient/authinfo
mv transient/authinfo.gpg ~/.authinfo.gpg