aboutsummaryrefslogtreecommitdiff
path: root/local/sbin
diff options
context:
space:
mode:
Diffstat (limited to 'local/sbin')
-rwxr-xr-xlocal/sbin/newmail-notify23
-rwxr-xr-xlocal/sbin/syncemail48
-rwxr-xr-xlocal/sbin/user-service.sh90
3 files changed, 0 insertions, 161 deletions
diff --git a/local/sbin/newmail-notify b/local/sbin/newmail-notify
deleted file mode 100755
index 7c6b803..0000000
--- a/local/sbin/newmail-notify
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-
-cd ~/.mail
-
-if [ -f notify-notified ]; then
- NOTIFIED=`cat notify-notified`
- rm notify-notified
-fi
-
-for account in `ls`; do
- if cd "$account"/INBOX/new; then
- for m in `ls`; do
- echo $m
- echo $m >> ~/.mail/notify-notified
- if echo "$NOTIFIED" | grep "$m" >/dev/null; then continue; fi
- FROM=`grep -E "^From: " "$m" | sed 's/^From: //' | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)'`
- TO=`grep -E "^To: " "$m" | sed 's/^To: //' | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)'`
- SUBJECT=`grep -E "^Subject: " "$m" | sed 's/^Subject: //' | perl -CS -MEncode -ne 'print decode("MIME-Header", $_)'`
- notify-send "$TO: $FROM" "$SUBJECT"
- done
- fi
- cd ~/.mail
-done
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/local/sbin/user-service.sh b/local/sbin/user-service.sh
deleted file mode 100755
index e48bb9d..0000000
--- a/local/sbin/user-service.sh
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/bin/sh
-set -e
-
-[ -z "$1" ] && {echo "Run this script only from user-service file!" && exit 1}
-
-# Name of service
-NAME="$(basename "$1")"
-SERVICE="$1"
-
-# Source input file
-. "$1"
-shift
-
-OP="status"
-Q=true
-# Parse arguments
-while [ -n "$1" ]; do
- case "$1" in
- -h|--help)
- echo "User service: $NAME"
- echo " $description"
- echo "$SERVICE [OPTION]... OPERATION"
- echo " Options:"
- echo " -q - be quiet"
- echo " Operations:"
- echo " status - show status of service"
- echo " start - start service"
- echo " stop - stop service"
- echo " restart - restart service"
- ;;
- -q)
- Q=false
- ;;
- status|start|stop|restart)
- OP="$1"
- ;;
- *)
- echo "Unknown argument: $1"
- exit 1
- ;;
- esac
- shift
-done
-
-case "$OP" in
- status)
- if status; then
- $Q && echo "Service $NAME is running"
- exit 0
- else
- $Q && echo "Service $NAME is not running"
- exit 1
- fi
- ;;
- start)
- $Q && echo -n "Starting service $NAME..."
- if start; then
- $Q && echo " ok"
- else
- $Q && echo " fail"
- exit 1
- fi
- ;;
- stop)
- $Q && echo -n "Stopping service $NAME..."
- if stop; then
- $Q && echo " ok"
- else
- $Q && echo " fail"
- exit 1
- fi
- ;;
- restart)
- $Q && echo "Restarting service $NAME..."
- if ! stop; then
- $Q && echo " stop failed"
- exit 1
- fi
- if start; then
- $Q && echo " ok"
- else
- $Q && echo " start failed"
- exit 1
- fi
- ;;
- *)
- echo "Invalid operation!"
- exit 3
- ;;
-esac