Repository navigation
Expand file tree
/
Copy pathinstallMuttForGmailOrApps.sh
More file actions
executable file
·72 lines (66 loc) · 2 KB
/
Copy pathinstallMuttForGmailOrApps.sh
File metadata and controls
executable file
·72 lines (66 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#!/bin/bash
# Config
muttrcFile='~/.muttrc'
muttdirdefault='~/.mutt'
# /Config
echo "This script installs mutt and configures it to be used with Gmail or Google Apps"
echo
read -p '... Install mutt using Homebrew? [y/N]' muttInstall
if [ "$muttInstall" != "y" ]; then
echo 'Exiting'
exit
fi
echo
echo "... Please fill some details"
read -p "Full username (username@domain):" userdomain
echo "(Note: you might need an App Password, see this: https://support.google.com/accounts/answer/185833)"
read -s -p "Password (will be stored as text in file):" pass
echo
read -p "Full name:" fullname
read -p "mutt dir (empty for default ~/.mutt)" muttdir
if [ -z $muttdir ]; then
muttdir=$muttdirdefault
fi
muttrcFileExpanded=$(eval echo $muttrcFile)
muttdirExpanded=$(eval echo $muttdir)
if [ -s $muttrcFileExpanded ]; then
echo "$muttrcFile is not empty: aborting"
exit
fi
if [ -e $muttdirExpanded ]; then
echo "mutt dir exists ($muttdirExpanded): aborting"
exit
fi
echo
echo "... Setting $muttrcFile"
{ # See https://stackoverflow.com/a/51113160/1071459
echo "set imap_user = \"$userdomain\""
echo "set imap_pass = \"$pass\""
echo "set smtp_url = \"smtp://$userdomain@smtp.gmail.com:587/\""
echo "set smtp_pass = \"$pass\""
echo "set from = \"$userdomain\""
echo "set realname = \"$fullname\""
echo "set folder = \"imaps://imap.gmail.com:993\""
echo "set spoolfile = \"+INBOX\""
echo "set postponed = \"+[Gmail]/Drafts\""
echo "set header_cache = $muttdirExpanded/cache/headers"
echo "set message_cachedir = $muttdirExpanded/cache/bodies"
echo "set certificate_file = $muttdirExpanded/certificates"
echo "set move = no"
echo "set smtp_authenticators = 'gssapi:login'"
} > $muttrcFileExpanded
echo
echo "... Creating directories in $muttdir"
mkdir -p $muttdirExpanded/cache/headers
mkdir -p $muttdirExpanded/cache/bodies
mkdir -p $muttdirExpanded/certificates
echo
echo '... Attempting mutt install'
brew install mutt
if [ $? -ne 0 ]; then
echo -e 'brew mutt install: failed'
echo 'Exiting'
exit
else
echo 'mutt install: done'
fi