diff options
| author | Karel Kočí <cynerd@email.cz> | 2016-10-15 19:22:44 +0200 | 
|---|---|---|
| committer | Karel Kočí <cynerd@email.cz> | 2016-10-15 19:22:44 +0200 | 
| commit | 02a2196150b16ee1c343a5587cadb177016fe222 (patch) | |
| tree | 8ef95619620a4689a12d26eff0a0287954a2cd3c /local/sbin/syncemail | |
| parent | b17cad80bfaf348ce805868dc4b35211a4c32906 (diff) | |
| download | myconfigs-02a2196150b16ee1c343a5587cadb177016fe222.tar.gz myconfigs-02a2196150b16ee1c343a5587cadb177016fe222.tar.bz2 myconfigs-02a2196150b16ee1c343a5587cadb177016fe222.zip  | |
Update files to changes done while abandoning systemd
Now I use openrc.
Diffstat (limited to 'local/sbin/syncemail')
| -rwxr-xr-x | local/sbin/syncemail | 48 | 
1 files changed, 22 insertions, 26 deletions
diff --git a/local/sbin/syncemail b/local/sbin/syncemail index 95deb7e..d0ea682 100755 --- a/local/sbin/syncemail +++ b/local/sbin/syncemail @@ -1,36 +1,32 @@  #!/usr/bin/python2 -# This starts offlineimap, but first it requests passwords from pass by user -# notification launching script at front. +# This starts offlineimap, but first it requests passwords from pass  import os  import sys  import subprocess +import daemon +import lockfile  from offlineimap import OfflineImap -frontscript = """ -echo "Asking for gpg password to access pass" 1>&2 -pass mail/cynerd@email.cz -echo "All done" 1>&2 -""" -annoyme = [ -		  os.path.expanduser("~/.local/sbin/annoyme-request"), -		  "syncemail", -		  "Imap email synchronization service password request." -		  ] +if os.path.isfile('/home/cynerd/.run/syncemail.pid.lock'): +    sys.exit(0) -anproc = subprocess.Popen(annoyme, stdin=subprocess.PIPE, -                          stdout=subprocess.PIPE) -anproc.stdin.write(frontscript) -anproc.stdin.close() -output = anproc.stdout.read().splitlines() -excode = anproc.wait() +accounts = [ +        ["email", "mail/cynerd@email.cz"], +        ] -if excode != 0: -    print("Authentication failed. Please start emailsync again") -    sys.exit(1) -print(output) +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) -sys.argv.append('-k') -sys.argv.append('Repository_email-remote:remotepass=' + output[0]) +sys.argv.append('-s') # output to syslog - -OfflineImap().run() +with daemon.DaemonContext( +        pidfile=lockfile.FileLock('/home/cynerd/.run/syncemail.pid') +        ): +    OfflineImap().run()  | 
