From 88c8b6493aea1549d71be0345295beb6c4e61c00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Sat, 15 Oct 2016 22:19:59 +0200 Subject: Some user services changes --- local/sbin/syncemail | 22 +++++++++++++++++----- private | 2 +- profile | 4 +++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/local/sbin/syncemail b/local/sbin/syncemail index d0ea682..dfd56a3 100755 --- a/local/sbin/syncemail +++ b/local/sbin/syncemail @@ -7,8 +7,17 @@ import daemon import lockfile from offlineimap import OfflineImap -if os.path.isfile('/home/cynerd/.run/syncemail.pid.lock'): - sys.exit(0) +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"], @@ -25,8 +34,11 @@ for acc in accounts: sys.argv.append('Repository_' + acc[0] + '-remote:remotepass=' + output) sys.argv.append('-s') # output to syslog +sys.argv.append('-u') +sys.argv.append('syslog') -with daemon.DaemonContext( - pidfile=lockfile.FileLock('/home/cynerd/.run/syncemail.pid') - ): +with daemon.DaemonContext(): + check_running() + with open(pidfile, "w") as f: + f.write("%s" % os.getpid()) OfflineImap().run() diff --git a/private b/private index 46aaf1f..404e1b3 160000 --- a/private +++ b/private @@ -1 +1 @@ -Subproject commit 46aaf1f524abcecf87471bc1a6aafdbfaa1ef024 +Subproject commit 404e1b3305786aab9dfc7ef180d4aa3b64130ed2 diff --git a/profile b/profile index 8a59d6e..5db59d9 100644 --- a/profile +++ b/profile @@ -1,6 +1,8 @@ # Start pulse audio -pulseaudio --start +pulseaudio --start 2>/dev/null # Start music player daemon mpd ~/.config/mpd/mpd.conf # Start email synchronization ~/.local/sbin/syncemail +# Start syncthing +start-stop-daemon -S -bm -p /tmp/syncthing-$UID.pid -- sh -c "syncthing -no-browser 2>&1 | logger -t syncthing" -- cgit v1.2.3