blob: 989a2d4bd5608fddf7a842ca59103b7cd80c612e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
#!/bin/sh
#
# my_mailsync
#
# Synchronize mail between here and lump. Clearly only effective if
# we're networked (i.e. we can see lump), so ping lump first. If we
# can't see it then simply return.
#
#exit 0
cd ~/.offlineimap/config
mkdir -p ~/.offlineimap/state
KNOWN_CONFIGS=$(ls -1t | grep -v '~')
for CONFIG in $KNOWN_CONFIGS; do
case $0 in
*${CONFIG}) CONF=${CONFIG};;
esac
done
SCHROOT="schroot -c buster-offlineimap --"
UI="Quiet"
VERBOSE=0
MAX_RUN=600 # Seconds
TTY=`tty`
if [ "$1"x = "-v"x ] ; then
VERBOSE=$(($VERBOSE + 1))
shift 1
fi
if [ "$1"x = "-v"x ] ; then
VERBOSE=$(($VERBOSE + 1))
shift 1
fi
if [ "$CONF"x = ""x ] ; then
CONF=$1
fi
if [ "$CONF"x = ""x ] ; then
CONF=DEFAULT
fi
if [ $VERBOSE -gt 0 ] ; then
UI="Basic"
fi
if [ $VERBOSE -gt 2 ] ; then
DEBUG="-d imap -l $LOG"
fi
LOG=~/.offlineimap/$CONF.log
cd /tmp
ulimit -c unlimited
if [ $VERBOSE -gt 1 ] ; then
echo "offlineimap -u $UI -o -c ~/.offlineimap/config/$CONF"
fi
if [ $VERBOSE -gt 1 ] ; then
echo "offlineimap -u $UI -o -c ~/.offlineimap/config/$CONF"
fi
if [ "$TTY"x = "not a tty"x ] ; then # No terminal, so running from cron or similar
$SCHROOT timeout -k $MAX_RUN $MAX_RUN offlineimap -u $UI -o -c ~/.offlineimap/config/$CONF 2>&1
else
$SCHROOT offlineimap -u $UI -o $DEBUG -c ~/.offlineimap/config/$CONF 2>&1
if [ $? -ne 0 ] ; then
echo
echo
echo "offlineimap -u $UI -o -c ~/.offlineimap/config/$CONF failed"
OTHER_PID=`ps wwwaux | grep "offlineimap.*$CONF" | grep -v grep | awk '{print $2}'`
if [ "$OTHER_PID"x != ""x ] ; then
echo "Another task still running: PID $OTHER_PID"
fi
fi
fi
|