25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Added preliminary template file for ejabberd.init (thanks to Christophe Romain)

SVN Revision: 2520
This commit is contained in:
Badlop 2009-08-24 19:43:52 +00:00
parent ad7a8fffd5
commit 11be369987
2 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,46 @@
#! /bin/sh
set -o errexit
set -o nounset
DIR=@@INSTALLDIR@@
CTL="$DIR"/bin/ejabberdctl
USER=ejabberd
test -d "$DIR" || {
echo "ERROR: ejabberd not found: $DIR"
exit 1
}
grep ^"$USER": /etc/passwd >/dev/null || {
echo "ERROR: System user not found: $USER"
exit 2
}
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in
start)
test -x "$CTL" || exit 0
echo "Starting ejabberd..."
su - $USER -c "$CTL start"
su - $USER -c "$CTL started"
echo "done."
;;
stop)
test -x "$CTL" || exit 0
echo "Stopping ejabberd..."
su - $USER -c "$CTL stop"
su - $USER -c "$CTL stopped"
echo "done."
;;
force-reload|restart)
"$0" stop
"$0" start
;;
*)
echo "Usage: $0 {start|stop|restart|force-reload}"
exit 1
esac
exit 0

View File

@ -239,9 +239,42 @@ usage ()
exit
}
# stop epmd if there is no other running node
stop_epmd()
{
epmd -names | grep -q name || epmd -kill
}
# allow sync calls
wait_for_status()
{
# args: status try delay
# return: 0 OK, 1 KO
timeout=$2
status=4
while [ $status -ne $1 ]; do
sleep $3
let timeout=timeout-1
[ $timeout -eq 0 ] && {
status=$1
} || {
ctl status > /dev/null
status=$?
}
done
[ $timeout -eq 0 ] && {
status=1
} || {
status=0
}
return $status
}
case $ARGS in
' start') start;;
' debug') debug;;
' live') live;;
' started') wait_for_status 0 30 2;; # wait 30x2s before timeout
' stopped') wait_for_status 3 15 2; stop_epmd;; # wait 15x2s before timeout
*) ctl $ARGS;;
esac