You are not logged in.
Pages: 1
I just installed offlineimap so I can use mutt to view IMAP email. How can I start it as a daemon so it automatically syncs email upon login? I found an rtorrent daemon script on the forum and just changed it to offlineimap, but it has a few problems.
1. It does not work upon init. It works if I manually do /etc/rc.d/offlineimap start.
2. It does not stop at all, regardless of how I do it - either manually or automatically.
Anything I can do to get this working?
Thanks.
#!/bin/bash
. /etc/rc.conf
. /etc/rc.d/functions
[ -z "$OFFLINEIMAP" ] && OFFLINEIMAP=/usr/bin/offlineimap
[ -z "$OFFLINEIMAP_USER" ] && OFFLINEIMAP_USER=oliver
[ -z "$OFFLINEIMAP_HOME" ] && OFFLINEIMAP_HOME=/home/oliver
[ -z "$OFFLINEIMAP_SOCKET" ] && OFFLINEIMAP_SOCKET=$OFFLINEIMAP_HOME/.socket
[ -z "$OFFLINEIMAP_LOCK" ] && OFFLINEIMAP_LOCK=$OFFLINEIMAP_HOME/.session/offlineimap.lock
[ -z "$OFFLINEIMAP_DTACH" ] && OFFLINEIMAP_DTACH="/usr/bin/dtach -n $OFFLINEIMAP_SOCKET -z"
case "$1" in
start)
stat_busy "Starting offlineimap"
PID=`pidof -o %PPID $OFFLINEIMAP`
if [ -z "$PID" ]; then
[ -S $OFFLINEIMAP_SOCKET ] && rm $OFFLINEIMAP_SOCKET &> /dev/null
[ -f $OFFLINEIMAP_LOCK ] && rm $OFFLINEIMAP_LOCK &> /dev/null
fi
/bin/su -c "$OFFLINEIMAP_DTACH $OFFLINEIMAP &> /dev/null" \
$OFFLINEIMAP_USER
if [ $? -gt 0 ]; then
stat_fail
else
add_daemon offlineimap
stat_done
fi
;;
stop)
stat_busy "Stopping offlineimap"
PID=`pidof -o %PPID $OFFLINEIMAP`
[ ! -z "$PID" ] && kill -s INT $PID &> /dev/null
if [ $? -gt 0 ]; then
stat_fail
else
rm_daemon offlineimap
stat_done
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "usage: $0 {start|stop|restart}"
esac
exit 0
Last edited by MTsoul (2009-02-04 08:10:21)
Offline
I just realized that offlineimap is a python script, and pidof definitely won't work for stopping it. But it still doens't explain why starting it upon init does not work.
Offline
Why not put it it your cron file?
Offline
Win.
Thanks that was one hell of a stupid question haha.
Offline
1. It does not work upon init. It works if I manually do /etc/rc.d/offlineimap start.
Have to ask, as you didn't mention it - did you add it to the rc.conf DAEMONS array?
Offline
Yeah I did. Oh well.
Offline
Pages: 1