freebsd-ports/net-im/ejabberd/files/ejabberd.sh.in
Doug Barton ffde46cbf9 Now that new style rc.d scripts are being run as part of the
base rcorder, hard coded variable values in these scripts
are overriding the values in /etc/rc.conf[.local] (due to
the way that variables from the latter are read at boot time).

Therefore, change the boot scripts to set default values only
if the variable is unset in /etc/rc.conf[.local]. This will
allow the service to start at boot time if it's been enabled
as the user would expect.

This change will be a noop for users who have systems that
have not yet been upgraded to the new rc.d code in the base.

In many cases there are other variables in the scripts that
should get similar treatment, however I did not change
anything other than the _enable lines. I'll leave the rest
up to the maintainers to do as they see fit.

Bump PORTREVISION to make sure that users and packages
pick up this change.
2006-01-07 06:29:57 +00:00

87 lines
1.8 KiB
Bash

#! /bin/sh
# $FreeBSD$
# PROVIDE: ejabberd
# REQUIRE: DAEMON
# BEFORE: LOGIN
# KEYWORD: shutdown
# Define these ejabberd_* variables in one of these files:
# /etc/rc.conf
# /etc/rc.conf.local
# /etc/rc.conf.d/ejabberd
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#
ejabberd_enable="${ejabberd_enable-NO}"
. %%RC_SUBR%%
name=ejabberd
rcvar=`set_rcvar`
reload_cmd="ejabberd_reload"
restart_cmd="ejabberd_reload"
start_cmd="ejabberd_start"
status_cmd="ejabberd_status"
stop_cmd="ejabberd_stop"
# Include ejabberd defaults if available
[ -f %%PREFIX%%/etc/ejabberd/ejabberd.defaults ] && . %%PREFIX%%/etc/ejabberd/ejabberd.defaults
PATH=/sbin:/bin:/usr/sbin:/usr/bin:%%PREFIX%%/bin:%%PREFIX%%/sbin
EJABBERD=%%PREFIX%%/bin/ejabberd
EJABBERDCTL=%%PREFIX%%/bin/ejabberdctl
EJABBERDUSER=ejabberd
ejabberd_status()
{
su $EJABBERDUSER -c "$EJABBERDCTL ejabberd@`hostname -s` status >/dev/null"
}
ejabberd_start()
{
echo -n "Starting $name: "
if ejabberd_status; then
echo " already running."
exit 1
else
su $EJABBERDUSER -c "$EJABBERD -noshell -detached"
fi
echo "$name."
}
ejabberd_stop()
{
echo -n "Stopping $name: "
if su $EJABBERDUSER -c "$EJABBERDCTL ejabberd@`hostname -s` stop"; then
cnt=0
while ejabberd_status; do
cnt=`expr $cnt + 1`
if [ $cnt -gt 60 ]; then
echo -n " failed "
break
fi
sleep 1
echo -n "."
done
else
echo -n " failed "
fi
echo "$name."
}
ejabberd_reload()
{
echo -n "Restarting $name: "
if ejabberd_status; then
su $EJABBERDUSER -c "$EJABBERDCTL ejabberd@`hostname -s` restart"
else
ejabberd_start
fi
echo "$name."
}
load_rc_config $name
run_rc_command "$1"