summaryrefslogtreecommitdiff
blob: 94ac2ae8e46544b9a4dff2574a023707b016d497 (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
#!/sbin/openrc-run
# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

extra_started_commands="reload"

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

start() {
	if ejabberdctl status >/dev/null 2>&1; then
		ewarn "ejabberd is already started (manually?)."
		return 0
	fi
	ebegin "Starting ejabberd"
	/usr/sbin/ejabberdctl ${EJABBERDCTL_OPTS} start
	eend $?
}

reload() {
	ebegin "Reloading ejabberd configuration"
	/usr/sbin/ejabberdctl ${EJABBERDCTL_OPTS} reload_config
	eend $?
}

stop() {
	ejabberdctl status >/dev/null 2>&1
	if test $? = 3; then
		ewarn "ejabberd is already stopped (manually?)."
		return 0
	fi
	ebegin "Stopping ejabberd"
	if /usr/sbin/ejabberdctl stop >/dev/null 2>&1; then
		cnt=0
		sleep 1
		while ejabberdctl status >/dev/null 2>&1 || test $? = 1; do
			echo -n .
			cnt=`expr $cnt + 1`
			if [ $cnt -ge 60 ] ; then
				eend 1
				break
			fi
			sleep 1
		done
		eend 0
	else
		eend 1
		einfo "Please, run '/usr/sbin/ejabberdctl stop' to see what's going on."
	fi
	eend 0
}