diff options
| author | alex <alex@pdp7.net> | 2023-10-21 12:30:49 +0200 |
|---|---|---|
| committer | alex <alex@pdp7.net> | 2023-10-21 12:31:10 +0200 |
| commit | 65bd013d7700d0a903fc61a6fb57e946dd0786b7 (patch) | |
| tree | 6cb4c633d57a91a567786da12107534405c89b6a /scripts | |
| parent | bb853893d8bf032ad7d6460c2a449241762703d8 (diff) | |
Complete mbsync setup
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/p7s/mail/__init__.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/scripts/p7s/mail/__init__.py b/scripts/p7s/mail/__init__.py index f5db2d86..ab1c5fad 100644 --- a/scripts/p7s/mail/__init__.py +++ b/scripts/p7s/mail/__init__.py @@ -1,4 +1,6 @@ import pathlib +import subprocess +import textwrap from p7s import bitwarden from p7s.mail import mbsync @@ -12,3 +14,32 @@ def generate_config(): "\n" + mbsync.mbsync_yahoo(yahoo["username"], yahoo["password"], "~/Mail") ) + + for username in [gmail["username"], yahoo["username"]]: + (pathlib.Path.home() / "Mail" / username).mkdir(exist_ok=True, parents=True) + + user_units = pathlib.Path.home() / ".config" / "systemd" / "user" + user_units.mkdir(exist_ok=True, parents=True) + (user_units / "mbsync.service").write_text(textwrap.dedent(""" + [Unit] + Description=Mail synchronization + + [Service] + ExecStart=/usr/bin/mbsync -qa + """).lstrip()) + + (user_units / "mbsync.timer").write_text(textwrap.dedent(""" + [Unit] + Description=Mail synchronization + + [Install] + WantedBy=timers.target + + [Timer] + OnBootSec=1m + OnActiveSec=0s + OnUnitInactiveSec=30s + Unit=mbsync.service + """).lstrip()) + + subprocess.run(["systemctl", "--user", "enable", "--now", "mbsync.timer"], check=True) |
