Skip to content

Instantly share code, notes, and snippets.

@mwgamera
Created October 1, 2013 06:23
Show Gist options
  • Save mwgamera/6774540 to your computer and use it in GitHub Desktop.
Save mwgamera/6774540 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Run mcabber with dedicated gpg-agent with preset passphrase
# klg, Sep 2013
KEYGRP=AB91925C3C10DB24EDCDB821A294A4F0248DE9A1
gpg_agent=gpg-agent
gpg_connect_agent=gpg-connect-agent
gpg_preset_passphrase=/usr/lib/x86_64-linux-gnu/gnupg2/gpg-preset-passphrase
pinentry=pinentry
mcabber=mcabber
# Start agent
eval $($gpg_agent --allow-preset-passphrase --daemon)
# Get passphrase
{
eval $(locale)
echo OPTION ttyname=`tty`
echo OPTION lc-ctype=$LC_CTYPE
echo OPTION lc-messages=$LC_MESSAGES
echo SETDESC `gpg --with-colons --list-secret-keys $KEYGRP \
| awk -F: '{printf"Unlock secret key %s%%0A%s",$5,$10;exit}'`
echo SETPROMPT Password:
echo GETPIN
echo BYE
} | $pinentry | {
{ line; line; line; line; line; line; } >/dev/null
line | sed -n 's:^D ::p'
} | $gpg_preset_passphrase --preset $KEYGRP \
&& {
# Launch mcabber
$mcabber
}
# Clean up later
kill "$($gpg_connect_agent /serverpid /subst '/echo ${get serverpid}' /bye)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment