$NetBSD: patch-ae,v 1.11 2015/06/29 21:44:10 fhajny Exp $

- Default locations.
- Make it work with NetBSD's flock(1).

--- ejabberdctl.template.orig	2015-06-24 09:58:37.000000000 +0000
+++ ejabberdctl.template
@@ -71,10 +71,10 @@ if [ "$EJABBERD_CONFIG_PATH" = "" ] ; th
     EJABBERD_CONFIG_PATH=$ETC_DIR/ejabberd.yml
 fi
 if [ "$LOGS_DIR" = "" ] ; then
-    LOGS_DIR={{localstatedir}}/log/ejabberd
+    LOGS_DIR=@EJABBERD_LOGDIR@
 fi
 if [ "$SPOOL_DIR" = "" ] ; then
-    SPOOL_DIR={{localstatedir}}/lib/ejabberd
+    SPOOL_DIR=@EJABBERD_DB@
 fi
 if [ "$EJABBERD_DOC_PATH" = "" ] ; then
     EJABBERD_DOC_PATH={{docdir}}
@@ -85,7 +85,7 @@ if [ "$ERLANG_NODE_ARG" != "" ] ; then
 fi
 if [ "{{release}}" != "true" ] ; then
     if [ "$EJABBERDDIR" = "" ] ; then
-        EJABBERDDIR={{libdir}}/ejabberd
+        EJABBERDDIR={{libdir}}/erlang/lib/@DISTNAME@
     fi
     if [ "$EJABBERD_EBIN_PATH" = "" ] ; then
         EJABBERD_EBIN_PATH=$EJABBERDDIR/ebin
@@ -335,7 +335,7 @@ ctl()
     # using flock if available. Expects a linux-style
     # flock that can lock a file descriptor.
     MAXCONNID=100
-    CONNLOCKDIR={{localstatedir}}/lock/ejabberdctl
+    CONNLOCKDIR=@EJABBERD_PIDDIR@
     FLOCK=/usr/bin/flock
     if [ ! -x "$FLOCK" ] || [ ! -d "$CONNLOCKDIR" ] ; then
         JOT=/usr/bin/jot
@@ -362,7 +362,7 @@ ctl()
             CTL_LOCKFILE="$CONNLOCKDIR/$CTL_CONN"
             (
                 exec 8>"$CTL_LOCKFILE"
-                if flock --nb 8; then
+                if flock -x -n 8; then
                     ctlexec $CTL_CONN $COMMAND
                     ssresult=$?
                     # segregate from possible flock exit(1)
