summaryrefslogtreecommitdiff
blob: 1f37df66a5c41b2dee4103890b635fbc90f40fcb (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-2007 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.4.initd,v 1.1 2007/09/14 11:38:29 chainsaw 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 \
		--exec /usr/bin/env HOME=/var/run/jabber /usr/bin/ejabberd -- -noshell -detached
	eend $?
	# For bug #190266
	chown jabber:jabber /var/run/jabber/.erlang.cookie
}

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 $?
}