mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-22 16:20:52 +01:00
Added preliminary template file for ejabberd.init (thanks to Christophe Romain)
SVN Revision: 2523
This commit is contained in:
parent
6688b4ea78
commit
d9a8c89b5a
46
src/ejabberd.init.template
Normal file
46
src/ejabberd.init.template
Normal 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
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user