equal support for isync/offlineimap, and more mail docs

This commit is contained in:
Pig Monkey 2015-12-28 13:22:44 -08:00
parent 90fb907e0e
commit 55664614d5
8 changed files with 83 additions and 32 deletions

View file

@ -61,16 +61,53 @@ AUR packages are installed via the [ansible-aur][7] module. Note that while
[aura][8], an [AUR helper][9], is installed by default, it will *not* be used
during any of the provisioning.
## System Mail
## Mail
### Receiving Mail
Receiving mail is supported by syncing from IMAP servers via both [isync][10]
and [OfflineIMAP][11]. By default isync is enabled, but this can be changed to
OfflineIMAP by setting the value of the `mail.sync_tool` variable to
`offlineimap`.
### Sending Mail
[msmtp][12] is used to send mail. Included as part of msmtp's documentation are
a set of [msmtpq scripts][13] for queuing mail. These scripts are copied to the
user's path for use. When calling `msmtpq` instead of `msmtp`, mail is sent
normally if internet connectivity is available. If the user is offline, the
mail is saved in a queue, to be sent out when internet connectivity is again
available. This helps support a seamless workflow, both offline and online.
### System Mail
If the `email.user` variable is defined, the system will be configured to
forward mail for the user and root to this address. Removing this variable will
cause no mail aliases to be put in place.
The cron implementation is configured to send mail using `msmtpq`.
### Syncing and Scheduling Mail
A shell script called `mailsync` is included to sync mail, by first sending any
mail in the msmtp queue and then syncing with the chosen IMAP servers via
either isync or OfflineIMAP. Before syncing, the script checks for internet
connectivity using NetworkMananger. `mailsync` may be called directly by the
user, ie by configuring a hotkey in Mutt.
A [systemd timer][14] is also included to periodically call `mailsync`. By
default, the timer starts 5 minutes after boot (to allow time for network
connectivity to be established, configurable through the `mail.sync_boot_delay`
variable) and syncs every 15 minutes (configurable through the `mail.sync_time`
variable).
If the `mail.sync_time` variable is not defined, neither the synchronization
service nor timer will be installed.
## Known Issues
* [tpfanco][10], normally installed as part of the `thinkpad` role is currently
[unavailable in the AUR][11]. No ThinkPad fan control software is currently
* [tpfanco][15], normally installed as part of the `thinkpad` role is currently
[unavailable in the AUR][16]. No ThinkPad fan control software is currently
installed.
@ -83,5 +120,10 @@ cause no mail aliases to be put in place.
[7]: https://github.com/pigmonkey/ansible-aur
[8]: https://github.com/aurapm/aura
[9]: https://wiki.archlinux.org/index.php/AUR_helpers
[10]: https://code.google.com/p/tpfanco/
[11]: https://aur.archlinux.org/packages/?O=0&K=tpfanco
[10]: http://isync.sourceforge.net/
[11]: http://offlineimap.org/
[12]: http://msmtp.sourceforge.net/
[13]: http://sourceforge.net/p/msmtp/code/ci/master/tree/scripts/msmtpq/README.msmtpq
[14]: https://wiki.archlinux.org/index.php/Systemd/Timers
[15]: https://code.google.com/p/tpfanco/
[16]: https://aur.archlinux.org/packages/?O=0&K=tpfanco

View file

@ -24,9 +24,10 @@ ssh:
user_key: /root/id_rsa
enable_sshd: False
isync:
boot_delay: 5min
sync: 15min
mail:
sync_tool: isync
sync_time: 15min
sync_boot_delay: 5min
editors:
- gvim

View file

@ -3,21 +3,3 @@
pacman: name=isync state=present
tags:
- isync
- name: Push mbsync service file
copy: src=mbsync.service dest=/etc/systemd/system/mbsync@.service
when: isync is defined
tags:
- isync
- name: Push mbsync timer file
template: src=mbsync.timer.j2 dest=/etc/systemd/system/mbsync@.timer
when: isync is defined
tags:
- isync
- name: Enable and start mbsync timer
service: name="mbsync@{{ user.name }}.timer" enabled=yes state=started
when: isync is defined
tags:
- isync

View file

@ -0,0 +1,23 @@
---
- name: Push mail sync script
template: src=mailsync.sh.j2 dest=/usr/local/bin/mailsync mode=755
tags:
- mailsync
- name: Push mailsync service file
copy: src=mailsync.service dest=/etc/systemd/system/mailsync@.service
when: mail.sync_time is defined
tags:
- mailsync
- name: Push mailsync timer file
template: src=mailsync.timer.j2 dest=/etc/systemd/system/mailsync@.timer
when: mail.sync_time is defined
tags:
- mailsync
- name: Enable and start mailsync timer
service: name="mailsync@{{ user.name }}.timer" enabled=yes state=started
when: mail.sync_time is defined
tags:
- mailsync

View file

@ -12,10 +12,8 @@
- name: Install notmuch
pacman: name=notmuch state=present
- name: Push mail sync script
copy: src=mailsync.sh dest=/usr/local/bin/mailsync mode=755
- include: msmtp.yml
- include: isync.yml
- include: offlineimap.yml
- include: mailsync.yml
- include: contacts.yml

View file

@ -1,4 +1,5 @@
#!/bin/sh
# {{ ansible_managed }}
# Original source: http://bit.ly/1Ztk5wg
# Send and receive mail when full internet connectivity is available.
@ -7,7 +8,11 @@ STATE=`nmcli networking connectivity`
if [ $STATE = 'full' ]
then
/usr/local/bin/msmtp-queue -r
{% if mail.sync_tool == "isync" %}
/usr/bin/mbsync -a
{% elif mail.sync_tool == "offlineimap" %}
/usr/bin/offlineimap -o
{% endif %}
exit $?
fi
echo "No internet connection."

View file

@ -3,9 +3,9 @@
Description=Mailbox synchronization timer
[Timer]
OnBootSec={{ isync.boot_delay }}
OnUnitActiveSec= {{ isync.sync }}
Unit=mbsync@%i.service
OnBootSec={{ mail.sync_boot_delay }}
OnUnitActiveSec= {{ mail.sync_time }}
Unit=mailsync@%i.service
[Install]
WantedBy=timers.target