aboutsummaryrefslogtreecommitdiff
blob: ca5ae9040cdd17cf2c055a9b4568d55daef9c747 (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
#!/sbin/runscript
# Copyright 2012-2015 Stuart Shelton
# Distributed under the terms of the GNU General Public License v2

DIR="${DAVMAIL_DIR:-%INST_DIR%}"

depend() {
	need localmount
	use net
	before fetchmail dovecot
}

start() {
	ebegin "Building \$CLASSPATH"
	found=1
	for JAR in $( find "${DIR}"/lib/ -type f -name \*.jar ); do
		CLASSPATH="${CLASSPATH}:${JAR}"
		found=0
	done
	eend $found "Unable to find bundled Jar libraries"
	unset found

        ebegin "Starting DavMail"
        start-stop-daemon \
                --start --quiet --pidfile /var/run/davmail.pid \
		--user davmail:davmail --make-pidfile --background \
                --exec java -- ${JAVA_OPTS:-} -cp "${DIR}"/bin/davmail.jar:${CLASSPATH} davmail.DavGateway "${DIR}"/conf/davmail.properties
        local ret=$?
        eend $ret
        return $ret
}

stop() {
        ebegin "Stopping DavMail"
        start-stop-daemon \
                --stop --quiet --pidfile /var/run/davmail.pid
        local ret=$?
        eend $ret
        return $ret
}