diff options
Diffstat (limited to 'net-im/ejabberd/files/ejabberd.sh.in')
-rw-r--r-- | net-im/ejabberd/files/ejabberd.sh.in | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/net-im/ejabberd/files/ejabberd.sh.in b/net-im/ejabberd/files/ejabberd.sh.in new file mode 100644 index 000000000000..d7e27e13b918 --- /dev/null +++ b/net-im/ejabberd/files/ejabberd.sh.in @@ -0,0 +1,87 @@ +#! /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="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" |