summaryrefslogtreecommitdiff
path: root/tools/ejabberdctl
diff options
context:
space:
mode:
authorAlexey Shchepin <alexey@process-one.net>2007-05-21 03:41:13 +0000
committerAlexey Shchepin <alexey@process-one.net>2007-05-21 03:41:13 +0000
commitc9e139d80a3eef43e66cad46a9ca14ccc286f912 (patch)
tree684898b91c565f10cd6dad1a297337a1cc38dac1 /tools/ejabberdctl
parent* src/ejabberd_sm.erl: Updated the session table to store (diff)
* src/ejabberdctl.template: Updated version of ejabberdctl (thanks
to Christophe Romain) * tools/ejabberdctl: Likewise * src/Makefile.in: Updated SVN Revision: 773
Diffstat (limited to '')
-rwxr-xr-xtools/ejabberdctl62
1 files changed, 61 insertions, 1 deletions
diff --git a/tools/ejabberdctl b/tools/ejabberdctl
index 48294cae..f4e134b3 100755
--- a/tools/ejabberdctl
+++ b/tools/ejabberdctl
@@ -1,4 +1,64 @@
#!/bin/sh
-exec erl -noinput -sname ejabberdctl -s ejabberd_ctl -extra $@
+NODE=ejabberd
+HOST=localhost
+
+# Define ejabberd environment
+base="`dirname $(which "$0")`/.."
+ROOTDIR=`(cd "$base"; echo $PWD)`
+SASL_LOG_PATH=$ROOTDIR/sasl.log
+EJABBERD_DB=$ROOTDIR/database/$NODE
+export EJABBERD_LOG_PATH=$ROOTDIR/ejabberd.log
+export EJABBERD_CONFIG_PATH=$ROOTDIR/ejabberd.cfg
+export EJABBERD_MSGS_PATH=$ROOTDIR/src/msgs
+export EJABBERD_SO_PATH=$ROOTDIR/src
+export ERL_MAX_PORTS=32000
+
+[ -d $EJABBERD_DB ] || mkdir -p $EJABBERD_DB
+[ -f $EJABBERD_CONFIG_PATH ] || cp $ROOTDIR/src/ejabberd.cfg.example $EJABBERD_CONFIG_PATH
+
+function start
+{
+ erl \
+ -noinput -detached \
+ -sname $NODE@$HOST \
+ -pa $ROOTDIR/src \
+ -mnesia dir "\"$EJABBERD_DB\"" \
+ -s ejabberd \
+ -ejabberd config \"$EJABBERD_CONFIG_PATH\" \
+ log_path \"$EJABBERD_LOG_PATH\" \
+ -sasl sasl_error_logger \{file,\"$SASL_LOG_PATH\"\}
+}
+
+function debug
+{
+ erl \
+ -sname debug$NODE@$HOST \
+ -pa $ROOTDIR/src \
+ -mnesia dir "\"$EJABBERD_DB\"" \
+ -remsh $NODE@$HOST
+}
+
+function ctl
+{
+ erl \
+ -noinput \
+ -sname ejabberdctl@$HOST \
+ -pa $ROOTDIR/src \
+ -s ejabberd_ctl -extra $NODE@$HOST $@
+}
+
+function usage
+{
+ ctl
+ exit
+}
+
+[ $# -lt 1 ] && usage
+
+case $1 in
+ start) start;;
+ debug) debug;;
+ *) ctl $@;;
+esac