# Cannot start davmail daemon at startup



## Peter2121 (Feb 21, 2011)

Hello,

I'm trying to install davmail in server mode at FreeBSD 8.1. I've prepared rc.d script, it works fine if I launch it manually:
[cmd=]/usr/local/etc/rc.d/davmail start[/cmd]

But the system cannot launch it during the startup:


```
WARNING: failed to start davmail
```
 

The main script /usr/local/bin/davmail:


```
#!/bin/sh
BASE="/usr/local/share/java/davmail"
CONFIG="/usr/local/etc/davmail/davmail.properties"
LOG="/var/log/davmail/davmail.log"
echo Starting... >>$LOG
for i in $BASE/lib/*; do export CLASSPATH=$CLASSPATH:$i; done
#echo CLASSPATH: $CLASSPATH >>$LOG
java -cp $BASE/davmail.jar:$CLASSPATH:/usr/local/share/java/classes/swt.jar davmail.DavGateway $1 >>$LOG 2>&1 &
```

The rc.d script /usr/local/etc/rc.d/davmail:

```
#!/bin/sh
#
# $FreeBSD$
#
#
# PROVIDE: davmail
# REQUIRE: DAEMON LOGIN NETWORKING cleanvar
#
DAVMAIL_HOME="/usr/local/etc/davmail"
LOG="/var/log/davmail/davmail.log"
CONFIG="/usr/local/etc/davmail/davmail.properties"

. /etc/rc.subr

name="davmail"
rcvar=`set_rcvar`
command="/usr/local/bin/${name}"
command_args="$CONFIG"
pidfile="/var/run/${name}.pid"
required_files="${DAVMAIL_HOME}/${name}.properties"
procname="java"
davmail_user="davmail"

start_postcmd="${name}_poststart"
stop_postcmd="${name}_poststop"

davmail_poststart()
{
sleep 5
pid=`jps |grep DavGateway |cut -d" " -f1`
echo "$pid" >$pidfile
info "Started ${name} PID: $pid"
}

davmail_poststop()
{
    rm -f $pidfile
}

load_rc_config ${name}
run_rc_command "$1"
```

There is nothing usable in davmail.log, nothing usable in /var/log/messages. :\

Does anyone have an idea?


----------



## SirDice (Feb 21, 2011)

How did you install davmail?


----------



## Peter2121 (Feb 21, 2011)

I installed davmail from the ports collection, then I replaced the installed tree by the last version downloaded from sourceforge.

Note that I have no problems with davmail, if I start it manually it works fine.


----------



## Peter2121 (Feb 22, 2011)

I think I've found it.

/usr/local/bin is not in the path during rc.d script startup. So, java tools were not found (java and jps). It's ok now with full path for these tools.


----------

