mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
remove bash dependency, fix EJABBERD_OPTS use
This commit is contained in:
parent
790201afc0
commit
40ef406ec7
@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
|
||||||
# define default configuration
|
# define default configuration
|
||||||
POLL=true
|
POLL=true
|
||||||
@ -7,7 +7,6 @@ ERL_MAX_PORTS=32000
|
|||||||
ERL_PROCESSES=250000
|
ERL_PROCESSES=250000
|
||||||
ERL_MAX_ETS_TABLES=1400
|
ERL_MAX_ETS_TABLES=1400
|
||||||
FIREWALL_WINDOW=""
|
FIREWALL_WINDOW=""
|
||||||
INET_DIST_INTERFACE="127.0.0.1"
|
|
||||||
ERLANG_NODE=ejabberd@localhost
|
ERLANG_NODE=ejabberd@localhost
|
||||||
|
|
||||||
# define default environment variables
|
# define default environment variables
|
||||||
@ -45,33 +44,33 @@ while [ $# -ne 0 ] ; do
|
|||||||
case $PARAM in
|
case $PARAM in
|
||||||
--) break ;;
|
--) break ;;
|
||||||
--node) ERLANG_NODE_ARG=$1 ; shift ;;
|
--node) ERLANG_NODE_ARG=$1 ; shift ;;
|
||||||
--config-dir) ETCDIR=$1 ; shift ;;
|
--config-dir) ETC_DIR="$1" ; shift ;;
|
||||||
--config) EJABBERD_CONFIG_PATH=$1 ; shift ;;
|
--config) EJABBERD_CONFIG_PATH="$1" ; shift ;;
|
||||||
--ctl-config) EJABBERDCTL_CONFIG_PATH=$1 ; shift ;;
|
--ctl-config) EJABBERDCTL_CONFIG_PATH="$1" ; shift ;;
|
||||||
--logs) LOGS_DIR=$1 ; shift ;;
|
--logs) LOGS_DIR="$1" ; shift ;;
|
||||||
--spool) SPOOLDIR=$1 ; shift ;;
|
--spool) SPOOL_DIR="$1" ; shift ;;
|
||||||
*) ARGS="$ARGS $PARAM" ;;
|
*) ARGS="$ARGS $PARAM" ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
# Define ejabberd variable if they have not been defined from the command line
|
# Define ejabberd variable if they have not been defined from the command line
|
||||||
if [ "$ETCDIR" = "" ] ; then
|
if [ "$ETC_DIR" = "" ] ; then
|
||||||
ETCDIR={{sysconfdir}}/ejabberd
|
ETC_DIR={{sysconfdir}}/ejabberd
|
||||||
fi
|
fi
|
||||||
if [ "$EJABBERDCTL_CONFIG_PATH" = "" ] ; then
|
if [ "$EJABBERDCTL_CONFIG_PATH" = "" ] ; then
|
||||||
EJABBERDCTL_CONFIG_PATH=$ETCDIR/ejabberdctl.cfg
|
EJABBERDCTL_CONFIG_PATH=$ETC_DIR/ejabberdctl.cfg
|
||||||
fi
|
fi
|
||||||
if [ -f "$EJABBERDCTL_CONFIG_PATH" ] ; then
|
if [ -f "$EJABBERDCTL_CONFIG_PATH" ] ; then
|
||||||
. "$EJABBERDCTL_CONFIG_PATH"
|
. "$EJABBERDCTL_CONFIG_PATH"
|
||||||
fi
|
fi
|
||||||
if [ "$EJABBERD_CONFIG_PATH" = "" ] ; then
|
if [ "$EJABBERD_CONFIG_PATH" = "" ] ; then
|
||||||
EJABBERD_CONFIG_PATH=$ETCDIR/ejabberd.yml
|
EJABBERD_CONFIG_PATH=$ETC_DIR/ejabberd.yml
|
||||||
fi
|
fi
|
||||||
if [ "$LOGS_DIR" = "" ] ; then
|
if [ "$LOGS_DIR" = "" ] ; then
|
||||||
LOGS_DIR={{localstatedir}}/log/ejabberd
|
LOGS_DIR={{localstatedir}}/log/ejabberd
|
||||||
fi
|
fi
|
||||||
if [ "$SPOOLDIR" = "" ] ; then
|
if [ "$SPOOL_DIR" = "" ] ; then
|
||||||
SPOOLDIR={{localstatedir}}/lib/ejabberd
|
SPOOL_DIR={{localstatedir}}/lib/ejabberd
|
||||||
fi
|
fi
|
||||||
if [ "$EJABBERD_DOC_PATH" = "" ] ; then
|
if [ "$EJABBERD_DOC_PATH" = "" ] ; then
|
||||||
EJABBERD_DOC_PATH={{docdir}}
|
EJABBERD_DOC_PATH={{docdir}}
|
||||||
@ -104,8 +103,7 @@ EJABBERD_LOG_PATH=$LOGS_DIR/ejabberd.log
|
|||||||
SASL_LOG_PATH=$LOGS_DIR/erlang.log
|
SASL_LOG_PATH=$LOGS_DIR/erlang.log
|
||||||
DATETIME=`date "+%Y%m%d-%H%M%S"`
|
DATETIME=`date "+%Y%m%d-%H%M%S"`
|
||||||
ERL_CRASH_DUMP=$LOGS_DIR/erl_crash_$DATETIME.dump
|
ERL_CRASH_DUMP=$LOGS_DIR/erl_crash_$DATETIME.dump
|
||||||
ERL_INETRC=$ETCDIR/inetrc
|
ERL_INETRC=$ETC_DIR/inetrc
|
||||||
HOME=$SPOOLDIR
|
|
||||||
|
|
||||||
# define erl parameters
|
# define erl parameters
|
||||||
ERLANG_OPTS="+K $POLL -smp $SMP +P $ERL_PROCESSES $ERL_OPTIONS"
|
ERLANG_OPTS="+K $POLL -smp $SMP +P $ERL_PROCESSES $ERL_OPTIONS"
|
||||||
@ -128,15 +126,15 @@ fi
|
|||||||
|
|
||||||
# define ejabberd environment parameters
|
# define ejabberd environment parameters
|
||||||
if [ "$EJABBERD_CONFIG_PATH" != "${EJABBERD_CONFIG_PATH%.yml}" ] ; then
|
if [ "$EJABBERD_CONFIG_PATH" != "${EJABBERD_CONFIG_PATH%.yml}" ] ; then
|
||||||
rate=$(grep log_rate_limit $EJABBERD_CONFIG_PATH | cut -d':' -f2 | sed 's/ *//')
|
rate=$(sed '/^[ ]*log_rate_limit/!d;s/.*://;s/ *//' $EJABBERD_CONFIG_PATH)
|
||||||
rotate=$(grep log_rotate_size $EJABBERD_CONFIG_PATH | cut -d':' -f2 | sed 's/ *//')
|
rotate=$(sed '/^[ ]*log_rotate_size/!d;s/.*://;s/ *//' $EJABBERD_CONFIG_PATH)
|
||||||
count=$(grep log_rotate_count $EJABBERD_CONFIG_PATH | cut -d':' -f2 | sed 's/ *//')
|
count=$(sed '/^[ ]*log_rotate_count/!d;s/.*://;s/ *//' $EJABBERD_CONFIG_PATH)
|
||||||
date=$(grep log_rotate_date $EJABBERD_CONFIG_PATH | cut -d':' -f2 | sed 's/ *//')
|
date=$(sed '/^[ ]*log_rotate_date/!d;s/.*://;s/ *//' $EJABBERD_CONFIG_PATH)
|
||||||
else
|
else
|
||||||
rate=$(grep log_rate_limit $EJABBERD_CONFIG_PATH | cut -d',' -f2 | sed 's/ *//;s/}\.//')
|
rate=$(sed '/^[ ]*log_rate_limit/!d;s/.*,//;s/ *//;s/}\.//' $EJABBERD_CONFIG_PATH)
|
||||||
rotate=$(grep log_rotate_size $EJABBERD_CONFIG_PATH | cut -d',' -f2 | sed 's/ *//;s/}\.//')
|
rotate=$(sed '/^[ ]*log_rotate_size/!d;s/.*,//;s/ *//;s/}\.//' $EJABBERD_CONFIG_PATH)
|
||||||
count=$(grep log_rotate_count $EJABBERD_CONFIG_PATH | cut -d',' -f2 | sed 's/ *//;s/}\.//')
|
count=$(sed '/^[ ]*log_rotate_count/!d;s/.*,//;s/ *//;s/}\.//' $EJABBERD_CONFIG_PATH)
|
||||||
date=$(grep log_rotate_date $EJABBERD_CONFIG_PATH | cut -d',' -f2 | sed 's/ *//;s/}\.//')
|
date=$(sed '/^[ ]*log_rotate_date/!d;s/.*,//;s/ *//;s/}\.//' $EJABBERD_CONFIG_PATH)
|
||||||
fi
|
fi
|
||||||
[ -z "$rate" ] || EJABBERD_OPTS="log_rate_limit $rate"
|
[ -z "$rate" ] || EJABBERD_OPTS="log_rate_limit $rate"
|
||||||
[ -z "$rotate" ] || EJABBERD_OPTS="${EJABBERD_OPTS} log_rotate_size $rotate"
|
[ -z "$rotate" ] || EJABBERD_OPTS="${EJABBERD_OPTS} log_rotate_size $rotate"
|
||||||
@ -148,7 +146,11 @@ fi
|
|||||||
# then change to that directory readable by INSTALLUSER to
|
# then change to that directory readable by INSTALLUSER to
|
||||||
# prevent "File operation error: eacces." messages
|
# prevent "File operation error: eacces." messages
|
||||||
[ -d $HOME ] || $EXEC_CMD "mkdir -p $HOME"
|
[ -d $HOME ] || $EXEC_CMD "mkdir -p $HOME"
|
||||||
cd $HOME
|
[ -d $SPOOL_DIR ] || $EXEC_CMD "mkdir -p $SPOOL_DIR"
|
||||||
|
# then set SPOOL_DIR as ejabberd home directory by changing
|
||||||
|
# to that directory readable by INSTALLUSER to prevent
|
||||||
|
# "File operation error: eacces." messages
|
||||||
|
cd $SPOOL_DIR
|
||||||
|
|
||||||
# export global variables
|
# export global variables
|
||||||
export EJABBERD_CONFIG_PATH
|
export EJABBERD_CONFIG_PATH
|
||||||
@ -163,8 +165,6 @@ export ERL_EPMD_ADDRESS
|
|||||||
export ERL_INETRC
|
export ERL_INETRC
|
||||||
export ERL_MAX_PORTS
|
export ERL_MAX_PORTS
|
||||||
export ERL_MAX_ETS_TABLES
|
export ERL_MAX_ETS_TABLES
|
||||||
export HOME
|
|
||||||
export EXEC_CMD
|
|
||||||
|
|
||||||
# start server
|
# start server
|
||||||
start()
|
start()
|
||||||
@ -174,8 +174,9 @@ start()
|
|||||||
$NAME $ERLANG_NODE \
|
$NAME $ERLANG_NODE \
|
||||||
-noinput -detached \
|
-noinput -detached \
|
||||||
-pa $EJABBERD_EBIN_PATH \
|
-pa $EJABBERD_EBIN_PATH \
|
||||||
-mnesia dir \"\\\"$SPOOLDIR\\\"\" \
|
-mnesia dir \"\\\"$SPOOL_DIR\\\"\" \
|
||||||
$KERNEL_OPTS \
|
$KERNEL_OPTS \
|
||||||
|
$EJABBERD_OPTS \
|
||||||
-s ejabberd \
|
-s ejabberd \
|
||||||
-sasl sasl_error_logger \\{file,\\\"$SASL_LOG_PATH\\\"\\} \
|
-sasl sasl_error_logger \\{file,\\\"$SASL_LOG_PATH\\\"\\} \
|
||||||
$ERLANG_OPTS $ARGS \"$@\""
|
$ERLANG_OPTS $ARGS \"$@\""
|
||||||
@ -198,13 +199,12 @@ debug()
|
|||||||
echo " control+c, control+c"
|
echo " control+c, control+c"
|
||||||
echo ""
|
echo ""
|
||||||
echo "--------------------------------------------------------------------"
|
echo "--------------------------------------------------------------------"
|
||||||
echo "To bypass permanently this warning, add to $EJABBERDCTL_CONFIG_PATH the line:"
|
echo "To bypass permanently this warning, add to ejabberdctl.cfg the line:"
|
||||||
echo " EJABBERD_BYPASS_WARNINGS=true"
|
echo " EJABBERD_BYPASS_WARNINGS=true"
|
||||||
echo "Press any key to continue"
|
echo "Press any key to continue"
|
||||||
|
|
||||||
read foo
|
read foo
|
||||||
fi
|
|
||||||
echo ""
|
echo ""
|
||||||
|
fi
|
||||||
TTY=`tty | sed -e 's/.*\///g'`
|
TTY=`tty | sed -e 's/.*\///g'`
|
||||||
$EXEC_CMD "$ERL \
|
$EXEC_CMD "$ERL \
|
||||||
$NAME debug-${TTY}-${ERLANG_NODE} \
|
$NAME debug-${TTY}-${ERLANG_NODE} \
|
||||||
@ -231,18 +231,18 @@ live()
|
|||||||
echo " q(). and press the Enter key"
|
echo " q(). and press the Enter key"
|
||||||
echo ""
|
echo ""
|
||||||
echo "--------------------------------------------------------------------"
|
echo "--------------------------------------------------------------------"
|
||||||
echo "To bypass permanently this warning, add to $EJABBERDCTL_CONFIG_PATH the line:"
|
echo "To bypass permanently this warning, add to ejabberdctl.cfg the line:"
|
||||||
echo " EJABBERD_BYPASS_WARNINGS=true"
|
echo " EJABBERD_BYPASS_WARNINGS=true"
|
||||||
echo "Press any key to continue"
|
echo "Press any key to continue"
|
||||||
|
|
||||||
read foo
|
read foo
|
||||||
fi
|
|
||||||
echo ""
|
echo ""
|
||||||
|
fi
|
||||||
$EXEC_CMD "$ERL \
|
$EXEC_CMD "$ERL \
|
||||||
$NAME $ERLANG_NODE \
|
$NAME $ERLANG_NODE \
|
||||||
-pa $EJABBERD_EBIN_PATH \
|
-pa $EJABBERD_EBIN_PATH \
|
||||||
-mnesia dir \"\\\"$SPOOLDIR\\\"\" \
|
-mnesia dir \"\\\"$SPOOL_DIR\\\"\" \
|
||||||
$KERNEL_OPTS \
|
$KERNEL_OPTS \
|
||||||
|
$EJABBERD_OPTS \
|
||||||
-s ejabberd \
|
-s ejabberd \
|
||||||
$ERLANG_OPTS $ARGS \"$@\""
|
$ERLANG_OPTS $ARGS \"$@\""
|
||||||
}
|
}
|
||||||
@ -263,11 +263,11 @@ help()
|
|||||||
echo " live Start an ejabberd node in live (interactive) mode"
|
echo " live Start an ejabberd node in live (interactive) mode"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Optional parameters when starting an ejabberd node:"
|
echo "Optional parameters when starting an ejabberd node:"
|
||||||
echo " --config-dir dir Config ejabberd: $ETCDIR"
|
echo " --config-dir dir Config ejabberd: $ETC_DIR"
|
||||||
echo " --config file Config ejabberd: $EJABBERD_CONFIG_PATH"
|
echo " --config file Config ejabberd: $EJABBERD_CONFIG_PATH"
|
||||||
echo " --ctl-config file Config ejabberdctl: $EJABBERDCTL_CONFIG_PATH"
|
echo " --ctl-config file Config ejabberdctl: $EJABBERDCTL_CONFIG_PATH"
|
||||||
echo " --logs dir Directory for logs: $LOGS_DIR"
|
echo " --logs dir Directory for logs: $LOGS_DIR"
|
||||||
echo " --spool dir Database spool dir: $SPOOLDIR"
|
echo " --spool dir Database spool dir: $SPOOL_DIR"
|
||||||
echo " --node nodename ejabberd node name: $ERLANG_NODE"
|
echo " --node nodename ejabberd node name: $ERLANG_NODE"
|
||||||
echo ""
|
echo ""
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user