#!/bin/bash
#
# prosody - Flexible communications server for Jabber/XMPP
#
# chkconfig: - 90 10
# description: Prosody is a flexible communications server for Jabber/XMPP written in Lua. \
# It aims to be easy to use, and light on resources. For developers it aims \
# to be easy to extend and give a flexible system on which to rapidly develop \
# added functionality, or prototype new protocols.
# config: /etc/prosody/prosody.cfg.lua
# pidfile: /var/run/prosody/prosody.pid
### BEGIN INIT INFO
# Provides: prosody
# Required-Start: $local_fs $network $remote_fs
# Required-Stop: $local_fs $network $remote_fs
# Default-Start:
# Default-Stop: 0 1 6
# Short-Description: Flexible communications server for Jabber/XMPP
# Description: Prosody is a flexible communications server for Jabber/XMPP written in Lua.
# It aims to be easy to use, and light on resources. For developers it aims
# to be easy to extend and give a flexible system on which to rapidly develop
# added functionality, or prototype new protocols.
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
prog="Prosody XMPP (Jabber) server"
exec="/usr/bin/prosodyctl"
user="prosody"
lockfile="/var/lock/subsys/prosody"
pidfile="/var/run/prosody/prosody.pid"
[ -e /etc/sysconfig/prosody ] && . /etc/sysconfig/prosody
start() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
echo -n $"Starting $prog: "
# Avoid output "Started\n" after successful startup
OUTPUT="`daemon --user $user $exec start`"
RETVAL=$?
echo -n "${OUTPUT/Started$'\n'/}"
[ $RETVAL -eq 0 ] && touch $lockfile
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
# Avoid output "Stopped\n" and "Prosody is not running\n"
OUTPUT="`daemon $exec stop`"
RETVAL=$?
OUTPUT="${OUTPUT/Stopped$'\n'/}"
echo -n "${OUTPUT/Prosody is not running$'\n'/}"
[ $RETVAL -eq 0 ] && rm -f $lockfile
echo
return $RETVAL
}
reload() {
echo -n $"Reloading $prog: "
# Avoid prosody specific output after successful reload
OUTPUT="`$exec reload`"
RETVAL=$?
[ $RETVAL -eq 0 ] && success || (echo "$OUTPUT"; failure)
echo
return $RETVAL
}
rh_status() {
status -p $pidfile $exec
}
rh_status_q() {
rh_status > /dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart)
stop
start
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
restart
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
stop
start
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac
exit $?