summaryrefslogtreecommitdiff
blob: ce958a7add40df2f11d41ecbb3c4eeea2fec2e6c (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
#!/sbin/runscript
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-im/ejabberd/files/ejabberd-1.1.1-r1.initd,v 1.4 2007/12/08 16:49:48 ulm Exp $

opts="${opts} reload"

depend() {
	use dns
	need net
	provide jabber-server
}

checkconfig() {
	if [ ! -e /etc/jabber/ejabberd.cfg ] ; then
		eerror "You need an /etc/jabber/ejabberd.cfg file to run ejabberd"
		return 1
	fi
}

start() {
	checkconfig || return 1
	ebegin "Starting eJabberd"
	start-stop-daemon --start --quiet --chuid jabber:jabber \
        --env HOME=/var/run/jabber \
        --exec /usr/bin/beam \
		--startas /usr/bin/ejabberd -- -noshell -detached
	eend $?
}

stop() {
	ebegin "Stopping eJabberd"
	if [ -z "$EJABBERD_NODE" ];
	then
		EJABBERD_NODE="ejabberd@`hostname -s`"
	fi
	/usr/bin/ejabberdctl $EJABBERD_NODE stop
	eend $?
}

# Work around a bug in /sbin/runscript.sh - it won't run our custom
# restart() unless it finds these two strings in the file.
# svc_start svc_stop
restart() {
	ebegin "Restarting eJabberd"
	if [ -z "$EJABBERD_NODE" ];
	then
		EJABBERD_NODE="ejabberd@`hostname -s`"
	fi
	/usr/bin/ejabberdctl $EJABBERD_NODE restart
	eend $?
}

reload() {
	ebegin "Reloading eJabberd"
	if [ -z "$EJABBERD_NODE" ];
	then
		EJABBERD_NODE="ejabberd@`hostname -s`"
	fi
	/usr/bin/ejabberdctl $EJABBERD_NODE reopen-log
	eend $?
}