2003-09-04 20:17:39 +02:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# PROVIDE: ejabberd
|
|
|
|
# REQUIRE: DAEMON
|
|
|
|
# KEYWORD: shutdown
|
|
|
|
#
|
|
|
|
|
|
|
|
HOME=/usr/pkg/jabber D=/usr/pkg/jabber/ejabberd export HOME
|
|
|
|
|
|
|
|
name="ejabberd"
|
|
|
|
rcvar=$name
|
|
|
|
|
|
|
|
if [ -r /etc/rc.conf ]
|
|
|
|
then
|
|
|
|
. /etc/rc.conf
|
|
|
|
else
|
|
|
|
eval ${rcvar}=YES
|
|
|
|
fi
|
|
|
|
|
|
|
|
# $flags from environment overrides ${rcvar}_flags
|
|
|
|
if [ -n "${flags}" ]
|
|
|
|
then
|
|
|
|
eval ${rcvar}_flags="${flags}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
checkyesno()
|
|
|
|
{
|
|
|
|
eval _value=\$${1}
|
|
|
|
case $_value in
|
|
|
|
[Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1) return 0 ;;
|
|
|
|
[Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0) return 1 ;;
|
|
|
|
*)
|
|
|
|
echo "\$${1} is not set properly."
|
|
|
|
return 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
cmd=${1:-start}
|
|
|
|
case ${cmd} in
|
|
|
|
force*)
|
|
|
|
cmd=${cmd#force}
|
|
|
|
eval ${rcvar}=YES
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
if checkyesno ${rcvar}
|
|
|
|
then
|
|
|
|
else
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
case ${cmd} in
|
|
|
|
start)
|
|
|
|
if [ -x $D/src ]; then
|
|
|
|
echo "Starting ${name}."
|
|
|
|
cd $D/src
|
|
|
|
su jabber -c "/usr/pkg/bin/erl -sname ejabberd -s ejabberd -heart -detached &" \
|
|
|
|
1>/dev/null 2>&1
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
echo "rpc:call('ejabberd@`hostname -s`', init, stop, [])." | \
|
2003-09-10 21:49:48 +02:00
|
|
|
su jabber -c "/usr/pkg/bin/erl -sname ejabberdstop"
|
2003-09-04 20:17:39 +02:00
|
|
|
;;
|
|
|
|
restart)
|
|
|
|
echo "rpc:call('ejabberd@`hostname -s`', init, restart, [])." | \
|
2003-09-10 21:49:48 +02:00
|
|
|
su jabber -c "/usr/pkg/bin/erl -sname ejabberdrestart"
|
2003-09-04 20:17:39 +02:00
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 {start|stop|restart}"
|
|
|
|
exit 1
|
|
|
|
esac
|