2016-04-05 19:12:37 +02:00
|
|
|
#!/bin/sh
|
2014-12-05 08:09:20 +01:00
|
|
|
set -e
|
|
|
|
|
2016-04-05 19:12:37 +02:00
|
|
|
if [ -z "$GMAIL" ]; then
|
2014-12-05 08:09:20 +01:00
|
|
|
echo >&2 'error: missing GMAIL environment variable'
|
|
|
|
echo >&2 ' try running again with -e GMAIL=your-email@gmail.com'
|
2015-01-08 07:10:55 +01:00
|
|
|
echo >&2 ' optionally, you can also specify -e GMAIL_PASS'
|
2015-01-13 17:52:55 +01:00
|
|
|
echo >&2 ' -e GMAIL_NAME="Your Name" and GMAIL_FROM=email@your-domain.com'
|
2014-12-05 08:09:20 +01:00
|
|
|
echo >&2 ' if not specified, both default to the value of GMAIL'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-04-05 19:12:37 +02:00
|
|
|
if [ -z "$GMAIL_NAME" ]; then
|
2015-01-08 07:10:55 +01:00
|
|
|
GMAIL_NAME="$GMAIL"
|
2014-12-05 08:09:20 +01:00
|
|
|
fi
|
|
|
|
|
2016-04-05 19:12:37 +02:00
|
|
|
if [ -z "$GMAIL_FROM" ]; then
|
2015-01-13 17:52:55 +01:00
|
|
|
GMAIL_FROM="$GMAIL"
|
|
|
|
fi
|
|
|
|
|
2016-04-05 19:12:37 +02:00
|
|
|
if [ -z "$IMAP_SERVER" ]; then
|
2015-10-06 22:23:39 +02:00
|
|
|
IMAP_SERVER="imap.gmail.com:993"
|
|
|
|
fi
|
|
|
|
|
2016-04-05 19:12:37 +02:00
|
|
|
if [ -z "$SMTP_SERVER" ]; then
|
2015-10-06 22:23:39 +02:00
|
|
|
SMTP_SERVER="smtp.gmail.com"
|
|
|
|
fi
|
|
|
|
|
|
|
|
sed -i "s/%GMAIL_LOGIN%/$GMAIL/g" "$HOME/.mutt/muttrc"
|
|
|
|
sed -i "s/%GMAIL_NAME%/$GMAIL_NAME/g" "$HOME/.mutt/muttrc"
|
|
|
|
sed -i "s/%GMAIL_PASS%/$GMAIL_PASS/g" "$HOME/.mutt/muttrc"
|
|
|
|
sed -i "s/%GMAIL_FROM%/$GMAIL_FROM/g" "$HOME/.mutt/muttrc"
|
|
|
|
sed -i "s/%IMAP_SERVER%/$IMAP_SERVER/g" "$HOME/.mutt/muttrc"
|
|
|
|
sed -i "s/%SMTP_SERVER%/$SMTP_SERVER/g" "$HOME/.mutt/muttrc"
|
2014-12-05 08:09:20 +01:00
|
|
|
|
2016-04-05 19:12:37 +02:00
|
|
|
if [ -d "$HOME/.gnupg" ]; then
|
2015-10-06 22:23:39 +02:00
|
|
|
# sane gpg settings to be a good encryption
|
|
|
|
# social citizen of the world
|
2014-12-05 08:09:20 +01:00
|
|
|
{
|
|
|
|
echo
|
2016-04-12 20:04:29 +02:00
|
|
|
if [ -f "/etc/Muttrc.gpg.dist" ]; then
|
|
|
|
echo 'source /etc/Muttrc.gpg.dist'
|
|
|
|
fi
|
2016-04-05 19:12:37 +02:00
|
|
|
if [ -f "/usr/share/doc/mutt/samples/gpg.rc" ]; then
|
|
|
|
echo 'source /usr/share/doc/mutt/samples/gpg.rc'
|
|
|
|
fi
|
|
|
|
if [ -f "/usr/share/doc/mutt/examples/gpg.rc" ]; then
|
|
|
|
echo 'source /usr/share/doc/mutt/examples/gpg.rc'
|
|
|
|
fi
|
2015-10-06 22:23:39 +02:00
|
|
|
if [[ ! -z "$GPG_ID" ]]; then
|
2014-12-05 08:09:20 +01:00
|
|
|
echo "set pgp_sign_as = $GPG_ID"
|
|
|
|
fi
|
2015-10-06 22:23:39 +02:00
|
|
|
echo 'set crypt_replysign=yes'
|
|
|
|
echo 'set crypt_replysignencrypted=yes'
|
|
|
|
echo 'set crypt_verify_sig=yes'
|
|
|
|
# auto encrypt replies to encrypted mail
|
|
|
|
echo 'set pgp_replyencrypt=yes'
|
|
|
|
# auto sign replies to signed mail
|
|
|
|
echo 'set pgp_replysign=yes'
|
|
|
|
# auto sign & encrypt to signed & encrypted mail
|
|
|
|
echo 'set pgp_replysignencrypted=yes'
|
|
|
|
# show which keys are no good anymore
|
|
|
|
echo 'set pgp_show_unusable=no'
|
|
|
|
# auto sign emails
|
|
|
|
echo 'set pgp_autosign=yes'
|
|
|
|
} >> "$HOME/.mutt/muttrc"
|
2014-12-05 08:09:20 +01:00
|
|
|
fi
|
|
|
|
|
2016-04-05 19:12:37 +02:00
|
|
|
if [ -e "$HOME/.muttrc.local" ]; then
|
2015-01-08 07:10:55 +01:00
|
|
|
echo "source $HOME/.muttrc.local" >> "$HOME/.mutt/muttrc"
|
2014-12-05 08:09:20 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
exec "$@"
|