From 5b32edcf88fe0b952100547b1b26f2eda15d47f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Thu, 25 Jun 2020 14:41:17 +0200 Subject: Replace offlineimap with isync --- config/offlineimap/config | 22 ---------------------- install | 31 ++++++++++++++---------------- local/bin/allsync | 20 ++++++++++++++++++++ local/sbin/syncemail | 48 ----------------------------------------------- private | 2 +- 5 files changed, 35 insertions(+), 88 deletions(-) delete mode 100755 config/offlineimap/config create mode 100755 local/bin/allsync delete mode 100755 local/sbin/syncemail diff --git a/config/offlineimap/config b/config/offlineimap/config deleted file mode 100755 index 6853963..0000000 --- a/config/offlineimap/config +++ /dev/null @@ -1,22 +0,0 @@ -# vim: set ft=config: -[general] -accounts = email -maxsyncaccounts = 4 - -[Repository email-remote] -type = IMAP -remotehost = imap.seznam.cz -remoteuser = cynerd@email.cz -ssl = yes -sslcacertfile = /etc/ssl/certs/ca-certificates.crt - -[Repository email-local] -type = Maildir -localfolders = ~/.mail/email - -[Account email] -localrepository = email-local -remoterepository = email-remote -autorefresh = 1 -postsynchook = ~/.local/sbin/newmail-notify - diff --git a/install b/install index d9a551c..230801a 100755 --- a/install +++ b/install @@ -60,13 +60,10 @@ if ask "dev" "Development tools configuration"; then inst pylintrc ~/.pylintrc fi -if ask "email-sync" "Install email synchronization"; then - inst local/bin/email-unread ~/.local/bin/email-unread - inst local/sbin/newmail-notify ~/.local/sbin/newmail-notify - inst_email_sync - # Contains: - # inst local/sbin/syncemail ~/.local/sbin/ - # inst config/offlineimap/ ~/.config/offlineimap +if ask "cal" "Install calendar and contacts"; then + inst config/khal/config ~/.config/khal/config + inst config/khard/khard.conf ~/.config/khard/khard.conf + inst private/vdirsyncer/ ~/.vdirsyncer fi if ask "mutt" "Install mutt configuration"; then @@ -74,13 +71,19 @@ if ask "mutt" "Install mutt configuration"; then inst lynxrc ~/.lynxrc inst mutt/mailcap ~/.mutt/ inst mutt/color ~/.mutt/ - inst_mutt_conf - # Contains: - # inst mutt/ ~/.mutt - # inst msmtprc ~/.msmtprc + inst private/mutt/ ~/.mutt + inst private/msmtprc ~/.msmtprc mkdir -p ~/.cache/mutt # directory for temporaly html files fi +if ask "sync" "Install synchronization"; then + inst local/bin/allsync ~/.local/bin/allsync + inst local/bin/email-unread ~/.local/bin/email-unread + inst local/sbin/newmail-notify ~/.local/sbin/newmail-notify + inst private/mbsyncrc ~/.mbsyncrc + inst_sync +fi + if ask "desktop" "Install desktop generic"; then # Theme inst gtk-2.0/gtkrc ~/.gtkrc-2.0 @@ -106,12 +109,6 @@ if ask "wayland" "Install Wayland (sway)"; then inst config/swaylock/ ~/.config/swaylock fi -if ask "cal" "Install calendar and contacts"; then - inst config/khal/config ~/.config/khal/config - inst config/khard/khard.conf ~/.config/khard/khard.conf - inst private/vdirsyncer/ ~/.vdirsyncer -fi - if ask "surf" "Install Surf configuration"; then inst surf/script.js ~/.surf/script.js inst surf/styles/default.css ~/.surf/styles/default.css diff --git a/local/bin/allsync b/local/bin/allsync new file mode 100755 index 0000000..b475460 --- /dev/null +++ b/local/bin/allsync @@ -0,0 +1,20 @@ +#!/bin/sh + +sec() { + echo -e '\e[1;34m==========' "$@" '==========\e[0m' +} + + +run() { + sec "Mail" + mbsync -a + ~/.local/sbin/newmail-notify + + sec "Calendar and contacts" + vdirsyncer sync +} + + + + +run diff --git a/local/sbin/syncemail b/local/sbin/syncemail deleted file mode 100755 index 3cb56a4..0000000 --- a/local/sbin/syncemail +++ /dev/null @@ -1,48 +0,0 @@ -#!/usr/bin/python2 -# This starts offlineimap, but first it requests passwords from pass -import os -import sys -import subprocess -import daemon -import lockfile -import syslog -from offlineimap import OfflineImap - -pidfile = '/tmp/syncemail-%d.pid' % os.getuid() - -# Check if not already running -def check_running(): - if os.access(pidfile, os.F_OK): - with open(pidfile, "r") as f: - pid = f.readline() - if os.path.exists('/proc/%s' % pid): - sys.exit(0) -check_running() - - -accounts = [ - ["email", "mail/cynerd@email.cz"], - ] - -for acc in accounts: - pproc = subprocess.Popen("pass " + acc[1], - stdout=subprocess.PIPE, shell=True) - output = pproc.stdout.read().rstrip() - if pproc.wait() != 0: - print("Password receive failed.") - sys.exit(1) - sys.argv.append('-k') - sys.argv.append('Repository_' + acc[0] + '-remote:remotepass=' + output) - -# Define out logger and redirect stdout and stderr to it -class logstd: - def write(self, data): - syslog.syslog(data) - -with daemon.DaemonContext(): - check_running() - with open(pidfile, "w") as f: - f.write("%s" % os.getpid()) - syslog.openlog('syncemail') - sys.stderr = sys.stdout = logstd() - OfflineImap().run() diff --git a/private b/private index c8c98ce..dfa038c 160000 --- a/private +++ b/private @@ -1 +1 @@ -Subproject commit c8c98ced6f1ddeab043d8017f4bd5c64184a68f3 +Subproject commit dfa038cf131612c96ffa859bd0b7added2bd2497 -- cgit v1.2.3