$NetBSD: patch-ae,v 1.18 2017/10/17 14:55:36 fhajny Exp $ - Default locations. - Use 'su -' instead of just 'su'. Fixes priv delegation on SunOS and AIX where Erlang relies on $HOME set correctly. Use a portable su arg order while at it. - At least SunOS has not wheel group. - Portable grep calls. --- ejabberdctl.template.orig 2017-09-28 13:21:11.000000000 +0000 +++ ejabberdctl.template @@ -57,8 +57,8 @@ done # define ejabberd variables if not already defined from the command line : "${ETC_DIR:="{{sysconfdir}}/ejabberd"}" -: "${LOGS_DIR:="{{localstatedir}}/log/ejabberd"}" -: "${SPOOL_DIR:="{{localstatedir}}/lib/ejabberd"}" +: "${LOGS_DIR:=@EJABBERD_LOGDIR@}" +: "${SPOOL_DIR:=@EJABBERD_DB@}" : "${EJABBERD_CONFIG_PATH:="$ETC_DIR/ejabberd.yml"}" : "${EJABBERDCTL_CONFIG_PATH:="$ETC_DIR/ejabberdctl.cfg"}" [ -f "$EJABBERDCTL_CONFIG_PATH" ] && . "$EJABBERDCTL_CONFIG_PATH" @@ -109,7 +109,7 @@ export ERL_LIBS exec_cmd() { case $EXEC_CMD in - as_install_user) su -c '"$0" "$@"' "$INSTALLUSER" -- "$@" ;; + as_install_user) su - "$INSTALLUSER" -c '"$@"' -- "$@" ;; as_current_user) "$@" ;; esac } @@ -208,14 +208,14 @@ uid() # stop epmd if there is no other running node stop_epmd() { - "$EPMD" -names 2>/dev/null | grep -q name || "$EPMD" -kill >/dev/null + "$EPMD" -names 2>/dev/null | grep name >/dev/null || "$EPMD" -kill >/dev/null } # make sure node not already running and node name unregistered # if all ok, ensure runtime directory exists and make it current directory check_start() { - "$EPMD" -names 2>/dev/null | grep -q " ${ERLANG_NODE%@*} " && { + "$EPMD" -names 2>/dev/null | grep " ${ERLANG_NODE%@*} " >/dev/null && { pgrep -f "$ERLANG_NODE" >/dev/null && { echo "ERROR: The ejabberd node '$ERLANG_NODE' is already running." exit 4